Exemplo n.º 1
0
        public void CanCreateNews()
        {
            var title = "new 1";
            var body = "This is bbc news blah...";
            var news = new News(title) { Body = body };

            Assert.That(news.Title, Is.EqualTo(title));
            Assert.That(news.Body, Is.EqualTo(body));
            Assert.That(news.CreatedAt, Is.Not.Null);
        }
Exemplo n.º 2
0
        public ActionResult Create(NewsFormViewModel newsViewModel)
        {
            if (ViewData.ModelState.IsValid)
            {
                var selectedCategory = newsCategoryRepository.Get(newsViewModel.SelectedCategoryId);
                var news = new News(newsViewModel.Title) { Body = newsViewModel.Body, NewsCategory = selectedCategory };
                newsRepository.SaveOrUpdate(news);
                TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = "The news was successfully created.";
                return RedirectToAction("Index");
            }

            prepareViewModel(newsViewModel);
            return View(newsViewModel);
        }
Exemplo n.º 3
0
 public void CanCompareNews()
 {
     var title = "title 1";
     var news = new News(title);
     Assert.That(news, Is.EqualTo(new News(title)));
 }