예제 #1
0
        public async void GetFolderByIdFailedAsync()
        {
            // Arrange
            mockFolderService.Setup(service => service.GetDetail(It.IsAny <int>())).Throws(new CurrentEntryNotFoundException("Specified Folder not found"));
            FolderController controller = new FolderController(mockFolderService.Object);

            var ex = await Assert.ThrowsAsync <CurrentEntryNotFoundException>(() => controller.Detail(It.IsAny <int>()));

            Assert.Equal("Specified Folder not found", ex.Message);
        }
예제 #2
0
        public async Task GetFolderByIdAsync()
        {
            // Arrange
            int id = 2;

            mockFolderService.Setup(service => service.GetDetail(id)).ReturnsAsync((await GetTestFolders()).FirstOrDefault(p => p.Id == 2));
            FolderController controller = new FolderController(mockFolderService.Object);

            // Act
            var result = await controller.Detail(id);

            var okResult = Assert.IsType <OkObjectResult>(result);
            var model    = Assert.IsType <FolderBaseDto>(okResult.Value);

            // Assert
            Assert.Equal((await GetTestFolders()).FirstOrDefault(f => f.Id == id).Title, model.Title);
        }