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