public static void Test_isInterfaceCollectionType_Returns_False_On_UnExpected_Types(Type t) { //arrange bool result = false; //act result = SerializedTypeManipulator.isInterfaceCollectionType(t); //assert Assert.IsFalse(result, "UnExpected Type: {0} was considered an interface collection", t?.FullName); }
public static void Test_isInterfaceCollectionType_Returns_True_On_Expected_Types(Type t) { //arrange bool result = false; //act result = SerializedTypeManipulator.isInterfaceCollectionType(t); //assert Assert.IsTrue(result, "Expected Type: {0} to ", nameof(SerializedTypeManipulator.isInterfaceCollectionType)); }
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)))); }
public static void Test_GetCollectionFields_Returns_Expected_FieldInfo() { //arrange Type typeToParse = typeof(TestClass); //act IEnumerable <FieldInfo> fieldInfos = SerializedTypeManipulator.GetCollectionFields(typeToParse); //assert Assert.IsNotEmpty(fieldInfos, "Expected to find collection types but failed."); Assert.IsTrue(fieldInfos.Where(x => x.Name == nameof(TestClass.Collection1)).Count() != 0); Assert.IsTrue(fieldInfos.Where(x => x.Name == nameof(TestClass.Collection2)).Count() != 0); Assert.IsTrue(fieldInfos.Where(x => x.Name == nameof(TestClass.Collection3)).Count() != 0); Assert.IsTrue(fieldInfos.Where(x => x.Name == nameof(TestClass.Collection4)).Count() != 0); //Should find these Assert.IsTrue(fieldInfos.Where(x => x.Name == "blahblahshouldnthave").Count() == 0, "Found an unexpected field."); Assert.IsTrue(fieldInfos.Where(x => x.Name == nameof(TestClass.Collection5)).Count() == 0, "Found an unexpected field."); Assert.IsTrue(fieldInfos.Where(x => x.Name == nameof(TestClass.Collection6)).Count() == 0, "Found an unexpected field."); }
public static void Test_GetCollectionFields_Throws_When_Null() { //assert Assert.Throws <ArgumentNullException>(() => SerializedTypeManipulator.GetCollectionFields(null)); }