Skip to content

Commit

Permalink
Add custom property test to savable and collectable
Browse files Browse the repository at this point in the history
  • Loading branch information
jbtule committed Nov 7, 2023
1 parent 174f314 commit 39385e4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Tests/UnitTestImpromptuInterface/Collectable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using System.Dynamic;
using Dynamitey.DynamicObjects;
using ImpromptuInterface;
using System.ComponentModel;
using System.Reflection;

namespace UnitTestImpromptuInterface

Expand Down Expand Up @@ -129,6 +131,17 @@ public void NestedInterfacetest()
Assert.AreEqual(tNew.Nested.NameLevel2, tActsLike.Nested.NameLevel2);

}


[Test]
public void PropertyAttributeTest()
{
dynamic tNew = new ExpandoObject();
ISimpeleSetClassProps tActsLike = CollectableMaker.ActLike<ISimpeleSetClassProps>(tNew);
var attribute = (DisplayNameAttribute)tActsLike.GetType().GetProperty(nameof(ISimpeleSetClassProps.Prop1)).GetCustomAttribute(typeof(DisplayNameAttribute), true);
Assert.NotNull(attribute);
Assert.AreEqual("testDisplayName", attribute.DisplayName);
}
}

}
14 changes: 14 additions & 0 deletions Tests/UnitTestImpromptuInterface/Savable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
using ImpromptuInterface.Build;
using Microsoft.CSharp.RuntimeBinder;
using System.Collections.Generic;
using System.ComponentModel;
using System.Dynamic;
using System.Reflection;
using Dynamitey.DynamicObjects;
using ImpromptuInterface;

Expand Down Expand Up @@ -133,6 +135,18 @@ public void NestedInterfacetest()
Assert.AreEqual(tNew.Nested.NameLevel2, tActsLike.Nested.NameLevel2);

}



[Test]
public void PropertyAttributeTest()
{
dynamic tNew = new ExpandoObject();
ISimpeleSetClassProps tActsLike = SaveableMaker.ActLike<ISimpeleSetClassProps>(tNew);
var attribute = (DisplayNameAttribute)tActsLike.GetType().GetProperty(nameof(ISimpeleSetClassProps.Prop1)).GetCustomAttribute(typeof(DisplayNameAttribute), true);
Assert.NotNull(attribute);
Assert.AreEqual("testDisplayName", attribute.DisplayName);
}
}


Expand Down

0 comments on commit 39385e4

Please sign in to comment.