Пример #1
0
        public async Task AddEndDatePlastDegreeForUser_InValid_Test()
        {
            //Arrange
            bool successfulAddedEndDate = false;

            _userManager.Setup(x => x.GetUserAsync(It.IsAny <ClaimsPrincipal>())).ReturnsAsync(new User()
            {
                Id = _userId
            });
            _userService.Setup(x => x.GetUserAsync(It.IsAny <string>())).ReturnsAsync(_user);
            _userManager.Setup(x => x.GetRolesAsync(It.IsAny <User>())).ReturnsAsync(new List <string>()
            {
                Roles.Admin
            });
            _plastDegreeService.Setup(cs => cs.AddEndDateForUserPlastDegreeAsync(It.IsAny <UserPlastDegreePutDTO>()))
            .ReturnsAsync(successfulAddedEndDate);

            ActiveMembershipController activeMembershipController = _activeMembershipController;

            //Act
            var result = await activeMembershipController.AddEndDatePlastDegreeForUser(new UserPlastDegreePutDTO());

            //Assert
            Assert.IsInstanceOf <BadRequestResult>(result);
        }
Пример #2
0
        public async Task AddEndDatePlastDegreeForUser_InValid_Test()
        {
            //Arrange
            bool successfulAddedEndDate = false;

            _plastDegreeService.Setup(cs => cs.AddEndDateForUserPlastDegreeAsync(It.IsAny <UserPlastDegreePutDTO>()))
            .ReturnsAsync(successfulAddedEndDate);

            ActiveMembershipController activeMembershipController = _activeMembershipController;

            //Act
            var result = await activeMembershipController.AddEndDatePlastDegreeForUser(new UserPlastDegreePutDTO());

            //Assert
            Assert.IsInstanceOf <BadRequestResult>(result);
        }
Пример #3
0
        public async Task AddEndDatePlastDegreeForUser_403Forbidden()
        {
            //Arrange
            _userManager.Setup(x => x.GetUserAsync(It.IsAny <ClaimsPrincipal>())).ReturnsAsync(new User()
            {
                Id = _userId
            });
            _userService.Setup(x => x.GetUserAsync(It.IsAny <string>())).ReturnsAsync(_user);
            _userManager.Setup(x => x.GetRolesAsync(It.IsAny <User>())).ReturnsAsync(new List <string>());

            ActiveMembershipController activeMembershipController = _activeMembershipController;
            var expected = StatusCodes.Status403Forbidden;

            // Act
            var result = await activeMembershipController.AddEndDatePlastDegreeForUser(new UserPlastDegreePutDTO());

            var actual = (result as StatusCodeResult).StatusCode;

            // Assert
            _loggerService.Verify((x) => x.LogError(It.IsAny <string>()), Times.Once);
            _userManager.Verify();
            Assert.AreEqual(expected, actual);
        }