public async Task ShouldAddConnection() { //Arrange IMatchListItemsService matchListItemService = new MatchListItemsService(); int startNumberOfConnections = new Random().Next(); MatchListItem matchListItem = new MatchListItem { Id = Guid.NewGuid().ToString(), Url = Guid.NewGuid().ToString(), Name = "Game", Password = "******", NumberOfConnections = startNumberOfConnections }; matchListItemService.AddMatchListItem(matchListItem); var handler = new AddConnectionCommandHandler(matchListItemService); //Act await handler.Handle(new AddConnectionCommand { Url = matchListItem.Url }, CancellationToken.None); //Assert int numberOfConnections = matchListItemService.GetMatchById(matchListItem.Id).NumberOfConnections; int expectedNumberOfConnections = startNumberOfConnections + 1; numberOfConnections.Should().Be(expectedNumberOfConnections); }
public async Task ShouldAddMatchListItem() { //Arrange IMatchListItemsService matchListItemService = new MatchListItemsService(); MatchListItem matchListItem = new MatchListItem(); var handler = new AddMatchListItemCommandHandler(matchListItemService); //Act await handler.Handle(new AddMatchListItemCommand { MatchListItem = matchListItem }, CancellationToken.None); //Assert MatchListItem result = matchListItemService.GetMatchById(matchListItem.Id); result.Should().NotBeNull(); result.Should().Be(matchListItem); }
public async Task ShouldRemoveMatchListItem() { //Arrange IMatchListItemsService matchListItemService = new MatchListItemsService(); MatchListItem matchListItem = new MatchListItem { Url = Guid.NewGuid().ToString() }; var handler = new RemoveMatchByUrlCommandHandler(matchListItemService); //Act await handler.Handle(new RemoveMatchByUrlCommand { Url = matchListItem.Url }, CancellationToken.None); //Assert MatchListItem result = matchListItemService.GetMatchById(matchListItem.Id); result.Should().BeNull(); }
public async Task ShouldAddMatchListItem() { //Arrange IMatchListItemsService matchListItemService = new MatchListItemsService(); MatchListItem matchListItem = new MatchListItem { Id = Guid.NewGuid().ToString(), Url = Guid.NewGuid().ToString(), Name = "Game", Password = "******", }; var handler = new AddMatchListItemCommandHandler(matchListItemService); //Act await handler.Handle(new AddMatchListItemCommand { MatchListItem = matchListItem }, CancellationToken.None); //Assert MatchListItem result = matchListItemService.GetMatchById(matchListItem.Id); result.Should().NotBeNull(); result.Should().Be(matchListItem); }