public async Task CanRetrieveOnlyEnabledTokens() { var enabledToken = AuthTokenDatabaseEntityHelper.AddTokenRecordToTheDatabase(true, DatabaseContext); AuthTokenDatabaseEntityHelper.AddTokenRecordToTheDatabase(false, DatabaseContext); //add disabled token var expectedResponse = new TokensListResponse() { Tokens = new List <AuthToken>() { enabledToken } }; var url = new Uri($"/api/v1/tokens?enabled=true", UriKind.Relative); var response = await Client.GetAsync(url).ConfigureAwait(true); response.StatusCode.Should().Be(200); var data = await response.Content.ReadAsStringAsync().ConfigureAwait(true); var tokens = JsonConvert.DeserializeObject <TokensListResponse>(data); tokens.Tokens.Count.Should().Be(1); tokens.Should().BeEquivalentTo(expectedResponse); }
public void EnsureControllerListTokensMethodCallsGetAllTokensUseCase() { var response = new TokensListResponse(); _mockGetAllTokensUseCase.Setup(x => x.Execute(It.IsAny <GetTokensRequest>())).Returns(response); _classUnderTest.ListTokens(It.IsAny <GetTokensRequest>()); _mockGetAllTokensUseCase.Verify(x => x.Execute(It.IsAny <GetTokensRequest>()), Times.Once); }
public void ControllerListTokensMethodShouldReturn200StatusCode() { var response = new TokensListResponse(); _mockGetAllTokensUseCase.Setup(x => x.Execute(It.IsAny <GetTokensRequest>())).Returns(response); var result = _classUnderTest.ListTokens(It.IsAny <GetTokensRequest>()) as OkObjectResult; result.Should().NotBeNull(); result.StatusCode.Should().Be(200); }
public void GetsAllTokensFromTheGateway() { var stubbedEntities = _fixture.CreateMany <AuthToken>().ToList(); _mockGateway.Setup(x => x.GetAllTokens(20, 0, null)).Returns(stubbedEntities); var expectedResponse = new TokensListResponse { Tokens = stubbedEntities }; _classUnderTest.Execute(new GetTokensRequest { Enabled = null }).Should().BeEquivalentTo(expectedResponse); }
public void ControllerListTokensMethodCanListTokens() { var fixture = new Fixture(); var expectedResponse = new TokensListResponse() { Tokens = new List <AuthToken>() { fixture.Build <AuthToken>().Create() } }; _mockGetAllTokensUseCase.Setup(x => x.Execute(It.IsAny <GetTokensRequest>())).Returns(expectedResponse); var result = _classUnderTest.ListTokens(It.IsAny <GetTokensRequest>()) as OkObjectResult; result.Should().NotBeNull(); result.Value.Should().Be(expectedResponse); }