예제 #1
0
        public void GetById_NotFound_Test()
        {
            // Arrange
            var mockService = new Mock <IPatientPhoneNumberService>();
            var controller  = new PatientPhoneNumberController(mockService.Object);

            // Act
            IHttpActionResult actionResult = controller.GetById(-1);

            // Assert
            Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult));
        }
예제 #2
0
        public void GetById_Test()
        {
            int id = 42;

            // Arrange
            var mockService = new Mock <IPatientPhoneNumberService>();

            mockService.Setup(x => x.GetById(id))
            .Returns(new PatientPhoneNumberModel {
                Id = id
            });

            var controller = new PatientPhoneNumberController(mockService.Object);


            // Act
            IHttpActionResult actionResult = controller.GetById(id);
            var contentResult = actionResult as OkNegotiatedContentResult <PatientPhoneNumberModel>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(id, contentResult.Content.Id);
        }