Ejemplo n.º 1
0
        public IntegrationTestFixture()
        {
            TestServer testServer = new TestServer(Program.CreateWebHostBuilder(new string[] { }).UseEnvironment("Development"));
            var        httpClient = testServer.CreateClient();

            FooServiceClient = new FooServiceClient(httpClient);
        }
Ejemplo n.º 2
0
        public DeploymentTestsFixture()
        {
            string serviceUrl = Environment.GetEnvironmentVariable("StudentsServiceDeploymentTestsUrl");

            if (string.IsNullOrWhiteSpace(serviceUrl))
            {
                throw new Exception("Could not find StudentsServiceUrl environment variable");
            }

            FooServiceClient = new FooServiceClient(new System.Net.Http.HttpClient
            {
                BaseAddress = new Uri(serviceUrl)
            });
        }
Ejemplo n.º 3
0
        public async Task AddStudentReturnsCorrectStatusCodeOnStorageErrors(HttpStatusCode statusCode)
        {
            var studentsStoreMock = new Mock <IStudentStore>();

            studentsStoreMock.Setup(store => store.AddStudent(_courseName, _testStudent))
            .ThrowsAsync(new StorageErrorException("Test Exception", (int)statusCode));

            TestServer testServer = new TestServer(
                Program.CreateWebHostBuilder(new string[] { })
                .ConfigureTestServices(services =>
            {
                services.AddSingleton(studentsStoreMock.Object);
            }).UseEnvironment("Development"));
            var httpClient       = testServer.CreateClient();
            var fooServiceClient = new FooServiceClient(httpClient);

            FooServiceException e = await Assert.ThrowsAsync <FooServiceException>(() => fooServiceClient.AddStudent(_courseName, _testStudent));

            Assert.Equal(statusCode, e.StatusCode);
        }