Пример #1
0
        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());
 }
Пример #3
0
        public async Task <IActionResult> Index()
        {
            var scopes = await ApiScopeService.GetAllApiScopesAsync();

            return(View(scopes));
        }