public async Task NoBookingsTableOnPage_WhenUserHasNoBookings() { var client = _factory.CreateClientWithMemberAndDbSetup(db => DatabaseHelper.ResetDbForTests(db)); var response = await client.GetAsync(""); response.AssertOk(); using var content = await HtmlHelpers.GetDocumentAsync(response); var table = content.QuerySelector("table"); Assert.Null(table); var paragraphs = content.QuerySelectorAll("#no-bookings"); Assert.Single(paragraphs); }
public async Task Post_ShouldWork() { var client = _factory.CreateClientWithMemberAndDbSetup(db => { DatabaseHelper.ResetDbForTests(db); }); var payload = new ProductPayload { Name = "OkOk" }; var result = await client.PostAsJsonAsync("http://localhost/api/test", payload); result.StatusCode.Should().Be(HttpStatusCode.OK); var context = _factory.Services.GetService <TestsDbContext>(); var product = context.Products.FirstOrDefault(x => x.Name == "OkOk"); product.Should().NotBeNull(); }
public async Task Get_WhenHasProduct() { var guid = Guid.NewGuid(); var client = _factory.CreateClientWithMemberAndDbSetup(db => { DatabaseHelper.ResetDbForTests(db); db.Products.Add(new Product { Id = guid, Name = "Bla" }); db.SaveChanges(); }); var response = await client.GetAsync($"?id= {guid}"); response.StatusCode.Should().Be(HttpStatusCode.OK); }