Exemplo n.º 1
0
        public void Validate_WhenCalled_ReturnsValidator()
        {
            IGetPostingLineCollectionQuery sut = CreateSut();

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

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

            IGetPostingLineCollectionQuery query  = CreateQuery();
            IPostingLineCollection         result = await sut.QueryAsync(query);

            Assert.That(result.Count(), Is.EqualTo(0));
        }
        public async Task QueryAsync_WhenNoPostingLineCollectionWasReturnedFromAccountingRepository_ReturnsNotNull()
        {
            QueryHandler sut = CreateSut(false);

            IGetPostingLineCollectionQuery query  = CreateQuery();
            IPostingLineCollection         result = await sut.QueryAsync(query);

            Assert.That(result, Is.Not.Null);
        }
Exemplo n.º 4
0
        public void Validate_WhenAccountingRepositoryIsNull_ThrowsArgumentNullException()
        {
            IGetPostingLineCollectionQuery sut = CreateSut();

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

            // ReSharper disable PossibleNullReferenceException
            Assert.That(result.ParamName, Is.EqualTo("accountingRepository"));
            // ReSharper restore PossibleNullReferenceException
        }
        public async Task QueryAsync_WhenNoPostingLineCollectionWasReturnedFromAccountingRepository_ReturnsWhereStatusDateIsEqualToStatusDateFromGetPostingLineCollectionQuery()
        {
            QueryHandler sut = CreateSut(false);

            DateTime statusDate = _fixture.Create <DateTime>().Date;
            IGetPostingLineCollectionQuery query  = CreateQuery(statusDate: statusDate);
            IPostingLineCollection         result = await sut.QueryAsync(query);

            Assert.That(result.StatusDate, Is.EqualTo(statusDate));
        }
        public async Task QueryAsync_WhenPostingLineCollectionWasReturnedFromAccountingRepository_ReturnsCalculatedPostingLineCollection()
        {
            IPostingLineCollection calculatedPostingLineCollection = _fixture.BuildPostingLineCollectionMock().Object;
            IPostingLineCollection postingLineCollection           = _fixture.BuildPostingLineCollectionMock(calculatedPostingLineCollection: calculatedPostingLineCollection).Object;
            QueryHandler           sut = CreateSut(postingLineCollection: postingLineCollection);

            IGetPostingLineCollectionQuery query  = CreateQuery();
            IPostingLineCollection         result = await sut.QueryAsync(query);

            Assert.That(result, Is.EqualTo(calculatedPostingLineCollection));
        }
Exemplo n.º 7
0
        public void Validate_WhenCalled_AssertShouldBeBetweenWasCalledOnIntegerValidator()
        {
            int numberOfPostingLines           = _fixture.Create <int>();
            IGetPostingLineCollectionQuery sut = CreateSut(numberOfPostingLines);

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

            _validatorMockContext.IntegerValidatorMock.Verify(m => m.ShouldBeBetween(
                                                                  It.Is <int>(value => value == numberOfPostingLines),
                                                                  It.Is <int>(minValue => minValue == 1),
                                                                  It.Is <int>(maxValue => maxValue == 512),
                                                                  It.Is <Type>(type => type == sut.GetType()),
                                                                  It.Is <string>(field => string.CompareOrdinal(field, "NumberOfPostingLines") == 0)),
                                                              Times.Once());
        }
        public async Task QueryAsync_WhenCalled_AssertGetPostingLinesAsyncWasCalledOnAccountingRepository()
        {
            QueryHandler sut = CreateSut();

            int      accountingNumber            = _fixture.Create <int>();
            DateTime statusDate                  = _fixture.Create <DateTime>().Date;
            int      numberOfPostingLines        = _fixture.Create <int>();
            IGetPostingLineCollectionQuery query = CreateQuery(accountingNumber, statusDate, numberOfPostingLines);
            await sut.QueryAsync(query);

            _accountingRepositoryMock.Verify(m => m.GetPostingLinesAsync(
                                                 It.Is <int>(value => value == accountingNumber),
                                                 It.Is <DateTime>(value => value == statusDate),
                                                 It.Is <int>(value => value == numberOfPostingLines)),
                                             Times.Once);
        }