public Task GetAllTablesReturnsProperHypermediaLinksForTablesWithoutWaiters(AddTable[] addTablesCommands, Fixture fixture) => _apiHelper.InTheContextOfAnAuthenticatedUser( async httpClient => { // Arrange await _fixture.SendManyAsync(addTablesCommands); // Act var response = await httpClient .GetAsync(TableRoute()); // Assert var expectedContainerLinks = new List <string> { LinkNames.Self, LinkNames.Table.Add }; var resource = await response.ShouldBeAResource <TableContainerResource>(expectedContainerLinks); var expectedTableLinks = new List <string> { LinkNames.Table.GetAll }; resource.Items.ShouldAllBe(tableResource => tableResource.Links.All(link => expectedTableLinks.Contains(link.Key))); }, fixture);
public async Task BetForAwayTeamShouldReturnProperHypermediaLinks( Fixture fixture, Team homeTeam, Team awayTeam) => await _apiHelper.InTheContextOfAnAuthenticatedUser( async client => { // Arrange var currentMatch = await _matchTestHelper .RegistrateMatchAsync(fixture, homeTeam, awayTeam); var httpRequest = new MatchAwayBetInput { MatchId = currentMatch.Id, AwayBet = fixture.Create <decimal>(), }; // Act var response = await client.PostAsJsonAsync("/bets/away-team", httpRequest); // Assert var expectedLinks = new List <string> { LinkNames.Self }; await response.ShouldBeAResource <UserMatchBetResource>(expectedLinks); }, fixture);
public Task LogoutShouldReturnProperHypermediaLinks(Fixture fixture) => _apiHelper.InTheContextOfAnAuthenticatedUser( async client => { // Act var response = await client.DeleteAsync(AuthRoute("logout")); // Assert var expectedLinks = new List <string> { LinkNames.Auth.Login, LinkNames.Auth.Register }; await response.ShouldBeAResource <LogoutResource>(expectedLinks); }, fixture);
public Task GetCurrentUserShouldReturnProperHypermediaLinks(Fixture fixture) => _apiHelper.InTheContextOfAnAuthenticatedUser( async client => { // Act var response = await client.GetAsync(AuthRoute()); // Assert // We don't expect any operations to be available on the user // when logged in as normal var expectedLinks = new List <string> { }; await response.ShouldBeAResource <UserResource>(expectedLinks); }, fixture);
public Task GetOrderShouldReturnProperHypermediaLinksWhenLoggedInAsANormalUser(Guid orderId, MenuItem[] menuItems, Fixture fixture) => _apiHelper.InTheContextOfAnAuthenticatedUser( async client => { // Arrange await _orderHelper.OrderToGo(orderId, menuItems); // Act var response = await client .GetAsync(OrderRoute(orderId.ToString())); // Assert var expectedLinks = new List <string> { LinkNames.Self }; await response.ShouldBeAResource <ToGoOrderResource>(expectedLinks); }, fixture);
public Task RequestingTheApiRootShouldReturnProperHypermediaLinksWhenLoggedIn(Fixture fixture) => _apiHelper.InTheContextOfAnAuthenticatedUser( async httpClient => { // Act var response = await httpClient .GetAsync(httpClient.BaseAddress); // Assert var expectedLinks = new List <string> { LinkNames.Auth.Logout }; await response.ShouldBeAResource <ApiRootResource>(expectedLinks); }, fixture);
public Task GetMenuItemsShouldReturnProperHypermediaLinksWhenLoggedInAsANormalUser(AddMenuItems command, Fixture fixture) => _apiHelper.InTheContextOfAnAuthenticatedUser( async client => { // Arrange await _fixture.SendAsync(command); // Act var response = await client .GetAsync(MenuRoute("items")); // Assert var expectedLinks = new List <string> { LinkNames.Self }; var resource = await response.ShouldBeAResource <MenuItemsContainerResource>(expectedLinks); resource.Items.ShouldAllBe(i => i.Links.Count == 0); }, fixture);