예제 #1
0
        public void GetById_WhenCalled_ReturnsOkResult()
        {
            var id          = 1;
            var mockService = new Mock <IPhotoService>();

            mockService.Setup(service => service.GetPhotoById(id)).Returns(Photos.FirstOrDefault(c => c.Id == id));
            var controller = new PhotoController(mockService.Object, _mapper, _userManager.Object);

            var result = controller.GetById(id);

            Assert.IsInstanceOf <OkObjectResult>(result.Result);
        }
예제 #2
0
        public void GetById_WhenCalled_ReturnsPhotoById()
        {
            var id          = 1;
            var mockService = new Mock <IPhotoService>();

            mockService.Setup(service => service.GetPhotoById(id)).Returns(Photos.FirstOrDefault(c => c.Id == id));
            var controller = new PhotoController(mockService.Object, _mapper, _userManager.Object);

            var result = controller.GetById(id).Result as OkObjectResult;
            var item   = result.Value as GetPhotoDto;

            Assert.AreEqual(id, item.Id);
            Assert.IsInstanceOf <GetPhotoDto>(result.Value);
        }