public async Task Get() { var fileStorageService = new Mock <IFileStorageService>(); fileStorageService.Setup( s => s.GetDeserialized <MethodologyViewModel>("methodology/methodologies/test-slug.json" ) ) .ReturnsAsync( new MethodologyViewModel { Content = new List <ContentSectionViewModel> { new ContentSectionViewModel() }, Annexes = new List <ContentSectionViewModel> { new ContentSectionViewModel() } } ); var controller = new MethodologyController(fileStorageService.Object); var result = await controller.Get("test-slug"); var methodologyViewModel = result.Value; Assert.IsType <MethodologyViewModel>(methodologyViewModel); Assert.Single(methodologyViewModel.Content); Assert.Single(methodologyViewModel.Annexes); }
public async Task Get_NotFound() { var fileStorageService = new Mock <IFileStorageService>(); fileStorageService .Setup(s => s.GetDeserialized <MethodologyViewModel>(It.IsAny <string>())) .ReturnsAsync(new NotFoundResult()); var controller = new MethodologyController(fileStorageService.Object); var result = await controller.Get("unknown-slug"); Assert.IsType <NotFoundResult>(result.Result); }