public void GetControllerTypes_FindsTypes() { // Arrange DefaultHttpControllerTypeResolver resolver = new DefaultHttpControllerTypeResolver(); Mock <IAssembliesResolver> mockAssemblyResolver = new Mock <IAssembliesResolver>(); mockAssemblyResolver.Setup(a => a.GetAssemblies()).Returns(new List <Assembly> { null, new MockExportedTypesAssembly(ThrowException.ReflectionTypeLoadException, typeof(InvalidControllerStruct), typeof(ValidController), typeof(ControllerWrapper.InvalidNestedController), typeof(InvalidControllerWithInconsistentName)), new MockExportedTypesAssembly(ThrowException.Exception, typeof(InvalidControllerAbstract), typeof(InvalidControllerWithNoBaseType)), new MockExportedTypesAssembly(ThrowException.None, typeof(VALIDController), typeof(VALIDCONTROLLER), typeof(InvalidControllerStruct)), }); // Act ICollection <Type> actualControllerTypes = resolver.GetControllerTypes(mockAssemblyResolver.Object); // Assert Assert.Equal(3, actualControllerTypes.Count); Assert.True(actualControllerTypes.Contains(typeof(ValidController))); Assert.True(actualControllerTypes.Contains(typeof(VALIDController))); Assert.True(actualControllerTypes.Contains(typeof(VALIDCONTROLLER))); }
public void GetControllerTypes_ThrowsOnNull() { DefaultHttpControllerTypeResolver resolver = new DefaultHttpControllerTypeResolver(); Assert.ThrowsArgumentNull( () => resolver.GetControllerTypes(null), "assembliesResolver" ); }
public void GetControllerTypes_FindsTypes() { // Arrange DefaultHttpControllerTypeResolver resolver = new DefaultHttpControllerTypeResolver(); Mock <IAssembliesResolver> mockAssemblyResolver = new Mock <IAssembliesResolver>(); mockAssemblyResolver.Setup(a => a.GetAssemblies()).Returns(new List <Assembly> { null, new MockExportedTypesAssembly(ThrowException.ReflectionTypeLoadException, typeof(ControllerWrapper.ValidNestedController), typeof(ControllerWrapper.ValidInheritedNestedController), typeof(ControllerWrapper.ControllerNestedWrapper.ValidNestedNestedController), typeof(InheritedControllerHidingWrapper.ValidNestedController)), new MockExportedTypesAssembly(ThrowException.Exception, typeof(ControllerWrapper.InvalidAbstractNestedController), ControllerWrapper.TypeOfInvalidProtectedNestedController(), // NOTE: Unable to get through typeof(ControllerWrapper.InvalidProtectedNestedController), ControllerWrapper.TypeOfInvalidPrivateNestedController(), // NOTE: Unable to get through typeof(ControllerWrapper.InvalidPrivateNestedController), typeof(ControllerWrapper.InvalidInternalNestedController)), new MockExportedTypesAssembly(ThrowException.None, typeof(ValidSealedController), typeof(ValidPartialController), typeof(ValidInheritedController), typeof(ValidController), typeof(VALIDController), typeof(VALIDCONTROLLER), typeof(InvalidAbstractController), typeof(InvalidControllerStruct), typeof(InvalidControllerWithInconsistentName), typeof(InvalidControllerWithNoBaseType)) }); // Act ICollection <Type> actualControllerTypes = resolver.GetControllerTypes(mockAssemblyResolver.Object); // Assert Assert.Equal(10, actualControllerTypes.Count); Assert.True(actualControllerTypes.Contains(typeof(ControllerWrapper.ValidNestedController))); Assert.True(actualControllerTypes.Contains(typeof(ControllerWrapper.ValidInheritedNestedController))); Assert.True(actualControllerTypes.Contains(typeof(ControllerWrapper.ControllerNestedWrapper.ValidNestedNestedController))); Assert.True(actualControllerTypes.Contains(typeof(ValidSealedController))); Assert.True(actualControllerTypes.Contains(typeof(ValidPartialController))); Assert.True(actualControllerTypes.Contains(typeof(ValidInheritedController))); Assert.True(actualControllerTypes.Contains(typeof(ValidController))); Assert.True(actualControllerTypes.Contains(typeof(VALIDController))); Assert.True(actualControllerTypes.Contains(typeof(VALIDCONTROLLER))); Assert.True(actualControllerTypes.Contains(typeof(InheritedControllerHidingWrapper.ValidNestedController))); }
public void GetControllerTypes_ThrowsOnNull() { DefaultHttpControllerTypeResolver resolver = new DefaultHttpControllerTypeResolver(); Assert.ThrowsArgumentNull(() => resolver.GetControllerTypes(null), "assembliesResolver"); }
public void GetControllerTypes_FindsTypes() { // Arrange DefaultHttpControllerTypeResolver resolver = new DefaultHttpControllerTypeResolver(); Mock<IAssembliesResolver> mockAssemblyResolver = new Mock<IAssembliesResolver>(); mockAssemblyResolver.Setup(a => a.GetAssemblies()).Returns(new List<Assembly> { null, new MockExportedTypesAssembly(ThrowException.ReflectionTypeLoadException, typeof(ControllerWrapper.ValidNestedController), typeof(ControllerWrapper.ValidInheritedNestedController), typeof(ControllerWrapper.ControllerNestedWrapper.ValidNestedNestedController), typeof(InheritedControllerHidingWrapper.ValidNestedController)), new MockExportedTypesAssembly(ThrowException.Exception, typeof(ControllerWrapper.InvalidAbstractNestedController), ControllerWrapper.TypeOfInvalidProtectedNestedController(), // NOTE: Unable to get through typeof(ControllerWrapper.InvalidProtectedNestedController), ControllerWrapper.TypeOfInvalidPrivateNestedController(), // NOTE: Unable to get through typeof(ControllerWrapper.InvalidPrivateNestedController), typeof(ControllerWrapper.InvalidInternalNestedController)), new MockExportedTypesAssembly(ThrowException.None, typeof(ValidSealedController), typeof(ValidPartialController), typeof(ValidInheritedController), typeof(ValidController), typeof(VALIDController), typeof(VALIDCONTROLLER), typeof(InvalidAbstractController), typeof(InvalidControllerStruct), typeof(InvalidControllerWithInconsistentName), typeof(InvalidControllerWithNoBaseType)) }); // Act ICollection<Type> actualControllerTypes = resolver.GetControllerTypes(mockAssemblyResolver.Object); // Assert Assert.Equal(10, actualControllerTypes.Count); Assert.True(actualControllerTypes.Contains(typeof(ControllerWrapper.ValidNestedController))); Assert.True(actualControllerTypes.Contains(typeof(ControllerWrapper.ValidInheritedNestedController))); Assert.True(actualControllerTypes.Contains(typeof(ControllerWrapper.ControllerNestedWrapper.ValidNestedNestedController))); Assert.True(actualControllerTypes.Contains(typeof(ValidSealedController))); Assert.True(actualControllerTypes.Contains(typeof(ValidPartialController))); Assert.True(actualControllerTypes.Contains(typeof(ValidInheritedController))); Assert.True(actualControllerTypes.Contains(typeof(ValidController))); Assert.True(actualControllerTypes.Contains(typeof(VALIDController))); Assert.True(actualControllerTypes.Contains(typeof(VALIDCONTROLLER))); Assert.True(actualControllerTypes.Contains(typeof(InheritedControllerHidingWrapper.ValidNestedController))); }
public void GetControllerTypes_FindsTypes() { // Arrange DefaultHttpControllerTypeResolver resolver = new DefaultHttpControllerTypeResolver(); Mock<IAssembliesResolver> mockAssemblyResolver = new Mock<IAssembliesResolver>(); mockAssemblyResolver.Setup(a => a.GetAssemblies()).Returns(new List<Assembly> { null, new MockExportedTypesAssembly(ThrowException.ReflectionTypeLoadException, typeof(InvalidControllerStruct), typeof(ValidController), typeof(ControllerWrapper.InvalidNestedController), typeof(InvalidControllerWithInconsistentName)), new MockExportedTypesAssembly(ThrowException.Exception, typeof(InvalidControllerAbstract), typeof(InvalidControllerWithNoBaseType)), new MockExportedTypesAssembly(ThrowException.None, typeof(VALIDController), typeof(VALIDCONTROLLER), typeof(InvalidControllerStruct)), }); // Act ICollection<Type> actualControllerTypes = resolver.GetControllerTypes(mockAssemblyResolver.Object); // Assert Assert.Equal(3, actualControllerTypes.Count); Assert.True(actualControllerTypes.Contains(typeof(ValidController))); Assert.True(actualControllerTypes.Contains(typeof(VALIDController))); Assert.True(actualControllerTypes.Contains(typeof(VALIDCONTROLLER))); }