public void When_Greeted_During_Night_GreetNightView_Is_Returned() { //Arrange var mockFactory = new Moq.Mock <ITimeService>(); mockFactory.Setup(ts => ts.GetCurrentTime()).Returns(new DateTime(2013, 9, 6, 21, 0, 0)); var timeService = mockFactory.Object; var testFirstName = "Magesh"; var testLastName = "K"; var controller = new GreetingController(timeService); //Act var result = controller.Greet(testFirstName, testLastName); //Assert Assert.AreEqual("GreetNightView", result.ViewName); Assert.AreEqual("Good Night " + testLastName + ", " + testFirstName, result.ViewData["greetMsg"]); }