public async Task ThrowArgumentNullException_WhenPassedNullName() { // 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 <ArgumentNullException>(async() => await SUT.AddChampionAsync(null)); }
public async Task AddChampionAsync_ShouldAddChampion_WhenPassedValidParameters() { // Arrange var contextOptions = new DbContextOptionsBuilder <DataContext>() .UseInMemoryDatabase(databaseName: "AddChampionAsync_ShouldAddChampion_WhenPassedValidParameters") .Options; string validFirstName = "testChamp"; bool validIsDeleted = false; Champion validChampion = new Champion { Name = validFirstName }; Champion result = null; // Act using (DataContext actContext = new DataContext(contextOptions)) { Mock <IPandaScoreClient> pandaScoreClientMock = new Mock <IPandaScoreClient>(); ChampionService SUT = new ChampionService( pandaScoreClientMock.Object, actContext); result = await SUT.AddChampionAsync(validFirstName); } // Assert using (DataContext assertContext = new DataContext(contextOptions)) { Assert.IsNotNull(result); Assert.IsNotNull(result.CreatedOn); Assert.IsNull(result.DeletedOn); Assert.IsTrue(result.IsDeleted.Equals(validIsDeleted)); Assert.IsTrue(assertContext.Champions.Any(c => c.Name.Equals(result.Name))); } }