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); }
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); }
public void CanCompareNews() { var title = "title 1"; var news = new News(title); Assert.That(news, Is.EqualTo(new News(title))); }