public void Test_that_inherited_properties_can_be_get()
        {
            // Arrange
            var factory = new PropertyGettersFactory();
            var entity  = new DerivedTestEntity
            {
                ValueTypeProperty       = 123,
                PropertyInDerivedEntity = 555,
                VirtualProperty         = "333"
            };

            // Act
            var valueTypePropertyGetter = factory.Create(DerivedTestEntityType.GetProperty(nameof(DerivedTestEntity.ValueTypeProperty)));
            var derivedPropertyGetter   = factory.Create(DerivedTestEntityType.GetProperty(nameof(DerivedTestEntity.PropertyInDerivedEntity)));
            var virtualPropertyGetter   = factory.Create(DerivedTestEntityType.GetProperty(nameof(DerivedTestEntity.VirtualProperty)));

            var valueTypeValue = valueTypePropertyGetter.Invoke(entity);
            var derivedValue   = derivedPropertyGetter.Invoke(entity);
            var virtualValue   = virtualPropertyGetter.Invoke(entity);

            // Assert
            Assert.AreEqual(entity.ValueTypeProperty, valueTypeValue);
            Assert.AreEqual(entity.PropertyInDerivedEntity, derivedValue);
            Assert.AreEqual(entity.VirtualProperty, virtualValue);
        }
Exemplo n.º 2
0
        public void DeformatTest_DerivedEntityWithoutProperty()
        {
            string xml = @"<?xml version=""1.0"" encoding=""utf-8""?><DerivedTestEntity xmlns=""tpum.example.com"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance""><Foo>BarBar</Foo><Id>1</Id></DerivedTestEntity>";
            XmlFormatter <DerivedTestEntity> sut_derived = new();
            DerivedTestEntity result = sut_derived.Deformat(xml);

            Assert.NotNull(result);
            Assert.IsType <DerivedTestEntity>(result);
            Assert.Equal("BarBar", result.Foo);
            Assert.Equal(1, result.Id);
            Assert.Equal(0, result.Count);
        }
Exemplo n.º 3
0
        public void DeFormatTest_DerivedEntityWithoutProperty()
        {
            string json = "{\"Id\": 0, \"Foo\": \"Bar\"}";
            JsonFormatter <DerivedTestEntity> sut_derived = new();
            DerivedTestEntity result = sut_derived.Deformat(json);

            Assert.NotNull(result);
            Assert.IsType <DerivedTestEntity>(result);
            Assert.Equal("Bar", result.Foo);
            Assert.Equal(0, result.Id);
            Assert.Equal(0, result.Count);
        }
Exemplo n.º 4
0
        public void DeformatTest_DerivedEntityWithoutProperty()
        {
            string yaml = @$ "!{DerivedTag}
Id: 1
Foo: BarBar
";
            YamlFormatter <DerivedTestEntity> sut_derived = new();
            DerivedTestEntity result = sut_derived.Deformat(yaml);

            Assert.NotNull(result);
            Assert.IsType <DerivedTestEntity>(result);
            Assert.Equal("BarBar", result.Foo);
            Assert.Equal(1, result.Id);
            Assert.Equal(0, result.Count);
        }