예제 #1
0
        public ActionResult Create(NewBragViewModel viewModel)
        {
            var brag = new Brag
            {
                Author = this._runtimeSession.GetCurrentUser(),
                Title = viewModel.Title,
                Description = viewModel.Description,
                SubmittedOn = DateTime.Now
            };

            this._repository.Save(brag);

            return null;
        }
예제 #2
0
        public void Create_WithValidViewModel_ShouldSaveANewBrag_AndRedirectsToList()
        {
            // arrange
            var authenticatedUser = A_user_is_logged_in(1, "Amir");
            var viewModel = new NewBragViewModel
            {
                AuthorId = 1,
                Title = "Awesome thing",
                Description = "This thing I did was really awesome."
            };

            // act
            var result = this.controller.Create(viewModel);

            // assert
            repository.AssertWasCalled(r => r.Save(Arg<Brag>.Matches(b =>
                b.Author == authenticatedUser
                && b.Title == "Awesome thing")));

            // assert
            result.AssertActionRedirect().ToAction<HomeController>(c => c.Index());
        }
예제 #3
0
        public void Update_WithValidViewModel_ShouldUpdateBrag_AndRedirectsToList()
        {
            var expected = GivenIHaveABrag(1, "Update Test Title", "Update Test Desc");

            // arrange
            var authenticatedUser = A_user_is_logged_in(1, "Amir");
            var viewModel = new NewBragViewModel
            {
                Id = expected.Id,
                Title = expected.Title,
                Description = expected.Description
            };

            // act
            var result = this.controller.Update(viewModel);

            // assert
            repository.AssertWasCalled(r => r.Save(Arg<Brag>.Matches(b =>
                b.Title == expected.Title
                && b.Description == expected.Description)));

            // assert
            result.AssertActionRedirect().ToAction<HomeController>(c => c.Index());
        }
예제 #4
0
        public ActionResult New()
        {
            var vm = new NewBragViewModel();

            return View(vm);
        }