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);
            }
        }