예제 #1
0
        public void GetListOfAppUsersAndCheckAreEqualLikeModels()
        {
            //Arrange
            AppUser appUser1 = new AppUser()
            {
                Id         = 1,
                FirstName  = "test",
                LastName   = "test",
                PositionId = 1
            };

            AppUser appUser2 = new AppUser()
            {
                Id         = 2,
                FirstName  = "test",
                LastName   = "test",
                PositionId = 1
            };

            var options = new DbContextOptionsBuilder <Context>()
                          .UseInMemoryDatabase(databaseName: "UsersDirectoryMVC")
                          .Options;

            using (var context = new Context(options))
            {
                //Act
                var appUserRepository = new AppUserRepository(context);
                appUserRepository.AddAppUser(appUser1);
                appUserRepository.AddAppUser(appUser2);

                var listOfAppUsers = appUserRepository.GetAllActiveAppUsers();

                //Assert
                listOfAppUsers.FirstOrDefault(e => e.Id == 1).Should().Equals(appUser1);
                listOfAppUsers.FirstOrDefault(e => e.Id == 2).Should().Equals(appUser2);
            }
        }