public async Task GetNestResources_GivenNoResources_ExpectJsonWithEmptyList() { var roleQueries = new Mock <IRoleQueries>(); roleQueries.Setup(x => x.GetNestedSimpleResources()).ReturnsAsync(Maybe <List <SimpleResourceModel> > .Nothing); var controller = new ResourceApiController(roleQueries.Object); var response = Assert.IsType <JsonResult>(await controller.GetNestResources()); var data = Assert.IsType <List <SimpleResourceModel> >(response.Value); Assert.Empty(data); }
public async Task GetNestResources_GivenResourcesAreFound_ExpectJsonWithPopulatedList() { var roleQueries = new Mock <IRoleQueries>(); roleQueries.Setup(x => x.GetNestedSimpleResources()).ReturnsAsync(Maybe.From(new List <SimpleResourceModel> { new SimpleResourceModel(TestVariables.ResourceId, "name", null), })); var controller = new ResourceApiController(roleQueries.Object); var response = Assert.IsType <JsonResult>(await controller.GetNestResources()); var data = Assert.IsType <List <SimpleResourceModel> >(response.Value); Assert.Single(data); }