public void TestGenerateIGetterForStudentName() { // Arrange IGetter getter = dynamicIGetterInstanceCreator.CreateIGetterFor(typeof(Student), "name"); // // Asserts Assert.NotNull(getter); Assert.AreEqual("name", getter.GetName()); Assert.AreEqual(s1.name, (string)getter.GetValue(s1)); }
public void TestGenerateIGetterForStudentNumber() { // Arrange IGetter getter = dynamicIGetterInstanceCreator.CreateIGetterForField(typeof(Student), "nr"); // // Asserts Assert.NotNull(getter); Assert.AreEqual("nr", getter.GetName()); Assert.AreEqual(s1.nr, (int)getter.GetValue(s1)); }
public void TestDynamicGetterForStudentNr() { // // Arrange // DynamicGetterBuider builder = new DynamicGetterBuider(typeof(Student)); Type getterType = builder.GenerateGetterFor(typeof(Student).GetField("nr")); IGetter getter = (IGetter)Activator.CreateInstance(getterType); // builder.SaveModule(); // // Act // Student st = new Student(762354, "Ze Manel", 13, "zemanel"); Assert.Equal("nr", getter.GetName()); Assert.Equal(762354, getter.GetValue(st)); }
public string GetName() { return(getter.GetName()); }