|
| 1 | +using System; |
| 2 | +using Xunit; |
| 3 | + |
| 4 | +namespace tv.codely.Booking.Tests |
| 5 | +{ |
| 6 | + public sealed class BookingShould |
| 7 | + { |
| 8 | + [Fact] |
| 9 | + private void GetTheCorrectStatusWhenTheBookingHasNotStartedYet() |
| 10 | + { |
| 11 | + var dateBeforeBookingHasStarted = new DateTime(2020, 5, 1, 12, 0, 0); |
| 12 | + |
| 13 | + var bookingStartDate = new DateTime(2020, 6, 26, 19, 0, 0); |
| 14 | + var bookingEndDate = new DateTime(2020, 7, 14, 16, 0, 0); |
| 15 | + |
| 16 | + var booking = new Booking( |
| 17 | + new BookingId("2c1e34d0-1430-4307-80bf-a71761f71390"), |
| 18 | + bookingStartDate, |
| 19 | + bookingEndDate, |
| 20 | + new CustomerId("72cf3524-7838-45f3-8179-2e75abe5e81c"), |
| 21 | + new CustomerName("Perico Los Palotes"), |
| 22 | + new EmailAddress("perico.los.palotes@mail.com"), |
| 23 | + BookingType.VACATION, |
| 24 | + DiscountType.NONE, |
| 25 | + new DiscountValue(0), |
| 26 | + TaxType.NONE, |
| 27 | + new TaxValue(0) |
| 28 | + ); |
| 29 | + |
| 30 | + Assert.Equal(BookingStatus.NOT_STARTED, booking.StatusFor(dateBeforeBookingHasStarted)); |
| 31 | + } |
| 32 | + |
| 33 | + [Fact] |
| 34 | + private void GetTheCorrectStatusWhenTheBookingIsCurrentlyActive() |
| 35 | + { |
| 36 | + var dateBeforeBookingHasStarted = new DateTime(2020, 6, 29, 15, 0, 0); |
| 37 | + |
| 38 | + var bookingStartDate = new DateTime(2020, 6, 26, 19, 0, 0); |
| 39 | + var bookingEndDate = new DateTime(2020, 7, 14, 16, 0, 0); |
| 40 | + |
| 41 | + var booking = new Booking( |
| 42 | + new BookingId("2c1e34d0-1430-4307-80bf-a71761f71390"), |
| 43 | + bookingStartDate, |
| 44 | + bookingEndDate, |
| 45 | + new CustomerId("72cf3524-7838-45f3-8179-2e75abe5e81c"), |
| 46 | + new CustomerName("Perico Los Palotes"), |
| 47 | + new EmailAddress("perico.los.palotes@mail.com"), |
| 48 | + BookingType.VACATION, |
| 49 | + DiscountType.NONE, |
| 50 | + new DiscountValue(0), |
| 51 | + TaxType.NONE, |
| 52 | + new TaxValue(0) |
| 53 | + ); |
| 54 | + |
| 55 | + Assert.Equal(BookingStatus.ACTIVE, booking.StatusFor(dateBeforeBookingHasStarted)); |
| 56 | + } |
| 57 | + |
| 58 | + [Fact] |
| 59 | + private void GetTheCorrectStatusWhenTheBookingIsFinished() |
| 60 | + { |
| 61 | + var dateBeforeBookingHasStarted = new DateTime(2020, 8, 30, 19, 0, 0); |
| 62 | + |
| 63 | + var bookingStartDate = new DateTime(2020, 6, 26, 19, 0, 0); |
| 64 | + var bookingEndDate = new DateTime(2020, 7, 14, 16, 0, 0); |
| 65 | + |
| 66 | + var booking = new Booking( |
| 67 | + new BookingId("2c1e34d0-1430-4307-80bf-a71761f71390"), |
| 68 | + bookingStartDate, |
| 69 | + bookingEndDate, |
| 70 | + new CustomerId("72cf3524-7838-45f3-8179-2e75abe5e81c"), |
| 71 | + new CustomerName("Perico Los Palotes"), |
| 72 | + new EmailAddress("perico.los.palotes@mail.com"), |
| 73 | + BookingType.VACATION, |
| 74 | + DiscountType.NONE, |
| 75 | + new DiscountValue(0), |
| 76 | + TaxType.NONE, |
| 77 | + new TaxValue(0) |
| 78 | + ); |
| 79 | + |
| 80 | + Assert.Equal(BookingStatus.FINISHED, booking.StatusFor(dateBeforeBookingHasStarted)); |
| 81 | + } |
| 82 | + } |
| 83 | +} |
0 commit comments