public void Shoud_Have_A_List_Od_Topic_With_Name_And_Color()
 {
     var list = new List<Topic>();
     var topic = new Topic { ID = 1, Color = Color.Red, Name = "Work" };
     object model = ((ViewResult)new TopicController().Index()).Model;
     Assert.AreEqual(list, model);
 }
Example #2
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                var newTopic = new Topic();
                newTopic.Name = collection["Name"];
                newTopic.Color = ColorTranslator.FromHtml("#" + collection["Color"]);

                topicRepository.SaveOrUpdate(newTopic);

                TempData["message"] = "Your topic has been added successfully.";
                return RedirectToAction("Index");
            }
            catch (Exception e)
            {
                return View();
            }
        }
Example #3
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                var newTopic = new Topic();
                newTopic.ID = Convert.ToInt32(collection["ID"]);
                newTopic.Name = collection["Name"];
                newTopic.Color = ColorTranslator.FromHtml("#" + collection["Color"]);

                TopicSource.Topics.Add(newTopic);
                TempData["Message"] = "Your topic has been successfully.";
                return RedirectToAction("Index");

            }
            catch
            {
                return View();
            }
        }
Example #4
0
        public void Should_Add_A_Topic_When_Create_With_Post_Is_Called_And_Notify_The_User()
        {
            var professionalDevelopment = new Topic {Id = 3,
                Color = ColorTranslator.FromHtml("#000000"), Name = "Professional Development"};

            var collection = new FormCollection();
            collection.Add("Id", professionalDevelopment.Id.ToString());
            collection.Add("Name", professionalDevelopment.Name);
            collection.Add("Color", ColorTranslator.ToHtml(professionalDevelopment.Color).Trim('#'));

            topicRepository.SaveOrUpdate(professionalDevelopment);
            LastCall.IgnoreArguments();
            mocks.ReplayAll();

            var result = (RedirectToRouteResult) topicController.Create(collection);

            mocks.VerifyAll();

            Assert.AreEqual("Index", result.RouteValues["action"]);
            Assert.AreEqual("Your topic has been added successfully.", topicController.TempData["message"]);
        }
        public void Should_Create_Topic_And_Notify_The_User()
        {
            var PerofessionalDevelopment = new Topic
                {
                    ID = 3
                    ,
                    Color = ColorTranslator.FromHtml("#000000"),
                    Name = "Perofessional Development"
                };

            var formValue = new FormCollection();
            formValue.Add("ID", PerofessionalDevelopment.ID.ToString());
            formValue.Add("Name", PerofessionalDevelopment.Name);
            formValue.Add("Color", PerofessionalDevelopment.ColorInWebHex().Trim('#'));

            var controller = new TopicController();

            var result = (RedirectToRouteResult)controller.Create(formValue);

            Assert.Contains(PerofessionalDevelopment, TopicSource.Topics);
            Assert.AreEqual("Index", result.RouteValues["action"]);
            Assert.AreEqual("Your topic has been successfully.", controller.TempData["Message"]);
        }
Example #6
0
        private Topic CreateTopic()
        {
            var topic = new Topic
            {
                Name = "A Greatly Debated Topic",
                Color = Color.AliceBlue
            };
            repository.SaveOrUpdate(topic);

            session.Flush();
            return topic;
        }
Example #7
0
        public void Should_Convert_A_Thought_Into_A_Todo_And_Redirect_To_Process_Thought()
        {
            var homeTopic = new Topic { Name = "Home" };

            var todo = new Todo
                           {
                               Title = "Do Laundry",
                               Outcome = "Laundry is clean and put away",
                               Topic = homeTopic
                           };

            var thought = new Thought { Id= 22, Name = "Do Laundry", Topic = homeTopic };

            Expect.Call(topicRepository.GetAll()).Return(new List<Topic> {homeTopic});
            Expect.Call(thoughtRepository.GetAll()).Return(new List<Thought> { thought });

            todoRepository.SaveOrUpdate(todo);
            LastCall.IgnoreArguments();;

            thoughtRepository.Delete(thought);
            LastCall.IgnoreArguments();

            mocks.ReplayAll();

            var result = (RedirectToRouteResult)
                         todoController.Convert(thought, "Laundry is clean and put away");

            Assert.AreEqual("Process", result.RouteValues["action"]);
            Assert.AreEqual("Thought", result.RouteValues["controller"]);

            mocks.VerifyAll();
        }
Example #8
0
 public void Should_Not_Be_Equal_By_Value()
 {
     var renovation = new Topic { Id = 2, Color = Color.White, Name = "Renovation" };
     Assert.AreNotEqual(school, renovation);
 }
Example #9
0
 public void Should_Be_Equal_By_Value()
 {
     var sameSchool = new Topic {Id = 1, Color = Color.White, Name = "School"};
     Assert.AreEqual(school, sameSchool);
 }
Example #10
0
 public void Setup()
 {
     school = new Topic { Id = 1, Color = Color.White, Name = "School" };
 }
Example #11
0
 public virtual bool Equals(Topic other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other.Id == Id && other.Color.Equals(Color) && Equals(other.Name, Name);
 }
Example #12
0
 public void Should_Not_Be_Equal_By_Value()
 {
     var anotherWorkTopic = new Topic {ID = 1, Color = Color.DarkRed, Name = "Personal"};
     Assert.AreNotEqual(workTopic, anotherWorkTopic);
 }
Example #13
0
 public void Should_Be_Equal_By_Value()
 {
     var anotherWorkTopic = new Topic {ID = 1, Color = Color.White, Name = "work"};
     Assert.AreEqual(workTopic, anotherWorkTopic);
 }
Example #14
0
 public void Sholud_Convert_Color_To_Hex_Value()
 {
     var aShadeOfRedTopic =
         new Topic {Color = Color.FromArgb(0, 208, 0, 0)};
     Assert.AreEqual("#D00000", aShadeOfRedTopic.ColorInWebHex());
 }
Example #15
0
 public void Setup()
 {
     workTopic = new Topic {ID = 1, Color = Color.White, Name = "work"};
 }