public void Validate_WhenCalled_ReturnsValidator()
        {
            IAccountCoreDataCommand <IAccountBase> sut = CreateSut();

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

            Assert.That(result, Is.SameAs(_validatorMockContext.ValidatorMock.Object));
        }
        public void Validate_WhenCalled_AssertShouldNotBeNullOrWhiteSpaceWasCalledOnStringValidatorWithAccountName()
        {
            string accountName = _fixture.Create <string>();
            IAccountCoreDataCommand <IAccountBase> sut = CreateSut(accountName);

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

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldNotBeNullOrWhiteSpace(
                                                                 It.Is <string>(value => value == accountName),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.CompareOrdinal(field, "AccountName") == 0)),
                                                             Times.Once);
        }
        public void Validate_WhenCalled_AssertShouldHaveMinLengthWasCalledOnStringValidatorWithAccountName()
        {
            string accountName = _fixture.Create <string>();
            IAccountCoreDataCommand <IAccountBase> sut = CreateSut(accountName);

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

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldHaveMinLength(
                                                                 It.Is <string>(value => value == accountName),
                                                                 It.Is <int>(minLength => minLength == 1),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.CompareOrdinal(field, "AccountName") == 0),
                                                                 It.Is <bool>(allowNull => allowNull == false)),
                                                             Times.Once);
        }
        public void Validate_WhenCalled_AssertShouldHaveMaxLengthWasCalledOnStringValidatorWithDescription()
        {
            string description = _fixture.Create <string>();
            IAccountCoreDataCommand <IAccountBase> sut = CreateSut(description: description);

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

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldHaveMaxLength(
                                                                 It.Is <string>(value => value == description),
                                                                 It.Is <int>(maxLength => maxLength == 512),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.CompareOrdinal(field, "Description") == 0),
                                                                 It.Is <bool>(allowNull => allowNull)),
                                                             Times.Once);
        }
        public void Validate_WhenCommonRepositoryIsNull_ThrowsArgumentNullException()
        {
            IAccountCoreDataCommand <IAccountBase> sut = CreateSut();

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

            Assert.That(result.ParamName, Is.EqualTo("commonRepository"));
        }