public void DeleteUser() { // Arrange DBSetup(); Mock<IUserService> userService = new Mock<IUserService>(); userService.Setup(x => x.DeleteUser(It.IsAny<IDocumentSession>(), It.IsAny<string>())).Returns("users/1"); UserApiController controller = new UserApiController(userService.Object); // Act IHttpActionResult result = controller.DeleteUser("1"); // Assert Assert.IsNotNull(result); Assert.AreEqual(typeof(OkResult), result.GetType()); }
public void DeleteUserFail() { // Arrange DBSetup(); Mock<IUserService> userService = new Mock<IUserService>(); userService.Setup(x => x.UpdateUser(It.IsAny<IDocumentSession>(), It.IsAny<User>())).Returns<User>(null); UserApiController controller = new UserApiController(userService.Object); // Act IHttpActionResult result = controller.DeleteUser("1"); // Assert Assert.IsNotNull(result); Assert.AreEqual(typeof(BadRequestErrorMessageResult), result.GetType()); Assert.AreEqual((result as BadRequestErrorMessageResult).Message, "User not found!"); }