コード例 #1
0
 private void btnCancel_Click(object sender, RoutedEventArgs e)
 {
     if (booking != null)
     {
         booking.Cancel();
     }
 }
コード例 #2
0
ファイル: Demo1.cs プロジェクト: happy-bits/design-patterns
        public void canceled_booking()
        {
            var view    = new MainWindow();
            var context = new BookingContext(view);

            Assert.AreEqual("New booking", view.Debug.Dequeue());
            Assert.AreEqual("New.TicketCount=0.Attendee=.", context.Debug.Dequeue());

            context.SubmitDetails("Oscar", 5);

            Assert.AreEqual("Processing Booking", view.Debug.Dequeue());
            Assert.AreEqual("Pending.TicketCount=5.Attendee=Oscar.", context.Debug.Dequeue());

            context.Cancel();

            Task.Delay(500).Wait();

            Assert.AreEqual("Processing Canceled", view.Debug.Dequeue());
            Assert.AreEqual("Closed.TicketCount=5.Attendee=Oscar.", context.Debug.Dequeue());

            AssertQueuesAreEmpty(view, context);
        }