Exemple #1
0
        public async Task <IActionResult> Enabled(string id, bool isEnabled)
        {
            if (!isEnabled)
            {
                await ApiScopeService.EnableApiScopeAsync(id);
            }
            else
            {
                await ApiScopeService.DisableApiScopeAsync(id);
            }

            return(RedirectToAction(nameof(Index)));
        }
Exemple #2
0
        public void GivenItHasApiScope_WhenitCallsEnabled_AndApiScopeIsDesabled_ThenShouldEnable()
        {
            // Given
            var id           = "1";
            var apiScopeData = new ApiScopeData(id, name: "ApiScope", displayName: "Api Scope", description: "Api Scope Description", enabled: true);

            ApiScopeDataAccessMock
            .Setup(dataAccess => dataAccess.GetByField(It.IsAny <Expression <Func <ApiScopeData, string> > >(), It.IsAny <string>()))
            .ReturnsAsync(apiScopeData);

            ApiScopeDataAccessMock
            .Setup(dataAccess => dataAccess.UpdateAsync(It.IsAny <Expression <Func <ApiScopeData, string> > >(), It.IsAny <string>(), It.IsAny <UpdateDefinition <ApiScopeData> >()))
            .ReturnsAsync(true);

            // When
            var apiScope = ApiScopeService.EnableApiScopeAsync(id).GetAwaiter().GetResult();

            // Then
            ApiScopeDataAccessMock.Verify(dataAccess => dataAccess.GetByField(It.IsAny <Expression <Func <ApiScopeData, string> > >(), It.IsAny <string>()), Times.Once);
            ApiScopeDataAccessMock.Verify(dataAccess => dataAccess.UpdateAsync(It.IsAny <Expression <Func <ApiScopeData, string> > >(), It.IsAny <string>(), It.IsAny <UpdateDefinition <ApiScopeData> >()), Times.Once);
            Assert.IsTrue(CheckApiScopeAndApiScopeData(apiScopeData, apiScope));
        }