public void GivenInitClient() { _factory = new ApiWebApplicationFactory(); _client = _factory.CreateClient(); _currencyAutomatedTestHelper = new CurrencyAutomatedTestHelper(_client); _currencyAutomatedTestHelper.GenerateTokenString(); }
public void Setup() { _factory = new ApiWebApplicationFactory(); var http = _factory.CreateClient(); _apiClient = new ApiTestClient(http); }
public void GivenARequestToTheController() { _factory = new ApiWebApplicationFactory(); _httpClient = _factory.CreateClient(); _httpClient .DefaultRequestHeaders .Accept .Add(new MediaTypeWithQualityHeaderValue("application/json")); }
protected ApiTestBase(ApiWebApplicationFactory <Startup> factory) { Factory = factory; Client = factory.CreateClient(new WebApplicationFactoryClientOptions { AllowAutoRedirect = false }); Client.BaseAddress = new Uri("https://localhost:44319"); Client.DefaultRequestHeaders .Accept .Add(new MediaTypeWithQualityHeaderValue("application/json")); //ACCEPT header }
public void Setup() { _factory = new ApiWebApplicationFactory(); _client = _factory.CreateClient(); var getResponse = _client.GetAsync("/api/pdf?order=NameDescending").Result; var stringResponse = getResponse.Content.ReadAsStringAsync().Result; pdfs = JsonConvert.DeserializeObject <List <Pdf> >(stringResponse); if (!pdfs.Any()) { var fileName = "pdf.pdf"; var io = File.Open(fileName, FileMode.Open); byte[] Bytes = new byte[io.Length + 1]; io.Read(Bytes, 0, Bytes.Length); using (var content = new MultipartFormDataContent()) { var fileContent = new ByteArrayContent(Bytes); fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { FileName = "1" + fileName }; content.Add(fileContent); var response1 = _client.PostAsync("/api/pdf", content).Result; fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { FileName = "2" + fileName }; var response2 = _client.PostAsync("/api/pdf", content).Result; var allResponse = _client.GetAsync("/api/pdf?order=NameDescending").Result; var allStringResponse = allResponse.Content.ReadAsStringAsync().Result; pdfs = JsonConvert.DeserializeObject <List <Pdf> >(allStringResponse); trueGuid = pdfs.First().Id; } } }
public void Setup() { _factory = new ApiWebApplicationFactory(); _client = _factory.CreateClient(); pdfs = DataGenerator.GetPdfs(); options = new DbContextOptionsBuilder <PdfContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) // Needs to be torn down fully for each test .EnableSensitiveDataLogging(true) .Options; mockService = new Mock <IPdfService>(); mockLogger = new Mock <ILogger <PdfController> >(); var list = new List <Pdf>(); trueGuid = new Guid("7e7ceb51-37e0-4ebb-897c-ce801b0e37fe"); falseGuid = new Guid("12345678901234567890123456789011"); validPdf = new Pdf() { Id = trueGuid }; invalidPdf = new Pdf() { Id = falseGuid }; mockService.Setup(repo => repo.GetPdfs(FileOrder.NameAscending)).ReturnsAsync(list); mockService.Setup(repo => repo.GetPdf(trueGuid)).ReturnsAsync(validPdf); mockService.Setup(repo => repo.GetPdf(falseGuid)).ReturnsAsync((Pdf)null); mockService.Setup(repo => repo.InsertPdf(validPdf)).Returns(Task.FromResult(1)); mockService.Setup(repo => repo.InsertPdf(invalidPdf)).Returns(Task.FromResult(0)); mockService.Setup(repo => repo.DeletePdf(trueGuid)).Throws(new Exception($"Pdf '{trueGuid}' is active, can't be deleted")); mockService.Setup(repo => repo.DeletePdf(falseGuid)).Returns(Task.FromResult(invalidPdf)); controller = new PdfController(mockLogger.Object, mockService.Object); }
public CardCostControllerTests(ApiWebApplicationFactory fixture) : base(fixture) { _httpClient = _factory.WithWebHostBuilder( builder => { builder.ConfigureServices( services => { var sp = services.BuildServiceProvider(); using var scope = sp.CreateScope(); var scopedServices = scope.ServiceProvider; var db = scopedServices.GetRequiredService <CardCostContext>(); db.Database.EnsureCreated(); ResetDb(db); }); }) .CreateClient(new WebApplicationFactoryClientOptions()); }
public GetRequest(ApiWebApplicationFactory factory) => _factory = factory;
public void InitiateServer() { this.factory = new ApiWebApplicationFactory(); this.client = this.factory.CreateClient(); }
public WeatherForecastControllerTests(ApiWebApplicationFactory fixture) : base(fixture) { }
public FornecedoresControllerTests(ApiWebApplicationFactory <Startup> factory) : base(factory) { }
public FSTeszt_02_Set(ApiWebApplicationFactory fixture) : base(fixture) { }
public IntegrationTestsFixture(ApiWebApplicationFactory <Startup> factory) { Factory = factory; Client = CreateClient(); ConfigureReesedDb(); }
public IntegrationTestWithDatabase() { dbFixture = new DbFixture(); factory = new ApiWebApplicationFactory(ConfigureWebHostBuilder()); httpClient = factory.CreateClient(); }
public static void InitOnce(TestContext context) { Factory = new ApiWebApplicationFactory(); Client = Factory.CreateClient(); Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Test"); }
public EmployeeController_Tests(ApiWebApplicationFactory fixture) : base(fixture) { }
public IntegrationTest() { factory = new ApiWebApplicationFactory(); httpClient = factory.CreateClient(); }
public DeleteEndpoint(ApiWebApplicationFactory fixture) : base(fixture) { }
public void GivenARequestToTheController() { _factory = new ApiWebApplicationFactory(); _client = _factory.CreateClient(); _client.BaseAddress = new Uri("https://localhost:44349/"); }
public ApiIntegrationTest(ApiWebApplicationFactory <Startup> factory) { Client = factory.CreateClient(); }
public ProductControllerTests(ApiWebApplicationFactory <Startup> factory) => _factory = factory;
public GetAllEndpoint(ApiWebApplicationFactory fixture) : base(fixture) { }
public HospitalTest(ApiWebApplicationFactory <Startup> factory) : base(factory) { }
public LoggingControllerTests(ApiWebApplicationFactory fixture) : base(fixture) { }
public HelloControllerTests(ApiWebApplicationFactory fixture) : base(fixture) { }
public BookControllerTests(ApiWebApplicationFactory factory) : base(factory) { }
public CreditCardsControllerTest(ApiWebApplicationFactory fixture) : base(fixture) { }
public IngredientControllerTests(ApiWebApplicationFactory fixture) : base(fixture) { }
public DeleteRequest(ApiWebApplicationFactory factory) => _factory = factory;
public AuthControllerTests(ApiWebApplicationFactory <Startup> factory) : base(factory) { }