Example #1
0
        public void GetAllPositionsAndCheckAreEqualLikeModelsList()
        {
            //Arrange
            Position position1 = new Position()
            {
                Id   = 1,
                Name = "Junior"
            };

            Position position2 = new Position()
            {
                Id   = 2,
                Name = "Mid"
            };

            List <Position> listOfPositions = new List <Position>();

            listOfPositions.Add(position1);
            listOfPositions.Add(position2);

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

            using (var context = new Context(options))
            {
                //Act
                var appUserRepository = new AppUserRepository(context);
                appUserRepository.AddPosition(position1);
                appUserRepository.AddPosition(position2);
                var positions = appUserRepository.GetAllPositions().ToList();

                //Assert
                positions.Should().NotBeEmpty();
                positions.Should().Equals(listOfPositions);
            }
        }