public void Create() { // Arrange ListsController controller = new ListsController(); // Act ViewResult result = controller.Create() as ViewResult; // Assert Assert.IsNotNull(result); }
public void Test_Create() { //Arrange var controller = new ListsController(listService); //Act var result = controller.Create(newList).Result as CreatedAtRouteResult; var value = result.Value as ToDoList; //Assert Assert.IsInstanceOfType(result, typeof(CreatedAtRouteResult)); Assert.AreEqual(result.StatusCode, 201); listService.Received(1).Create(newList); Assert.AreEqual(value.Id, newList.Id); Assert.AreEqual(value.Name, newList.Name); Assert.AreEqual(value.Items.Count, newList.Items.Count); }