public void setup() { mocks = new MockRepository(); builder = new TestControllerBuilder(); session = mocks.DynamicMock<ISession>(); topicRepository = mocks.StrictMock<TopicRepository>(session); topicController = new TopicController(topicRepository); builder.InitializeController(topicController); }
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"]); }