Ejemplo n.º 1
0
        public void DeleteGet_InvalidGreeting()
        {
            // Arrange - create the controller
            GreetingController target = new GreetingController(mock.Object);

            // Act - call the action method
            var      result   = (HttpNotFoundResult)target.Delete(15);
            Greeting Greeting = mock.Object.Greetings.Where(m => m.GreetingId == 1500).FirstOrDefault();

            // Assert - check the result
            Assert.IsInstanceOf(typeof(HttpNotFoundResult), result);
            Assert.IsNull(Greeting);
            Assert.AreEqual(404, result.StatusCode);
        }
Ejemplo n.º 2
0
        public void DeleteGet_ValidGreeting_CanDelete()
        {
            // Arrange - create the controller
            GreetingController target = new GreetingController(mock.Object);

            // Act - call the action method
            var result = target.Delete(5) as ViewResult;

            // Assert - check the result
            Assert.AreEqual("", result.ViewName);
            Assert.IsInstanceOf(typeof(Greeting), result.ViewData.Model);
            Assert.IsInstanceOf(typeof(ViewResult), result);
            Assert.IsNotNull(result.ViewData.Model);
        }