Ejemplo n.º 1
0
        public void CreateBudgetAccountGroup_WhenCalledWithoutModel_ReturnsViewResult()
        {
            Controller sut = CreateSut();

            IActionResult result = sut.CreateBudgetAccountGroup();

            Assert.That(result, Is.TypeOf <ViewResult>());
        }
Ejemplo n.º 2
0
        public void CreateBudgetAccountGroup_WhenCalledWithoutModel_ReturnsViewResultWhereViewNameIsEqualToCreateBudgetAccountGroup()
        {
            Controller sut = CreateSut();

            ViewResult result = (ViewResult)sut.CreateBudgetAccountGroup();

            Assert.That(result.ViewName, Is.EqualTo("CreateBudgetAccountGroup"));
        }
Ejemplo n.º 3
0
        public async Task CreateBudgetAccountGroup_WhenCalledWithInvalidModel_AssertPublishAsyncWasNotCalledOnCommandBus()
        {
            Controller sut = CreateSut(false);

            BudgetAccountGroupViewModel model = CreateModel();
            await sut.CreateBudgetAccountGroup(model);

            _commandBusMock.Verify(m => m.PublishAsync(It.IsAny <ICreateBudgetAccountGroupCommand>()), Times.Never);
        }
Ejemplo n.º 4
0
        public async Task CreateBudgetAccountGroup_WhenCalledWithValidModel_ReturnsRedirectToActionResultWhereActionNameIsEqualToBudgetAccountGroups()
        {
            Controller sut = CreateSut();

            BudgetAccountGroupViewModel model  = CreateModel();
            RedirectToActionResult      result = (RedirectToActionResult)await sut.CreateBudgetAccountGroup(model);

            Assert.That(result.ActionName, Is.EqualTo("BudgetAccountGroups"));
        }
Ejemplo n.º 5
0
        public async Task CreateBudgetAccountGroup_WhenCalledWithValidModel_ReturnsRedirectToActionResult()
        {
            Controller sut = CreateSut();

            BudgetAccountGroupViewModel model = CreateModel();
            IActionResult result = await sut.CreateBudgetAccountGroup(model);

            Assert.That(result, Is.TypeOf <RedirectToActionResult>());
        }
Ejemplo n.º 6
0
        public async Task CreateBudgetAccountGroup_WhenCalledWithValidModel_AssertPublishAsyncWasCalledOnCommandBus()
        {
            Controller sut = CreateSut();

            BudgetAccountGroupViewModel model = CreateModel();
            await sut.CreateBudgetAccountGroup(model);

            _commandBusMock.Verify(m => m.PublishAsync(It.Is <ICreateBudgetAccountGroupCommand>(command => command.Number == model.Number && string.CompareOrdinal(command.Name, model.Name) == 0)), Times.Once);
        }
Ejemplo n.º 7
0
        public async Task CreateBudgetAccountGroup_WhenCalledWithInvalidModel_ReturnsViewResultWhereViewNameIsEqualToCreateBudgetAccountGroup()
        {
            Controller sut = CreateSut(false);

            BudgetAccountGroupViewModel model = CreateModel();
            ViewResult result = (ViewResult)await sut.CreateBudgetAccountGroup(model);

            Assert.That(result.ViewName, Is.EqualTo("CreateBudgetAccountGroup"));
        }
Ejemplo n.º 8
0
        public async Task CreateBudgetAccountGroup_WhenCalledWithInvalidModel_ReturnsViewResultWhereModelIsEqualToInvalidModel()
        {
            Controller sut = CreateSut(false);

            BudgetAccountGroupViewModel model = CreateModel();
            ViewResult result = (ViewResult)await sut.CreateBudgetAccountGroup(model);

            Assert.That(result.Model, Is.TypeOf <BudgetAccountGroupViewModel>());

            BudgetAccountGroupViewModel budgetAccountGroupViewModel = (BudgetAccountGroupViewModel)result.Model;

            Assert.That(budgetAccountGroupViewModel, Is.EqualTo(model));
        }
Ejemplo n.º 9
0
        public void CreateBudgetAccountGroup_WhenCalledWithoutModel_ReturnsViewResultWhereModelIsBudgetAccountGroupViewModel()
        {
            Controller sut = CreateSut();

            ViewResult result = (ViewResult)sut.CreateBudgetAccountGroup();

            Assert.That(result.Model, Is.TypeOf <BudgetAccountGroupViewModel>());

            BudgetAccountGroupViewModel budgetAccountGroupViewModel = (BudgetAccountGroupViewModel)result.Model;

            Assert.That(budgetAccountGroupViewModel, Is.Not.Null);
            Assert.That(budgetAccountGroupViewModel.Number, Is.EqualTo(default(int)));
            Assert.That(budgetAccountGroupViewModel.Name, Is.Null);
            Assert.That(budgetAccountGroupViewModel.EditMode, Is.EqualTo(EditMode.Create));
        }
Ejemplo n.º 10
0
        public void CreateBudgetAccountGroup_WhenCalledWithModelWhereModelIsNull_ThrowsArgumentNullException()
        {
            Controller sut = CreateSut();

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

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