Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 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"]);
        }
Ejemplo n.º 5
0
        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"]);
        }
Ejemplo n.º 6
0
        private Topic CreateTopic()
        {
            var topic = new Topic
            {
                Name = "A Greatly Debated Topic",
                Color = Color.AliceBlue
            };
            repository.SaveOrUpdate(topic);

            session.Flush();
            return topic;
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 9
0
 public void Should_Be_Equal_By_Value()
 {
     var sameSchool = new Topic {Id = 1, Color = Color.White, Name = "School"};
     Assert.AreEqual(school, sameSchool);
 }
Ejemplo n.º 10
0
 public void Setup()
 {
     school = new Topic { Id = 1, Color = Color.White, Name = "School" };
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 13
0
 public void Should_Be_Equal_By_Value()
 {
     var anotherWorkTopic = new Topic {ID = 1, Color = Color.White, Name = "work"};
     Assert.AreEqual(workTopic, anotherWorkTopic);
 }
Ejemplo n.º 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());
 }
Ejemplo n.º 15
0
 public void Setup()
 {
     workTopic = new Topic {ID = 1, Color = Color.White, Name = "work"};
 }