예제 #1
0
        public void ShouldNotInjectValuesIfChildEnumerableIsNull()
        {
            ValueInjector.UseValueObtainer(_remoteValueObtainer);
            var testData = new EnumerableChildPropertyTestData
            {
                TestDatas = null
            };

            ValueInjector.InjectValues(testData);

            Assert.Null(testData.TestDatas);
        }
예제 #2
0
        public void ShouldInjectValuesInChildEnumerable()
        {
            ValueInjector.UseValueObtainer(_remoteValueObtainer);
            var testData = new EnumerableChildPropertyTestData
            {
                TestDatas = new List <TestData>
                {
                    new TestData {
                        ValueKey = 1
                    },
                    new TestData {
                        ValueKey = 2
                    }
                }
            };

            ValueInjector.InjectValues(testData);

            foreach (var element in testData.TestDatas)
            {
                Assert.NotNull(element.Value);
                Assert.Equal(element.ValueKey.ToString(), element.Value);
            }
        }