public void ShouldHaveListOfTopicsWithNameAndColour() { var topic = new Topic {Id = 1, Colour = Color.Red, Name = "Work"}; var model = ((ViewResult) new TopicController().Index()).ViewData.Model; Assert.AreEqual(topic, ((List<Topic>) model)[0]); }
public void ShouldCreateTopicAndNotifyTheUser() { var professionalDevelopment = new Topic{Id = 3, Colour = ColorTranslator.FromHtml("#000000"), Name = "Professional Development"}; var formValues = new FormCollection { {"Id", professionalDevelopment.Id.ToString()}, {"Name", professionalDevelopment.Name}, {"Colour", professionalDevelopment.ColourInWebHex().Trim('#')} }; var controller = new TopicController(); var result = (RedirectToRouteResult) controller.Create(formValues); Assert.Contains(professionalDevelopment, Topic.Topics); Assert.AreEqual("Index", result.RouteValues["action"]); Assert.AreEqual("Your topic has been added successfully.", controller.TempData["message"]); }
public ActionResult Create(FormCollection collection) { try { // TODO: Add insert logic here var newTopic = new Topic { Id = Convert.ToInt32(collection["Id"]), Name = collection["Name"], Colour = ColorTranslator.FromHtml("#" + collection["Colour"]) }; Topic.Topics.Add(newTopic); TempData["Message"] = "Your topic has been added successfully."; return RedirectToAction("Index"); } catch { return View(); } }
public void ShouldNotBeEqualByValue() { var personalTopic = new Topic {Id = 2, Colour = Color.Red, Name = "Personal"}; Assert.AreNotEqual(_workTopic, personalTopic); }
public void ShouldConverrtColourToHexValue() { var aShadeOfRedTopic = new Topic {Colour = Color.FromArgb(0, 208, 0, 0)}; Assert.AreEqual("#D00000", aShadeOfRedTopic.ColourInWebHex()); }
public void ShouldBeEqualByValue() { var anotherWorktopic = new Topic {Id = 1, Colour = Color.White, Name = "Work"}; Assert.AreEqual(_workTopic, anotherWorktopic); }
public void Setup() { _workTopic = new Topic{Id = 1, Colour = Color.White, Name = "Work"}; }