Exemplo n.º 1
0
 public void Should_Have_List_Of_Topics_With_Name_And_Color()
 {
     var topic = new Topic { Id = 1, Color = Color.Red, Name = "Work" };
     var model =
         ((ViewResult)new TopicController().Index()).ViewData.Model;
     Assert.AreEqual(topic, ((List<Topic>)model)[0]);
 }
Exemplo n.º 2
0
        public ActionResult Create(FormCollection collection)
        {
            var newTopic = new Topic();
            newTopic.Id = Convert.ToInt32(collection["Id"]);
            newTopic.Name = collection["Name"];
            newTopic.Color =
                ColorTranslator.FromHtml("#" + collection["Color"]);

            Topic.Topics.Add(newTopic);
            TempData["message"] = "Your topic has been added successfully.";
            return RedirectToAction("Index");
        }
Exemplo n.º 3
0
        public void Should_Create_Topic_And_Notify_The_User()
        {
            var professionalDevelopment =
                new Topic
                {
                    Id = 3,
                    Color = ColorTranslator.FromHtml("#000000"),
                    Name = "Professional Development"
                };

            var formValues = new FormCollection();
            formValues.Add("Id", professionalDevelopment.Id.ToString());
            formValues.Add("Name",professionalDevelopment.Name);
            formValues.Add("Color",
                professionalDevelopment.ColorInWebHex().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"]);
        }
Exemplo n.º 4
0
 public void Should_Not_Be_Equal_By_Value()
 {
     var personalTopic = new Topic() {Id = 2, Color = Color.Red, Name = "Personal"};
     Assert.AreNotEqual(workTopic, personalTopic);
 }
Exemplo n.º 5
0
 public void Should_Convert_Color_To_Hex_Value()
 {
     var aShadeOfRedTopic =
         new Topic {Color = Color.FromArgb(0, 208, 0, 0)};
     Assert.AreEqual("#D00000",aShadeOfRedTopic.ColorInWebHex());
 }
Exemplo n.º 6
0
 public void Should_Be_Equal_By_Value()
 {
     var anotherWorkTopic = new Topic() {Id = 1, Color = Color.White, Name = "Work"};
     Assert.AreEqual(workTopic, anotherWorkTopic);
 }
Exemplo n.º 7
0
 public void Setup()
 {
     workTopic = new Topic {Id = 1, Color = Color.White, Name = "Work"};
 }