public void Convert_FromBaseToDerivedClass_ShouldConvert() { TestClassBase derived = new DerivedTestClass(); var result = new TypeConverter().ConvertTo <DerivedTestClass>(derived); result.Should().BeSameAs(derived); }
public void Convert_FromDerivedToBase_ShouldConvert() { var derived = new DerivedTestClass(); var result = new TypeConverter().ConvertTo <TestClassBase>(derived); result.Should().BeSameAs(derived); }
public void SetField_SetPrivateFieldOfBaseClass_FieldHasBeenUpdated() { // Setup var derivedTestClass = new DerivedTestClass(0); // Call TypeUtils.SetField(derivedTestClass, "privateInt", 23); // Assert Assert.AreEqual(23, TypeUtils.GetField <int>(derivedTestClass, "privateInt")); }
public void SetField_SetPrivateFieldFromBaseClass_FieldHasBeenSet() { // Setup var derivedTestClass = new DerivedTestClass(1); // Call TypeUtils.SetField(derivedTestClass, "privateInt", 10); // Assert Assert.AreEqual(10, TypeUtils.GetField <int>(derivedTestClass, "privateInt")); }
public void GetProperty_ProtectedPropertyOfDerivedClass_ReturnPropertyValue() { // Setup var testClass = new DerivedTestClass(); // Call var privateIntValue = TypeUtils.GetProperty <int>(testClass, "ProtectedIntProperty"); // Assert Assert.AreEqual(102, privateIntValue); }
public void GetField_PrivateFieldOfDerivedClass_ReturnFieldValue() { // Setup var testClass = new DerivedTestClass(55); // Call var privateIntValue = TypeUtils.GetField <int>(testClass, "privateInt"); // Assert Assert.AreEqual(55, privateIntValue); }
public void GetProperty_PublicPropertyFromBaseClass_ReturnPublicPropertyValue() { // Setup var derivedTestClass = new DerivedTestClass(1) { PublicProperty = 2.0 }; // Call var publicPropertyValue = TypeUtils.GetProperty <double>(derivedTestClass, "PublicProperty"); // Assert Assert.AreEqual(derivedTestClass.PublicProperty, publicPropertyValue); }
public void GetField_PublicFieldFromBaseClass_ReturnPublicFieldValue() { // Setup var derivedTestClass = new DerivedTestClass(1) { PublicField = 2 }; // Call var publicFieldValue = TypeUtils.GetField <int>(derivedTestClass, "PublicField"); // Assert Assert.AreEqual(derivedTestClass.PublicField, publicFieldValue); }
public void Is_ParameterValueIsInterfaceOfType_DoesNothing() { ITestInterface baseTestObject = new BaseTestClass(); Argument.Is((object)baseTestObject, typeof(ITestInterface), Option<string>.None); Argument.Is((object)baseTestObject, typeof(BaseTestClass), Option<string>.None); ITestInterface derivedTestObject = new DerivedTestClass(); Argument.Is((object)derivedTestObject, typeof(ITestInterface), Option<string>.None); Argument.Is((object)derivedTestObject, typeof(BaseTestClass), Option<string>.None); }