public async Task ThrowArgumentException_WhenPassedInvalidId(string invalidId) { // Arrange Mock <IPandaScoreClient> pandaScoreClientMock = new Mock <IPandaScoreClient>(); Mock <DataContext> dataContextMock = new Mock <DataContext>(); // Act ChampionService SUT = new ChampionService( pandaScoreClientMock.Object, dataContextMock.Object); // Assert await Assert.ThrowsExceptionAsync <ArgumentException>(async() => await SUT.DeleteChampionAsync(invalidId)); }
public async Task DeleteChampionAsync_ShouldFlagChampionAsDelete_WhenPassedValidParameters() { // Arrange var contextOptions = new DbContextOptionsBuilder <DataContext>() .UseInMemoryDatabase(databaseName: "DeleteChampionAsync_ShouldFlagAChampionAsDelete_WhenPassedValidParameters") .Options; Guid Id = Guid.NewGuid(); bool validIsDeleted = true; Champion validChampion = new Champion { Id = Id, Name = "testChamp" }; Champion result = null; // Act using (DataContext actContext = new DataContext(contextOptions)) { Mock <IPandaScoreClient> pandaScoreClientMock = new Mock <IPandaScoreClient>(); await actContext.AddAsync(validChampion); await actContext.SaveChangesAsync(); ChampionService SUT = new ChampionService( pandaScoreClientMock.Object, actContext); result = await SUT.DeleteChampionAsync(Id.ToString()); } // Assert using (DataContext assertContext = new DataContext(contextOptions)) { Assert.IsNotNull(result); Assert.IsNotNull(result.DeletedOn); Assert.IsTrue(result.IsDeleted.Equals(validIsDeleted)); } }