public void GetAllFilterByCurrent_Test() { // Arrange var mockService = new Mock <IAppointmentTypeService>(); var controller = new AppointmentTypeController(mockService.Object); // Act IQueryable <AppointmentTypeModel> response = controller.GetAll(); Assert.AreEqual(response.Where(x => x.IsCurrent).Count(), response.Count()); }
public void GetById_NotFound_Test() { // Arrange var mockService = new Mock <IAppointmentTypeService>(); var controller = new AppointmentTypeController(mockService.Object); // Act IHttpActionResult actionResult = controller.GetById(-1); // Assert Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult)); }
public void GetAll_Test() { // Arrange var mockService = new Mock <IAppointmentTypeService>(); var controller = new AppointmentTypeController(mockService.Object); // Act IQueryable <AppointmentTypeModel> response = controller.GetAll(); // Assert Assert.IsNotNull(response); }
public void SetUp() { controllerContext = new HttpControllerContext(); HttpContext.Current = new HttpContext(new HttpRequest(null, "http://localhost", null), new HttpResponse(null)); controllerContext.Request = new HttpRequestMessage(); controllerContext.Request.Headers.Add("Basic", "password"); controller = new AppointmentTypeController(); controller.ControllerContext = controllerContext; }
public void Delete_Test() { // Arrange var mockService = new Mock <IAppointmentTypeService>(); var controller = new AppointmentTypeController(mockService.Object); int id = 10; int userId = 1; // Act IHttpActionResult actionResult = controller.Delete(id, userId); // Assert Assert.IsInstanceOfType(actionResult, typeof(OkResult)); }
public void Post_Test() { // Arrange var mockService = new Mock <IAppointmentTypeService>(); var controller = new AppointmentTypeController(mockService.Object); // Act IHttpActionResult actionResult = controller.Post(GetDemoItem(true), 1); var createdResult = actionResult as OkNegotiatedContentResult <int>; // Assert Assert.IsNotNull(createdResult); //Assert.AreEqual("DefaultApi", createdResult.RouteName); Assert.IsTrue(createdResult.Content >= 0); }
public void Put_Test() { // Arrange var mockService = new Mock <IAppointmentTypeService>(); var controller = new AppointmentTypeController(mockService.Object); AppointmentTypeModel model = GetDemoItem(false); int userId = 1; // Act IHttpActionResult actionResult = controller.Put(model, userId); var contentResult = actionResult as NegotiatedContentResult <AppointmentTypeModel>; // Assert Assert.IsNotNull(contentResult); Assert.AreEqual(HttpStatusCode.Accepted, contentResult.StatusCode); Assert.IsNotNull(contentResult.Content); Assert.AreEqual(model.Id, contentResult.Content.Id); }
public void GetDefault_Test() { // Arrange var mockService = new Mock <IAppointmentTypeService>(); mockService.Setup(x => x.GetDefault()) .Returns(new AppointmentTypeModel { IsDefault = true }); var controller = new AppointmentTypeController(mockService.Object); // Act IHttpActionResult actionResult = controller.GetDefault(); var contentResult = actionResult as OkNegotiatedContentResult <AppointmentTypeModel>; // Assert Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); Assert.IsTrue(contentResult.Content.IsDefault); }
public void GetById_Test() { int id = 1; // Arrange var mockService = new Mock <IAppointmentTypeService>(); mockService.Setup(x => x.GetById(id)) .Returns(new AppointmentTypeModel { Id = id }); var controller = new AppointmentTypeController(mockService.Object); // Act IHttpActionResult actionResult = controller.GetById(id); var contentResult = actionResult as OkNegotiatedContentResult <AppointmentTypeModel>; // Assert Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); Assert.AreEqual(id, contentResult.Content.Id); }