Example #1
0
        public async Task Application_shows_no_exception_details_in_production_mode()
        {
            // Arrange
            using var factory = new CustomWebApplicationFactory <Startup>(Environments.Production);
            using var client  = factory.CreateClient();
            WebHostTestBase.AuthenticateWith(client, "not-a-guid");

            // Assert
            await Assert.ThrowsExceptionAsync <FormatException>(() => client.GetAsync("/mycharacter"));
        }
Example #2
0
        public async Task Application_shows_exception_details_in_development_mode()
        {
            // Arrange
            using var factory = new CustomWebApplicationFactory <Startup>(Environments.Development);
            using var client  = factory.CreateClient();
            WebHostTestBase.AuthenticateWith(client, "not-a-guid");

            // Act
            var response = await client.GetAsync("/mycharacter");

            var content = await response.Content.ReadAsStringAsync();

            // Assert
            Assert.IsTrue(content.Contains("System.FormatException"));
        }
Example #3
0
 public static Task ClearRepositoryAsync(this WebHostTestBase test, string entityName)
 {
     return(test.Client.DeleteAsync(test.BaseAddress + "/" + entityName));
 }