public void ToDomain_WhenCalled_ReturnsPostingJournal() { IApplyPostingJournalCommand sut = CreateSut(); IPostingJournal result = sut.ToDomain(_accountingRepositoryMock.Object); Assert.That(result, Is.TypeOf <PostingJournal>()); }
public void ToDomain_WhenCalled_ReturnsPostingJournalWherePostingLineCollectionContainingSameAmountOfPostingLinesAsApplyPostingLineCommands() { int numberOfApplyPostingLineCommands = _random.Next(10, 25); IApplyPostingLineCommand[] applyPostingLineCommandCollection = _fixture.CreateMany <IApplyPostingLineCommand>(numberOfApplyPostingLineCommands).ToArray(); IApplyPostingJournalCommand sut = CreateSut(applyPostingLineCommandCollection: applyPostingLineCommandCollection); IPostingJournal result = sut.ToDomain(_accountingRepositoryMock.Object); Assert.That(result.PostingLineCollection.Count(), Is.EqualTo(numberOfApplyPostingLineCommands)); }
public void ToDomain_WhenCalled_AssertGetAccountingAsyncWasCalledOnAccountingRepository() { int accountingNumber = _fixture.Create <int>(); IApplyPostingJournalCommand sut = CreateSut(accountingNumber); sut.ToDomain(_accountingRepositoryMock.Object); _accountingRepositoryMock.Verify(m => m.GetAccountingAsync( It.Is <int>(value => value == accountingNumber), It.Is <DateTime>(value => value == DateTime.Today)), Times.Once); }
public void ToDomain_WhenCalled_ReturnsPostingJournalWherePostingLineCollectionContainingPostingLinesFromToDomainOnEachApplyPostingLineCommands() { IPostingLine[] postingLineCollection = new[] { _fixture.BuildPostingLineMock().Object, _fixture.BuildPostingLineMock().Object, _fixture.BuildPostingLineMock().Object, _fixture.BuildPostingLineMock().Object, _fixture.BuildPostingLineMock().Object, _fixture.BuildPostingLineMock().Object, _fixture.BuildPostingLineMock().Object }; IApplyPostingJournalCommand sut = CreateSut(applyPostingLineCommandCollection: postingLineCollection.Select(CreateApplyPostingLineCommand).ToArray()); IPostingJournal result = sut.ToDomain(_accountingRepositoryMock.Object); foreach (IPostingLine postingLine in postingLineCollection) { Assert.That(result.PostingLineCollection.Contains(postingLine), Is.True); } }
public void ToDomain_WhenCalled_AssertToDomainWasCalledOnEachApplyPostingLineCommand() { IAccounting accounting = _fixture.BuildAccountingMock().Object; IEnumerable <Mock <IApplyPostingLineCommand> > applyPostingLineCommandMockCollection = new[] { CreateApplyPostingLineCommandMock(), CreateApplyPostingLineCommandMock(), CreateApplyPostingLineCommandMock(), CreateApplyPostingLineCommandMock(), CreateApplyPostingLineCommandMock(), CreateApplyPostingLineCommandMock(), CreateApplyPostingLineCommandMock() }; IApplyPostingJournalCommand sut = CreateSut(accounting: accounting, applyPostingLineCommandCollection: applyPostingLineCommandMockCollection.Select(applyPostingLineCommandMock => applyPostingLineCommandMock.Object).ToArray()); sut.ToDomain(_accountingRepositoryMock.Object); foreach (Mock <IApplyPostingLineCommand> applyPostingLineCommandMock in applyPostingLineCommandMockCollection) { applyPostingLineCommandMock.Verify(m => m.ToDomain(It.Is <IAccounting>(value => value == accounting)), Times.Once); } }
public void ToDomain_WhenAccountingRepositoryIsNull_ThrowsArgumentNullException() { IApplyPostingJournalCommand sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ToDomain(null)); // ReSharper disable PossibleNullReferenceException Assert.That(result.ParamName, Is.EqualTo("accountingRepository")); // ReSharper restore PossibleNullReferenceException }