public void NewTicket_ShouldBeNew() { var t = new Ticket(); t.Title = "Test Ticket"; t.Body = "Blah blah"; Assert.True(t.Status == TicketStatus.New); }
public void AcceptedTicket_AbleToChangeToClosedOrRejected() { Ticket newTicket = new Ticket(); newTicket.Accept(); Assert.True(newTicket.IsCloseable); Assert.True(newTicket.IsRejectable); }
public void ClosedTicket_CannotChangeStatusAnymore() { Ticket newTicket = new Ticket(); newTicket.Accept(); newTicket.Close(); Assert.False(newTicket.IsAcceptable); Assert.False(newTicket.IsRejectable); }
public void CannotChangeFromNewToClosed() { var t = new Ticket(); Assert.Throws<InvalidOperationException>(() => { t.Close(); }); }
public void Sample() { var t = new Ticket(); t.Title = "Test Ticket"; t.Body = "Blah blah"; app.Tickets.Add(t); app.SaveChanges(); }
public void NewTicket_ableToChangeToAcceptedOrRejected_ButNotClosed() { var t = new Ticket(); t.Title = "Test Ticket"; t.Body = "Blah blah"; Assert.False(t.CanChangeTo(TicketStatus.New)); Assert.True(t.CanChangeTo(TicketStatus.Accepted)); Assert.True(t.CanChangeTo(TicketStatus.Rejected)); Assert.False(t.CanChangeTo(TicketStatus.Closed)); }
public ActionResult AddSampleTicket() { var t = new Ticket(); t.Title = "Test Ticket"; t.Body = "Blah blah"; t.LastActivityDate = DateTime.Now; app.Tickets.Add(t); app.SaveChanges(); return RedirectToAction("Index"); }
public void RejectedTicket_CannotChangeStatusAnymore() { var t = new Ticket(); t.Title = "Test Ticket"; t.Body = "Blah blah"; t.Reject(reason:"Blah hhh"); Assert.False(t.CanChangeTo(TicketStatus.New)); Assert.False(t.CanChangeTo(TicketStatus.Accepted)); Assert.False(t.CanChangeTo(TicketStatus.Rejected)); Assert.False(t.CanChangeTo(TicketStatus.Closed)); }
public void ChangeFromNewToAccepted() { var t = new Ticket(); Assert.True(t.Status == TicketStatus.New); Assert.Equal(1, t.TicketStates.Count()); t.Accept(); Assert.True(t.Status == TicketStatus.Accepted); Assert.Equal(2, t.TicketStates.Count()); }
public void CannotChangeFromNewToClosed() { using (var app = new App(testing: true)) { var t = new Ticket(); app.Tickets.Add(t); Assert.Throws<InvalidOperationException>(() => { t.Close(); }); } }
public void NewTicket_LastActivityDateShouldBeCreatedDate() { using (var app = new App(testing: true)) { var t = new Ticket(); var dt = new DateTime(2015, 1, 1, 9, 0, 0); SystemTime.SetDateTime(dt); var ticket = app.Tickets.Add(t); app.SaveChanges(); Assert.Equal(dt, ticket.LastActivityDate); } }
public ActionResult SubmitTicket(ContactUsIndexVM item) { if (ModelState.IsValid) { var t = new Ticket(); t.Title = item.Title; t.Body = item.Body; app.Tickets.Add(t); app.SaveChanges(); return RedirectToAction("Index"); } return View(item); }
public void AcceptedTicket_AbleToChangeToClosedOrRejected() { using (var app = new App(testing: true)) { var t = new Ticket(); app.Tickets.Add(t); t.Accept(); Assert.False(t.IsAcceptable); Assert.True(t.IsRejectable); Assert.True(t.IsCloseable); } }
public void NewTicket_HasCorrectId() { using (var app = new App(testing: true)) { var t = new Ticket(); t.Title = "Test Ticket"; t.Body = "Blah blah"; var ticket = app.Tickets.Add(t); app.SaveChanges(); Assert.True(Regex.IsMatch(ticket.Id, "[0-9a-f]{6}")); } }
public void ChangeFromNewToRejected() { var t = new Ticket(); Assert.True(t.Status == TicketStatus.New); Assert.Equal(1, t.TicketStates.Count()); t.Reject(reason: "test reject"); Assert.True(t.Status == TicketStatus.Rejected); Assert.Equal(2, t.TicketStates.Count()); var s2 = t.CurrentState as RejectedTicketState; Assert.Equal("test reject", s2.Reason); }
public void ChangeFromNewToAccepted() { using (var app = new App(testing: true)) { var t = new Ticket(); app.Tickets.Add(t); Assert.True(t.Status == TicketStatus.New); Assert.Equal(1, t.TicketStates.Count()); t.Accept(); Assert.True(t.Status == TicketStatus.Accepted); Assert.Equal(2, t.TicketStates.Count()); } }
public void ChangeFromNewToRejected() { using (var app = new App(testing: true)) { var t = new Ticket(); app.Tickets.Add(t); Assert.True(t.Status == TicketStatus.New); Assert.Equal(1, t.TicketStates.Count()); t.Reject(reason: "test reject"); Assert.True(t.Status == TicketStatus.Rejected); Assert.Equal(2, t.TicketStates.Count()); var s2 = t.CurrentState as RejectedTicketState; Assert.Equal("test reject", s2.Reason); } }
public void TicketMustAddToServiceBeforeUse() { // the incorrect way var t = new Ticket(); Assert.ThrowsAny<NullReferenceException>(() => { // Now, Ticket is no state! // // Cannot get status before add to service, // because we add "New" status after adding to service. // // If we add "New" status inside Ticket's constructor, // Entity Framework will always append the "New" state // to recreated Ticket. var s = t.Status; }); // the correct way using (var app = new App(testing: true)) { var t2 = new Ticket(); app.Tickets.Add(t2); Assert.NotNull(t2.Status); } }
public void NewTicketStatus_ShouldBeNew() { using (var app = new App(testing: true)) { var t = new Ticket(); app.Tickets.Add(t); Assert.Equal(TicketStatus.New, t.Status); } }
public void NewTicket_AbleToChangeToAcceptedAndRejected_ButNotClosed() { Ticket newTicket = new Ticket(); Assert.True(newTicket.IsAcceptable); Assert.False(newTicket.IsCloseable); }
public void ClosedTicket_CannotChangeStatusAnymore() { using (var app = new App(testing: true)) { var t = new Ticket(); app.Tickets.Add(t); t.Accept(); t.Close(); Assert.False(t.IsAcceptable); Assert.False(t.IsRejectable); Assert.False(t.IsCloseable); } }
public void NewTicketStatus_ShouldBeNew() { Ticket newTicket = new Ticket(); Assert.Equal(TicketStatus.New, newTicket.Status); }
public void RejectedTicket_CannotChangeStatusAnymore() { Ticket newTicket = new Ticket(); newTicket.Reject("test reject"); Assert.False(newTicket.IsRejectable); Assert.False(newTicket.IsCloseable); }