Beispiel #1
0
        public void ToDomain_WhenCalled_ReturnsAccounting()
        {
            IAccountingCommand sut = CreateSut();

            IAccounting result = sut.ToDomain(_commonRepositoryMock.Object);

            Assert.That(result, Is.TypeOf <Domain.Accounting.Accounting>());
        }
Beispiel #2
0
        public void ToDomain_WhenCommonRepositoryIsNull_ThrowsArgumentNullException()
        {
            IAccountingCommand sut = CreateSut();

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ToDomain(null));

            Assert.That(result.ParamName, Is.EqualTo("commonRepository"));
        }
        public void Validate_WhenCommonRepositoryIsNull_ThrowsArgumentNullException()
        {
            IAccountingCommand sut = CreateSut();

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

            Assert.That(result.ParamName, Is.EqualTo("commonRepository"));
        }
        public void Validate_WhenCalled_ReturnsValidator()
        {
            IAccountingCommand sut = CreateSut();

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

            Assert.That(result, Is.EqualTo(_validatorMockContext.ValidatorMock.Object));
        }
Beispiel #5
0
        public void ToDomain_WhenCalled_ReturnsAccountingWithLetterHeadFromCommonRepository()
        {
            ILetterHead        letterHead = _fixture.BuildLetterHeadMock().Object;
            IAccountingCommand sut        = CreateSut(letterHead: letterHead);

            ILetterHead result = sut.ToDomain(_commonRepositoryMock.Object).LetterHead;

            Assert.That(result, Is.EqualTo(letterHead));
        }
Beispiel #6
0
        public void ToDomain_WhenCalled_ReturnsAccountingWithNameFromCommand()
        {
            string             name = _fixture.Create <string>();
            IAccountingCommand sut  = CreateSut(name: name);

            string result = sut.ToDomain(_commonRepositoryMock.Object).Name;

            Assert.That(result, Is.EqualTo(name));
        }
Beispiel #7
0
        public void ToDomain_WhenCalled_ReturnsAccountingWithAccountingNumberFromCommand()
        {
            int accountingNumber   = _fixture.Create <int>();
            IAccountingCommand sut = CreateSut(accountingNumber);

            int result = sut.ToDomain(_commonRepositoryMock.Object).Number;

            Assert.That(result, Is.EqualTo(accountingNumber));
        }
Beispiel #8
0
        public void ToDomain_WhenCalled_AssertGetLetterHeadAsyncWasCalledOnCommonRepository()
        {
            int letterHeadNumber   = _fixture.Create <int>();
            IAccountingCommand sut = CreateSut(letterHeadNumber: letterHeadNumber);

            sut.ToDomain(_commonRepositoryMock.Object);

            _commonRepositoryMock.Verify(m => m.GetLetterHeadAsync(It.Is <int>(value => value == letterHeadNumber)), Times.Once);
        }
Beispiel #9
0
        public void ToDomain_WhenCalled_ReturnsAccountingWithBackDatingFromCommand()
        {
            int backDating         = _fixture.Create <int>();
            IAccountingCommand sut = CreateSut(backDating: backDating);

            int result = sut.ToDomain(_commonRepositoryMock.Object).BackDating;

            Assert.That(result, Is.EqualTo(backDating));
        }
Beispiel #10
0
        public void ToDomain_WhenCalled_ReturnsAccountingWithBalanceBelowZeroFromCommand()
        {
            BalanceBelowZeroType balanceBelowZero = _fixture.Create <BalanceBelowZeroType>();
            IAccountingCommand   sut = CreateSut(balanceBelowZero: balanceBelowZero);

            BalanceBelowZeroType result = sut.ToDomain(_commonRepositoryMock.Object).BalanceBelowZero;

            Assert.That(result, Is.EqualTo(balanceBelowZero));
        }
        public void Validate_WhenCalled_AssertShouldNotBeNullOrWhiteSpaceWasCalledOnStringValidatorForName()
        {
            string             name = _fixture.Create <string>();
            IAccountingCommand sut  = CreateSut(name);

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

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldNotBeNullOrWhiteSpace(
                                                                 It.Is <string>(value => string.Compare(value, name, false) == 0),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.Compare(field, "Name", false) == 0)),
                                                             Times.Once());
        }
        public void Validate_WhenCalled_AssertShouldHaveMinLengthWasCalledOnStringValidatorForName()
        {
            string             name = _fixture.Create <string>();
            IAccountingCommand sut  = CreateSut(name);

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

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldHaveMinLength(
                                                                 It.Is <string>(value => string.Compare(value, name, false) == 0),
                                                                 It.Is <int>(minLength => minLength == 1),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.Compare(field, "Name", false) == 0),
                                                                 It.Is <bool>(allowNull => allowNull == false)),
                                                             Times.Once());
        }
        public void Validate_WhenCalled_AssertShouldBeKnownValueWasCalledOnObjectValidatorForBalanceBelowZero()
        {
            BalanceBelowZeroType balanceBelowZero = _fixture.Create <BalanceBelowZeroType>();
            IAccountingCommand   sut = CreateSut(balanceBelowZero: balanceBelowZero);

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

            _validatorMockContext.ObjectValidatorMock.Verify(m => m.ShouldBeKnownValue(
                                                                 It.Is <BalanceBelowZeroType>(value => value == balanceBelowZero),
                                                                 It.IsNotNull <Func <BalanceBelowZeroType, Task <bool> > >(),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.Compare(field, "BalanceBelowZero", false) == 0),
                                                                 It.Is <bool>(allowNull => allowNull == false)),
                                                             Times.Once());
        }