// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. #if ASPNET50 using System; using System.Net.Http; using System.Threading.Tasks; using AutofacWebSite; using Microsoft.AspNet.Builder; using Microsoft.AspNet.TestHost; using Xunit; namespace Microsoft.AspNet.Mvc.FunctionalTests { public class DependencyResolverTests { [Theory] [InlineData("http://localhost/di", "

Builder Output: Hello from builder.

")] [InlineData("http://localhost/basic", "

Hello From Basic View

")] public async Task AutofacDIContainerCanUseMvc(string url, string expectedResponseBody) { // Arrange var provider = TestHelper.CreateServices("AutofacWebSite"); Action app = new Startup().Configure; // Act & Assert (does not throw) // This essentially calls into the Startup.Configuration method var server = TestServer.Create(provider, app); // Make a request to start resolving DI pieces var response = await server.CreateClient().GetAsync(url); var actualResponseBody = await response.Content.ReadAsStringAsync(); Assert.Equal(expectedResponseBody, actualResponseBody); } } } #endif