public async Task TryAddReservationToShowTest() { var stateManager = new MockReliableStateManager(); var showService = new ShowService(TestUtils.StatefulServiceContext, stateManager); var showId = new ItemId(new Guid("936DA01F-9ABD-4D9D-80C7-02AF85C822A8")); await showService.AddAsync(new ShowItem { Id = showId, MaxReservations = 50, Movie = "Bucks Bunny", ShowDateTime = new DateTime(2010, 10, 10, 10, 10, 10) }); var reservation = new Reservation.Domain.ReservationItem { ReservationDateTime = new DateTime(2010, 10, 10, 9, 10, 10), ShowItemId = showId }; var success = await showService.TryAddReservationToShowAsync(reservation); Assert.IsTrue(success); var added = (await showService.GetByIdAsync(showId)).Reservations.First(); Assert.AreEqual(added.Key, reservation.Id); }
public async Task TryRemoveReservationFromShowAsync() { var stateManager = new MockReliableStateManager(); var showService = new ShowService(TestUtils.StatefulServiceContext, stateManager); var showId = new ItemId(new Guid("936DA01F-9ABD-4D9D-80C7-02AF85C822A8")); await showService.AddAsync(new ShowItem { Id = showId, MaxReservations = 50, Movie = "Bucks Bunny", ShowDateTime = new DateTime(2010, 10, 10, 10, 10, 10) }); var reservation = new Reservation.Domain.ReservationItem { ReservationDateTime = new DateTime(2010, 10, 10, 9, 10, 10), ShowItemId = showId }; await showService.TryAddReservationToShowAsync(reservation); var result = await showService.TryRemoveReservationFromShowAsync(reservation); Assert.IsTrue(result); Assert.IsTrue(!(await showService.GetByIdAsync(showId)).Reservations.Any()); }
public async Task TryAddReservationToShowTest_ReservationIsPastShow() { //ARRANGE var stateManager = new MockReliableStateManager(); var showService = new ShowService(TestUtils.StatefulServiceContext, stateManager); var showId = new ItemId(new Guid("936DA01F-9ABD-4D9D-80C7-02AF85C822A8")); await showService.AddAsync(new ShowItem { Id = showId, MaxReservations = 50, Movie = "Bucks Bunny", ShowDateTime = new DateTime(2010, 10, 10, 10, 10, 10) }); var reservation = new Reservation.Domain.ReservationItem { ReservationDateTime = new DateTime(2011, 10, 10, 9, 10, 10), ShowItemId = showId }; //ACT var success = await showService.TryAddReservationToShowAsync(reservation); //ASSERT Assert.IsFalse(success); }
public async Task AddShowTest() { var stateManager = new MockReliableStateManager(); var ShowService = new ShowService(TestUtils.StatefulServiceContext, stateManager); var item = new ShowItem(); var result = await ShowService.GetByIdAsync(item.Id); Assert.AreEqual(null, result); var addResult = await ShowService.AddAsync(item); Assert.IsTrue(addResult); result = await ShowService.GetByIdAsync(item.Id); Assert.AreEqual(item, result); }
public async Task TryAddReservationToShowTest_ShowBookedOut() { var stateManager = new MockReliableStateManager(); var showService = new ShowService(TestUtils.StatefulServiceContext, stateManager); var showId = new ItemId(new Guid("936DA01F-9ABD-4D9D-80C7-02AF85C822A8")); var reservations = new ConcurrentDictionary <ItemId, Reservation.Domain.ReservationItem>(); var id1 = new ItemId(new Guid("936DA01F-9ABD-4D9D-80C7-02AF85C822B3")); var id2 = new ItemId(new Guid("936DA01F-9ABD-4D9D-80C7-02AF85C822B2")); var id3 = new ItemId(new Guid("936DA01F-9ABD-4D9D-80C7-02AF85C822B4")); reservations.TryAdd(id1, new Reservation.Domain.ReservationItem { Id = id1 }); reservations.TryAdd(id2, new Reservation.Domain.ReservationItem { Id = id2 }); reservations.TryAdd(id3, new Reservation.Domain.ReservationItem { Id = id3 }); await showService.AddAsync(new ShowItem { Id = showId, MaxReservations = 3, Movie = "Bucks Bunny", ShowDateTime = new DateTime(2010, 10, 10, 10, 10, 10), Reservations = reservations }); var reservation = new Reservation.Domain.ReservationItem { ReservationDateTime = new DateTime(2010, 10, 10, 9, 10, 10), ShowItemId = showId }; var success = await showService.TryAddReservationToShowAsync(reservation); Assert.IsFalse(success); }