示例#1
0
 public void NewTicket_ShouldBeNew()
 {
     var t = new Ticket();
     t.Title = "Test Ticket";
     t.Body = "Blah blah";
     Assert.True(t.Status == TicketStatus.New);
 }
示例#2
0
            public void AcceptedTicket_AbleToChangeToClosedOrRejected()
            {
                Ticket newTicket = new Ticket();
                newTicket.Accept();

                Assert.True(newTicket.IsCloseable);
                Assert.True(newTicket.IsRejectable);
            }
示例#3
0
            public void ClosedTicket_CannotChangeStatusAnymore()
            {
                Ticket newTicket = new Ticket();
                newTicket.Accept();
                newTicket.Close();

                Assert.False(newTicket.IsAcceptable);
                Assert.False(newTicket.IsRejectable);
            }
示例#4
0
            public void CannotChangeFromNewToClosed()
            {
                var t = new Ticket();

                Assert.Throws<InvalidOperationException>(() =>
                {
                    t.Close();
                });
            }
示例#5
0
        public void Sample()
        {
            var t = new Ticket();
            t.Title = "Test Ticket";
            t.Body = "Blah blah";

            app.Tickets.Add(t);
            app.SaveChanges();
        }
示例#6
0
 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");
 }
示例#8
0
 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));
 }
示例#9
0
            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());
            }
示例#10
0
            public void CannotChangeFromNewToClosed()
            {
                using (var app = new App(testing: true))
                {
                    var t = new Ticket();
                    app.Tickets.Add(t);

                    Assert.Throws<InvalidOperationException>(() =>
                    {
                        t.Close();
                    });
                }
            }
示例#11
0
            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);
                }
            }
示例#12
0
        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);
        }
示例#13
0
            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);
                }
            }
示例#14
0
            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}"));
                }
            }
示例#15
0
            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);
            }
示例#16
0
            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());
                }
            }
示例#17
0
            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);
                }
            }
示例#18
0
            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);
                }
            }
示例#19
0
            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);
                }
            }
示例#20
0
            public void NewTicket_AbleToChangeToAcceptedAndRejected_ButNotClosed()
            {
                Ticket newTicket = new Ticket();

                Assert.True(newTicket.IsAcceptable);
                Assert.False(newTicket.IsCloseable);
            }
示例#21
0
            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);
                }
            }
示例#22
0
            public void NewTicketStatus_ShouldBeNew()
            {
                Ticket newTicket = new Ticket();

                Assert.Equal(TicketStatus.New, newTicket.Status);
            }
示例#23
0
            public void RejectedTicket_CannotChangeStatusAnymore()
            {
                Ticket newTicket = new Ticket();
                newTicket.Reject("test reject");

                Assert.False(newTicket.IsRejectable);
                Assert.False(newTicket.IsCloseable);
            }