public async Task ThrowArgumentNullException_WhenPassedNullAccessToken()
        {
            // Arrange
            Mock <IPandaScoreClient> pandaScoreClientMock = new Mock <IPandaScoreClient>();
            Mock <DataContext>       dataContextMock      = new Mock <DataContext>();

            // Act
            MasteryService SUT = new MasteryService(
                pandaScoreClientMock.Object,
                dataContextMock.Object);

            // Assert
            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() =>
                                                                      await SUT.RebaseMasteriesAsync(null));
        }
Пример #2
0
        public async Task RebaseMasteriesAsync_ShouldRepopulateMasteriesTable_WhenPassedValidParameters()
        {
            // Arrange
            var contextOptions = new DbContextOptionsBuilder <DataContext>()
                                 .UseInMemoryDatabase(databaseName: "RebaseMasteriesAsync_ShouldRepopulateMasteriesTable_WhenPassedValidParameters")
                                 .Options;

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

            Mastery validMastery = new Mastery
            {
                Id        = Guid.NewGuid(),
                Name      = "testMastery",
                DeletedOn = DateTime.UtcNow.AddHours(2),
                IsDeleted = true
            };

            IEnumerable <Mastery> validMasteryList = new List <Mastery>()
            {
                validMastery
            };

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

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

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

                await SUT.RebaseMasteriesAsync(validAccessToken);
            }

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