Esempio n. 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());
        }
Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 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;
        }
Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }