public void GivenItHasAnApiScope_WhenItCallsGetAllApiScopes_ThenShouldReturnAllScopes() { // Given var apiScopesData = new[] { new ApiScopeData(id: "1", name: "API1", displayName: "API 1", description: "Description 1", true), new ApiScopeData(id: "1", name: "API2", displayName: "API 2", description: "Description 2", true) }; ApiScopeDataAccessMock .Setup(apiScopeDataAccess => apiScopeDataAccess.GetAsync()) .ReturnsAsync(apiScopesData.AsEnumerable()); // When var apiScopes = ApiScopeService.GetAllApiScopesAsync().GetAwaiter().GetResult(); // Then ApiScopeDataAccessMock.Verify(apiScopeDataAccess => apiScopeDataAccess.GetAsync(), Times.Once); Assert.IsNotNull(apiScopes); Assert.IsTrue(apiScopes.Count() == 2); Assert.IsTrue(apiScopesData.All(data => apiScopes.Any(apiScope => apiScope.Name == data.Name && apiScope.DisplayName == data.DisplayName))); }
private Task <IEnumerable <ApiScopeModel> > GetAllApiScopes() { return(ApiScopeService.GetAllApiScopesAsync()); }
public async Task <IActionResult> Index() { var scopes = await ApiScopeService.GetAllApiScopesAsync(); return(View(scopes)); }