Example #1
0
        public async Task QueryAsync_WhenCalled_AssertIdentifierWasCalledOnGetClientSecretIdentityQuery()
        {
            QueryHandler sut = CreateSut();

            Mock <IGetClientSecretIdentityQuery> queryMock = CreateQueryMock();
            await sut.QueryAsync(queryMock.Object);

            queryMock.Verify(m => m.Identifier, Times.Once);
        }
Example #2
0
        public async Task QueryAsync_WhenCalled_ReturnsClientSecretIdentityFromSecurityRepository()
        {
            IClientSecretIdentity clientSecretIdentity = _fixture.Create <IClientSecretIdentity>();
            QueryHandler          sut = CreateSut(clientSecretIdentity);

            IGetClientSecretIdentityQuery query  = CreateQueryMock().Object;
            IClientSecretIdentity         result = await sut.QueryAsync(query);

            Assert.That(result, Is.EqualTo(clientSecretIdentity));
        }
Example #3
0
        public async Task QueryAsync_WhenCalled_AssertGetClientSecretIdentityAsyncWasCalledOnSecurityRepository()
        {
            QueryHandler sut = CreateSut();

            int identifier = _fixture.Create <int>();
            IGetClientSecretIdentityQuery query = CreateQueryMock(identifier).Object;
            await sut.QueryAsync(query);

            _securityRepositoryMock.Verify(m => m.GetClientSecretIdentityAsync(It.Is <int>(value => value == identifier)), Times.Once());
        }
Example #4
0
        public async Task QueryAsync_WhenCalled_AssertValidateWasCalledOnGetClientSecretIdentityQuery()
        {
            QueryHandler sut = CreateSut();

            Mock <IGetClientSecretIdentityQuery> 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);
        }
Example #5
0
        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"));
        }