示例#1
0
        public async Task NoRequestContentType_Throws_IfMultipleActionsWithConstraints()
        {
            // Arrange
            var server  = TestHelper.CreateServer(_app, SiteName, _configureServices);
            var client  = server.CreateClient();
            var request = new HttpRequestMessage(
                HttpMethod.Post,
                "http://localhost/ConsumesAttribute_AmbiguousActions/CreateProduct");

            // Act
            var response = await client.SendAsync(request);

            var exception = response.GetServerException();

            // Assert
            Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
            Assert.Equal(typeof(AmbiguousActionException).FullName, exception.ExceptionType);
            // Mono issue - https://github.com/aspnet/External/issues/19
            Assert.Equal(
                "Multiple actions matched. The following actions matched route data and had all constraints " +
                "satisfied:" + PlatformNormalizer.GetNewLinesAsUnderscores(2) + "ActionConstraintsWebSite." +
                "ConsumesAttribute_NoFallBackActionController." +
                "CreateProduct" + PlatformNormalizer.GetNewLinesAsUnderscores(1) + "ActionConstraintsWebSite." +
                "ConsumesAttribute_NoFallBackActionController.CreateProduct",
                exception.ExceptionMessage);
        }
示例#2
0
        public async Task RoutingToANonExistantArea_WithoutExistConstraint_RoutesToIncorrectAction()
        {
            // Arrange & Act
            var response = await Client.GetAsync("http://localhost/area-withoutexists/Users");

            // Assert
            var exception = response.GetServerException();

            // Mono issue - https://github.com/aspnet/External/issues/19
            Assert.Equal(
                "The view 'Index' was not found." +
                " The following locations were searched:" + PlatformNormalizer.GetNewLinesAsUnderscores(1) +
                "/Areas/Users/Views/Home/Index.cshtml" + PlatformNormalizer.GetNewLinesAsUnderscores(1) +
                "/Areas/Users/Views/Shared/Index.cshtml" + PlatformNormalizer.GetNewLinesAsUnderscores(1) +
                "/Views/Shared/Index.cshtml.",
                exception.ExceptionMessage);
        }