public void GivenACreateAction_WhenTheTicketIsInvalid_ThenRenderHomeIndexView() { var controller = GetTicketsController(new InMemoryTicketsRepository()); controller.ModelState.AddModelError("", "Name is required"); var ticket = new Ticket(); var result = controller.Create(ticket) as ViewResult; Assert.That(result.ViewName, Is.EqualTo("Index")); }
public void GivenACreateAction_WhenTheTicketIsValid_ThenItIsCreated() { var repository = new InMemoryTicketsRepository(); var controller = GetTicketsController(repository); var ticket = new Ticket { Name = "name", PhoneNumber = "phone", Description = "description", CreatedAt = new DateTime(1985, 8, 26) }; controller.Create(ticket); var tickets = repository.All(); Assert.That(tickets, Contains.Item(ticket)); }
public void Create(Ticket ticket) { _db.Add(ticket); }