public void Test_that_setter_is_created_well_and_works() { // Arrange var factory = new PropertySettersFactory(); var valueTypeValue = 123; var referenceTypeValue = new TestComplexType(); var entity = new TestEntity { NullProperty = "not null" }; // Act var valueTypePropertySetter = factory.Create(TestEntityType.GetProperty(nameof(TestEntity.ValueTypeProperty))); var referenceTypePropertySetter = factory.Create(TestEntityType.GetProperty(nameof(TestEntity.ReferenceTypeProperty))); var nullPropertySetter = factory.Create(TestEntityType.GetProperty(nameof(TestEntity.NullProperty))); valueTypePropertySetter.Invoke(entity, valueTypeValue); referenceTypePropertySetter.Invoke(entity, referenceTypeValue); nullPropertySetter.Invoke(entity, null); // Assert Assert.AreEqual(valueTypeValue, entity.ValueTypeProperty); Assert.AreEqual(referenceTypeValue, entity.ReferenceTypeProperty); Assert.IsNull(entity.NullProperty); }
public void ComplexType() { var obj = new TestComplexType(); ModelSanitizer.Sanitize(obj); Assert.That(obj, Is.Not.Null); Assert.That(obj.String, Is.EqualTo("sanitize me")); Assert.That(obj.IgnoreMe, Is.EqualTo(" ignored ")); Assert.That(obj.StringSet, Is.EqualTo(new SortedSet <string> { "hello" })); Assert.That(obj.Nested, Has.Exactly(2).Items); Assert.That(obj.Nested[0].Name, Is.EqualTo("one")); Assert.That(obj.Nested[0].Dict, Is.Null); Assert.That(obj.Nested[1].Name, Is.EqualTo("two")); Assert.That(obj.Nested[1].Dict, Has.Exactly(1).Items); Assert.That(obj.Nested[1].Dict["three"].Name, Is.EqualTo("three")); }
public TestComplexTypeWithCompressedComplex(TestComplexType compressedComplex) { CompressedComplex = compressedComplex; }