public async Task ThrowArgumentNullException_WhenPassedNullAccessToken()
        {
            // 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.RebaseChampionsAsync(null));
        }
Example #2
0
        public async Task RebaseChampionsAsync_ShouldRepopulateChampionTable_WhenPassedValidParameters()
        {
            // Arrange
            var contextOptions = new DbContextOptionsBuilder <DataContext>()
                                 .UseInMemoryDatabase(databaseName: "RebaseChampionsAsync_ShouldRepopulateChampionTable_WhenPassedValidParameters")
                                 .Options;

            string validAccessToken    = string.Empty;
            string validCollectionName = "champions";
            int    validPageSize       = 100;

            Champion validChampion = new Champion
            {
                Id        = Guid.NewGuid(),
                Name      = "testChamp",
                DeletedOn = DateTime.UtcNow.AddHours(2),
                IsDeleted = true
            };

            IEnumerable <Champion> validChampionList = new List <Champion>()
            {
                validChampion
            };

            // Act
            using (DataContext actContext = new DataContext(contextOptions))
            {
                Mock <IPandaScoreClient> pandaScoreClientMock = new Mock <IPandaScoreClient>();

                pandaScoreClientMock
                .Setup(mock => mock.GetEntitiesParallel <Champion>(validAccessToken, validCollectionName, validPageSize))
                .Returns(Task.FromResult(validChampionList));

                ChampionService SUT = new ChampionService(
                    pandaScoreClientMock.Object,
                    actContext);

                await SUT.RebaseChampionsAsync(validAccessToken);
            }

            // Assert
            using (DataContext assertContext = new DataContext(contextOptions))
            {
                Assert.IsTrue(assertContext.Champions.Count() == 1);
                Assert.IsTrue(assertContext.Champions.Contains(validChampion));
            }
        }