public void GetRoutePrefix_WithNullPrefix_ThrowsInvalidOperationException() { // Arrange var httpControllerDescriptor = new NullRoutePrefixControllerDescripter(); var typeMock = new Mock <Type>(); typeMock.SetupGet(t => t.FullName).Returns("Namespace.TypeFullName"); httpControllerDescriptor.ControllerType = typeMock.Object; var provider = new AccessibleDirectRouteProvider(); // Act & Assert Assert.Throws <InvalidOperationException>( () => provider.GetRoutePrefix(httpControllerDescriptor), "The property 'prefix' from route prefix attribute on controller of type 'Namespace.TypeFullName' cannot be null."); }
public void GetRoutePrefix_WithMultiRoutePrefix_ThrowsInvalidOperationException() { // Arrange var httpControllerDescriptor = new MultiRoutePrefixControllerDescripter(); var typeMock = new Mock <Type>(); typeMock.SetupGet(t => t.FullName).Returns("Namespace.TypeFullName"); httpControllerDescriptor.ControllerType = typeMock.Object; var provider = new AccessibleDirectRouteProvider(); // Act & Assert Assert.Throws <InvalidOperationException>( () => provider.GetRoutePrefix(httpControllerDescriptor), "Only one route prefix attribute is supported. Remove extra attributes from the controller of type 'Namespace.TypeFullName'."); }