Beispiel #1
0
        public void CheckPositionExistAfterAddAndIsEqualLikeModelName()
        {
            //Arrange
            Position position = new Position()
            {
                Id   = 1,
                Name = "test"
            };

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

            using (var context = new Context(options))
            {
                //Act
                var appUserRepository = new AppUserRepository(context);
                appUserRepository.AddPosition(position);
                var positionResult = appUserRepository.GetAppUserPositionName(1);

                //Assert
                positionResult.Should().NotBeNull();
                positionResult.Should().Equals(position.Name);
            }
        }
Beispiel #2
0
        public void GetAppUserPositionNameAndCheckAreEqualLikePositionNameString()
        {
            var positionName = "Junior";

            AppUser appUser = new AppUser()
            {
                Id         = 1,
                PositionId = 1
            };

            //Arrange
            Position position = new Position()
            {
                Id   = 1,
                Name = "Junior"
            };

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

            using (var context = new Context(options))
            {
                //Act
                var appUserRepository = new AppUserRepository(context);
                appUserRepository.AddPosition(position);
                var positionNameToCheck = appUserRepository.GetAppUserPositionName(appUser.PositionId);

                //Assert
                positionNameToCheck.Should().NotBeNull();
                positionNameToCheck.Should().Equals(positionName);
            }
        }
Beispiel #3
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);
            }
        }