public void Validate_WhenCalled_ReturnsValidator()
        {
            IKeyValueEntryIdentificationCommand sut = CreateSut();

            IValidator result = sut.Validate(_validatorMockContext.ValidatorMock.Object, _commonRepositoryMock.Object);

            Assert.That(result, Is.EqualTo(_validatorMockContext.ValidatorMock.Object));
        }
        public async Task ExecuteAsync_WhenCommandIsNotNull_AssertManageRepositoryAsyncWasCalledOnKeyValueEntryIdentificationCommandHandlerBaseWithKeyValueEntryIdentificationCommand()
        {
            CommandHandler sut = CreateSut();

            IKeyValueEntryIdentificationCommand keyValueEntryIdentificationCommand = BuildKeyValueEntryIdentificationCommand();
            await sut.ExecuteAsync(keyValueEntryIdentificationCommand);

            Assert.That(((Sut)sut).ManageRepositoryAsyncWasCalledWithKeyValueEntryIdentificationCommand, Is.EqualTo(keyValueEntryIdentificationCommand));
        }
            protected override Task ManageRepositoryAsync(IKeyValueEntryIdentificationCommand command)
            {
                NullGuard.NotNull(command, nameof(command));

                ManageRepositoryAsyncWasCalled = true;
                ManageRepositoryAsyncWasCalledWithKeyValueEntryIdentificationCommand = command;

                return(Task.CompletedTask);
            }
        public void Validate_WhenCommonRepositoryIsNull_ThrowsArgumentNullException()
        {
            IKeyValueEntryIdentificationCommand sut = CreateSut();

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Validate(_validatorMockContext.ValidatorMock.Object, null));

            // ReSharper disable PossibleNullReferenceException
            Assert.That(result.ParamName, Is.EqualTo("commonRepository"));
            // ReSharper restore PossibleNullReferenceException
        }
        public void Validate_WhenCalled_AssertShouldNotBeNullOrWhiteSpaceWasCalledOnStringValidatorWithKey()
        {
            string key = _fixture.Create <string>();
            IKeyValueEntryIdentificationCommand sut = CreateSut(key);

            sut.Validate(_validatorMockContext.ValidatorMock.Object, _commonRepositoryMock.Object);

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldNotBeNullOrWhiteSpace(
                                                                 It.Is <string>(value => string.CompareOrdinal(value, key) == 0),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.CompareOrdinal(field, "Key") == 0)),
                                                             Times.Once());
        }