Example #1
0
        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());
        }
Example #2
0
        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));
        }
Example #3
0
        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);
        }
Example #4
0
        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;
        }
Example #5
0
        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));
        }
Example #6
0
        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);
        }
Example #7
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);
        }
Example #8
0
        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);
        }
Example #9
0
        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);
        }