public async Task QueryAsync_WhenQueryIsNotNull_AssertGenerateGenericKeyAsyncWasNotCalledOnKeyGenerator()
        {
            QueryHandler sut = CreateSut();

            await sut.QueryAsync(BuildGetUserSpecificKeyQuery());

            _keyGeneratorMock.Verify(m => m.GenerateGenericKeyAsync(It.IsAny <IEnumerable <string> >()), Times.Never);
        }
        public async Task QueryAsync_WhenQueryIsNotNull_ReturnsNotNull()
        {
            QueryHandler sut = CreateSut();

            string result = await sut.QueryAsync(BuildGetUserSpecificKeyQuery());

            Assert.That(result, Is.Not.Null);
        }
        public async Task QueryAsync_WhenQueryIsNotNull_AssertKeyElementCollectionWasCalledOnGetUserSpecificKeyQuery()
        {
            QueryHandler sut = CreateSut();

            Mock <IGetUserSpecificKeyQuery> getUserSpecificKeyQueryMock = BuildGetUserSpecificKeyQueryMock();
            await sut.QueryAsync(getUserSpecificKeyQueryMock.Object);

            getUserSpecificKeyQueryMock.Verify(m => m.KeyElementCollection, Times.Once);
        }
        public async Task QueryAsync_WhenQueryIsNotNull_AssertValidateWasCalledOnGetUserSpecificKeyQuery()
        {
            QueryHandler sut = CreateSut();

            Mock <IGetUserSpecificKeyQuery> getUserSpecificKeyQueryMock = BuildGetUserSpecificKeyQueryMock();
            await sut.QueryAsync(getUserSpecificKeyQueryMock.Object);

            getUserSpecificKeyQueryMock.Verify(m => m.Validate(It.Is <IValidator>(value => value != null && value == _validatorMock.Object)), Times.Once);
        }
        public async Task QueryAsync_WhenQueryIsNotNull_ReturnsKeyFromKeyGenerator()
        {
            string       generatedKey = _fixture.Create <string>();
            QueryHandler sut          = CreateSut(generatedKey);

            string result = await sut.QueryAsync(BuildGetUserSpecificKeyQuery());

            Assert.That(result, Is.EqualTo(generatedKey));
        }
        public async Task QueryAsync_WhenQueryIsNotNull_AssertGenerateUserSpecificKeyAsyncWasCalledOnKeyGenerator()
        {
            QueryHandler sut = CreateSut();

            IEnumerable <string>     keyElementCollection    = _fixture.CreateMany <string>(_random.Next(1, 5)).ToArray();
            IGetUserSpecificKeyQuery getUserSpecificKeyQuery = BuildGetUserSpecificKeyQuery(keyElementCollection);
            await sut.QueryAsync(getUserSpecificKeyQuery);

            _keyGeneratorMock.Verify(m => m.GenerateUserSpecificKeyAsync(It.Is <IEnumerable <string> >(value => value != null && Equals(value, keyElementCollection))), Times.Once);
        }
        public void QueryAsync_WhenQueryIsNull_ThrowsArgumentNullException()
        {
            QueryHandler sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.QueryAsync(null));

            // ReSharper disable PossibleNullReferenceException
            Assert.That(result.ParamName, Is.EqualTo("query"));
            // ReSharper restore PossibleNullReferenceException
        }