Пример #1
0
        public static void Test_FindUncontainedFields_Returns_Uncontained_Fields()
        {
            //arrange
            SingleContainerFieldMatcher   matcher    = new SingleContainerFieldMatcher(typeof(TestClass));
            List <ISerializableContainer> containers = new List <ISerializableContainer>();

            //act
            IEnumerable <FieldInfo> infos = matcher.FindUnContainedFields(containers);

            //assert
            Assert.NotNull(infos);
            Assert.IsTrue(infos.Count() > 0);
            Assert.IsTrue(infos.Where(i => i.Type() == typeof(IDisposable)).Count() != 0);
            Assert.IsTrue(infos.Where(i => SerializedTypeManipulator.isInterfaceCollectionType(i.Type())).Count() == 0);
        }
        public static void Test_FindUncontainedFields_Returns_Uncontained_Fields()
        {
            //arrange
            SingleContainerFieldMatcher matcher = new SingleContainerFieldMatcher(typeof(TestClass));
            List<ISerializableContainer> containers = new List<ISerializableContainer>();

            //act
            IEnumerable<FieldInfo> infos = matcher.FindUnContainedFields(containers);

            //assert
            Assert.NotNull(infos);
            Assert.IsTrue(infos.Count() > 0);
            Assert.IsTrue(infos.Where(i => i.Type() == typeof(IDisposable)).Count() != 0);
            Assert.IsTrue(infos.Where(i => SerializedTypeManipulator.isInterfaceCollectionType(i.Type())).Count() == 0);
        }
        public static void Test_FindUncontainedFields_Returns_Uncontained_Fields()
        {
            //arrange
            SingleContainerFieldMatcher   matcher    = new SingleContainerFieldMatcher(typeof(TestClass));
            List <ISerializableContainer> containers = new List <ISerializableContainer>();

            //act
            IEnumerable <FieldInfo> infos = matcher.FindUnContainedFields(containers);

            //assert
            Assert.NotNull(infos);
            Assert.IsTrue(infos.Any());
            Assert.IsTrue(infos.Any(i => i.Type() == typeof(IDisposable)));
            Assert.IsTrue(!infos.Any(i => SerializedTypeManipulator.isInterfaceCollectionType(i.Type())));

            //Check and make sure the protected field is there
            Assert.IsTrue(infos.Any(i => i.Name == "TestSingle"));
            Assert.IsTrue(infos.Any(i => i.Name.Contains(nameof(TestClass.TestSingleProp))));
        }