public void QueryAsync_WhenQueryIsNull_ThrowsArgumentNullException() { QueryHandler sut = CreateSut(); ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.QueryAsync(null)); Assert.That(result.ParamName, Is.EqualTo("query")); }
public async Task QueryAsync_WhenCalled_AssertIdentifierWasCalledOnGetUserIdentityQuery() { QueryHandler sut = CreateSut(); Mock <IGetUserIdentityQuery> queryMock = CreateQueryMock(); await sut.QueryAsync(queryMock.Object); queryMock.Verify(m => m.Identifier, Times.Once); }
public async Task QueryAsync_WhenCalled_ReturnsUserIdentityFromSecurityRepository() { IUserIdentity userIdentity = _fixture.Create <IUserIdentity>(); QueryHandler sut = CreateSut(userIdentity); IGetUserIdentityQuery query = CreateQueryMock().Object; IUserIdentity result = await sut.QueryAsync(query); Assert.That(result, Is.EqualTo(userIdentity)); }
public async Task QueryAsync_WhenCalled_AssertGetUserIdentityAsyncWasCalledOnSecurityRepository() { QueryHandler sut = CreateSut(); int identifier = _fixture.Create <int>(); IGetUserIdentityQuery query = CreateQueryMock(identifier).Object; await sut.QueryAsync(query); _securityRepositoryMock.Verify(m => m.GetUserIdentityAsync(It.Is <int>(value => value == identifier)), Times.Once()); }
public async Task QueryAsync_WhenCalled_AssertValidateWasCalledOnGetUserIdentityQuery() { QueryHandler sut = CreateSut(); Mock <IGetUserIdentityQuery> queryMock = CreateQueryMock(); await sut.QueryAsync(queryMock.Object); queryMock.Verify(m => m.Validate( It.Is <IValidator>(value => value == _validatorMock.Object), It.Is <ISecurityRepository>(value => value == _securityRepositoryMock.Object)), Times.Once); }