コード例 #1
0
        public async Task ReturnCorrectData_WhenPageNumberIsPassed()
        {
            //Arrange
            var contextOptions = new DbContextOptionsBuilder <ItsAllAboutTheGameDbContext>()
                                 .UseInMemoryDatabase(databaseName: "ReturnCorrectData_WhenPageNumberIsPassed")
                                 .UseInternalServiceProvider(serviceProvider)
                                 .Options;
            var listOfUsers = new List <User>()
            {
                testUserOne, testUserTwo
            };

            //Act
            using (var actContext = new ItsAllAboutTheGameDbContext(contextOptions))
            {
                await actContext.AddRangeAsync(listOfUsers);

                await actContext.SaveChangesAsync();
            }

            //Assert
            using (var assertContext = new ItsAllAboutTheGameDbContext(contextOptions))
            {
                var command = new UserService(assertContext, foreignExchangeServiceMock.Object,
                                              walletServiceMock.Object, dateTimeProviderMock.Object);

                var result = await command.GetAllUsers(null, 2, 1, GlobalConstants.DefaultUserSorting);

                Assert.IsInstanceOfType(result, typeof(IPagedList <UserDTO>));
                Assert.IsTrue(result.Count() == 1);
                Assert.AreEqual(testUserTwo.UserName, result.First().Username);
                Assert.IsFalse(result.First().Admin);
                Assert.IsFalse(result.First().Deleted);
            }
        }