예제 #1
0
        public void TestGetAllPhoto()
        {
            IEnumerable <Photo> ienumablePhoto = new List <Photo>()
            {
                photo
            };
            var contextMock = new Mock <HttpContext>();

            contextMock.Setup(x => x.User).Returns(new ClaimsPrincipal(claims));
            mockPhotoService.Setup(x => x.GetAllPhoto(It.IsAny <string>())).Returns(ienumablePhoto);
            var photoController = new PhotoController(mockPhotoService.Object);

            photoController.ControllerContext.HttpContext = contextMock.Object;
            IActionResult getAllPhoto = photoController.GetAllPhoto();
            var           type        = getAllPhoto.GetType();

            Assert.AreEqual(type.Name, "OkObjectResult");
        }