public async Task CreateAccounting_WhenCalled_ReturnsPartialViewResultWhereModelIsAccountingViewModel()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.CreateAccounting();

            Assert.That(result.Model, Is.TypeOf <AccountingViewModel>());
        }
        public async Task CreateAccounting_WhenCalled_ReturnsPartialViewResult()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.CreateAccounting();

            Assert.That(result, Is.TypeOf <PartialViewResult>());
        }
        public async Task CreateAccounting_WhenCalled_ReturnsPartialViewResultWhereViewNameIsEqualToPresentAccountingPartial()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.CreateAccounting();

            Assert.That(result.ViewName, Is.EqualTo("_PresentAccountingPartial"));
        }
Example #4
0
        public async Task CreateAccounting_WhenAccountingViewModelIsInvalid_ReturnsRedirectToActionResultWhereRouteValuesIsNull()
        {
            Controller sut = CreateSut(false);

            RedirectToActionResult result = (RedirectToActionResult)await sut.CreateAccounting(CreateAccountingViewModel());

            Assert.That(result.RouteValues, Is.Null);
        }
        public async Task CreateAccounting_WhenCalled_AssertQueryAsyncWasCalledOnQueryBusWithEmptyQueryForLetterHeadCollection()
        {
            Controller sut = CreateSut();

            await sut.CreateAccounting();

            _queryBusMock.Verify(m => m.QueryAsync <EmptyQuery, IEnumerable <ILetterHead> >(It.IsNotNull <EmptyQuery>()), Times.Once);
        }
Example #6
0
        public async Task CreateAccounting_WhenAccountingViewModelIsInvalid_ReturnsRedirectToActionResultWhereActionNameIsEqualToAccountings()
        {
            Controller sut = CreateSut(false);

            RedirectToActionResult result = (RedirectToActionResult)await sut.CreateAccounting(CreateAccountingViewModel());

            Assert.That(result.ActionName, Is.EqualTo("Accountings"));
        }
Example #7
0
        public async Task CreateAccounting_WhenAccountingViewModelIsInvalid_ReturnsRedirectToActionResult()
        {
            Controller sut = CreateSut(false);

            IActionResult result = await sut.CreateAccounting(CreateAccountingViewModel());

            Assert.That(result, Is.TypeOf <RedirectToActionResult>());
        }
Example #8
0
        public async Task CreateAccounting_WhenAccountingViewModelIsInvalid_AssertPublishAsyncWasNotCalledOnCommandBus()
        {
            Controller sut = CreateSut(false);

            await sut.CreateAccounting(CreateAccountingViewModel());

            _commandBusMock.Verify(m => m.PublishAsync(It.IsAny <ICreateAccountingCommand>()), Times.Never);
        }
Example #9
0
        public async Task CreateAccounting_WhenAccountingViewModelIsValid_AssertPublishAsyncWasCalledOnCommandBus()
        {
            Controller sut = CreateSut();

            await sut.CreateAccounting(CreateAccountingViewModel());

            _commandBusMock.Verify(m => m.PublishAsync(It.IsNotNull <ICreateAccountingCommand>()), Times.Once);
        }
        public async Task CreateAccounting_WhenCalled_ReturnsPartialViewResultWhereModelIsAccountingViewModelWhereEditModeIsEqualToCreate()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.CreateAccounting();

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.EditMode, Is.EqualTo(EditMode.Create));
        }
        public async Task CreateAccounting_WhenCalled_ReturnsPartialViewResultWhereModelIsAccountingViewModelWherePostingLinesIsNull()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.CreateAccounting();

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.PostingLines, Is.Null);
        }
        public async Task CreateAccounting_WhenCalled_ReturnsPartialViewResultWhereModelIsAccountingViewModelWhereBackDatingIsEqualTo30()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.CreateAccounting();

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.BackDating, Is.EqualTo(30));
        }
        public async Task CreateAccounting_WhenCalled_ReturnsPartialViewResultWhereModelIsAccountingViewModelWhereBalanceBelowZeroIsEqualToCreditors()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.CreateAccounting();

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.BalanceBelowZero, Is.EqualTo(BalanceBelowZeroType.Creditors));
        }
        public async Task CreateAccounting_WhenCalled_ReturnsPartialViewResultWhereModelIsAccountingViewModelWhereLetterHeadIsEqualToFirstLetterHeadFromLetterHeadCollectionFromQueryBus()
        {
            IEnumerable <ILetterHead> letterHeadCollection = _fixture.CreateMany <ILetterHead>(_random.Next(5, 10)).OrderBy(letterHead => letterHead.Number).ToList();
            Controller sut = CreateSut(letterHeadCollection);

            PartialViewResult result = (PartialViewResult)await sut.CreateAccounting();

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.LetterHead, Is.Not.Null);
            Assert.That(accountingViewModel.LetterHead.Number, Is.EqualTo(letterHeadCollection.First().Number));
        }
Example #15
0
        public void CreateAccounting_WhenAccountingViewModelIsNull_ThrowsArgumentNullException()
        {
            Controller sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.CreateAccounting(null));

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