public void PropertyContainer_Construct_ReferenceFieldConstructsNewInstanceWithDifferentSourceType()
        {
            var src = new StructContainerWithNestedStruct {
                Container = new StructContainerWithPrimitives()
            };
            var dst = new ClassContainerWithNestedClass {
                Container = null
            };

            using (var result = PropertyContainer.Construct(ref dst, ref src))
            {
                Assert.That(result.Succeeded, Is.True);
                Assert.That(dst.Container, Is.Not.Null);
            }
        }
        public void PropertyContainer_Transfer_ReferenceFieldWithDifferentSourceTypeDoesNotThrow()
        {
            var src = new StructContainerWithNestedStruct {
                Container = new StructContainerWithPrimitives()
            };
            var dst = new ClassContainerWithNestedClass {
                Container = null
            };

            Assert.DoesNotThrow(() =>
            {
                using (var result = PropertyContainer.Transfer(ref dst, ref src))
                {
                    Assert.That(result.Succeeded, Is.True);
                }
            });

            Assert.That(dst.Container, Is.Null);
        }
예제 #3
0
        public void PropertyContainer_Transfer_NestedPrimitiveFieldsWithDifferentContainerTypes()
        {
            var src = new StructContainerWithNestedStruct {
                Container = new StructContainerWithPrimitives {
                    Int32Value = 10
                }
            };
            var dst = new ClassContainerWithNestedClass {
                Container = new ClassContainerWithPrimitives()
            };

            Assert.DoesNotThrow(() =>
            {
                using (var result = PropertyContainer.Transfer(ref dst, ref src))
                {
                    Assert.That(result.Succeeded, Is.True);
                }
            });

            Assert.That(dst.Container.Int32Value, Is.EqualTo(10));
        }