public void makeSeats(int num) { var seats = SeatFactory.createSeats(num); foreach (var item in seats) { this._dbContext.seats.Add(item); } this._dbContext.SaveChanges(); }
public async Task Call_suggestion_api_when_asking_for_seats_suggestions() { var showId = "666"; var party = 2; var seatSuggestionsProvider = Substitute.For <ISuggestSeats>(); var suggestionsForFirstCategory = SeatFactory.BuildSuggestions(party, PricingCategoryRequested.First, "A7-A8", "A10-A11", "B6-B7"); var suggestionsForSecondCategory = SeatFactory.BuildSuggestions(party, PricingCategoryRequested.Second, "A12-A13", "C6-C7", "D8-D9"); var suggestionsForThirdCategory = SeatFactory.BuildSuggestions(party, PricingCategoryRequested.Third, "E8-E9", "E10-E11", "E6-E7"); var suggestionsForMixedCategory = SeatFactory.BuildSuggestions(party, PricingCategoryRequested.Mixed); // to be refactor since mixed here makes no sense seatSuggestionsProvider.MakeSuggestions(showId, party).Returns(new SuggestionsMade(new ShowId(showId), new PartyRequested(party), suggestionsForFirstCategory, suggestionsForSecondCategory, suggestionsForThirdCategory, suggestionsForMixedCategory)); var pricingProvider = Substitute.For <IProvidePrices>(); pricingProvider.GetPrices(showId).Returns(new PricingMapping(110, 90, 70)); var controller = new ShowsController(Substitute.For <IProvideAuditoriumSeating>(), Substitute.For <IProvideReservedSeats>(), seatSuggestionsProvider, pricingProvider, null, null, null); var suggestions = await controller.MakeSuggestions(showId, party); Check.That(suggestions.ShowId).IsEqualTo(showId); Check.That(suggestions.PartyRequested).IsEqualTo(party); Check.That(suggestions.SuggestionsForFirstCategory) .ContainsExactly( new ShowSuggestion(showId, party, PricingCategoryRequested.First, SeatFactory.BuildSeats(PricingCategory.First, "A7", "A8"), 2 * 110), new ShowSuggestion(showId, party, PricingCategoryRequested.First, SeatFactory.BuildSeats(PricingCategory.First, "A10", "A11"), 2 * 110), new ShowSuggestion(showId, party, PricingCategoryRequested.First, SeatFactory.BuildSeats(PricingCategory.First, "B6", "B7"), 2 * 110)); Check.That(suggestions.SuggestionsForFirstCategory.Select(s => s.TotalPrice)) .ContainsExactly(2 * 110, 2 * 110, 2 * 110); Check.That(suggestions.SuggestionsForSecondCategory.Select(s => s.TotalPrice)) .ContainsExactly(2 * 90, 2 * 90, 2 * 90); Check.That(suggestions.SuggestionsForThirdCategory.Select(s => s.TotalPrice)) .ContainsExactly(2 * 70, 2 * 70, 2 * 70); Check.That(suggestions.SuggestionsForMixedCategory.Select(s => s.TotalPrice)).IsEmpty(); }
public void Be_a_ValueType() { var suggestion = new ShowSuggestion("3", 7, PricingCategoryRequested.Second, SeatFactory.BuildSeats(PricingCategory.Second, "A1", "A2")); var sameSuggestion = new ShowSuggestion("3", 7, PricingCategoryRequested.Second, SeatFactory.BuildSeats(PricingCategory.Second, "A1", "A2")); Check.That(sameSuggestion).IsEqualTo(suggestion); var sameSuggestionButWithPriceUpdated = suggestion.ComputePrice(new PricingMatrix(100, 80, 50)); Check.That(sameSuggestion).IsEqualTo(suggestion); }
public void Be_a_ValueType() { var showId = "7"; var suggestionFirstCat1 = new ShowSuggestion(showId, 2, PricingCategoryRequested.First, SeatFactory.BuildSeats(PricingCategory.Second, "A1", "A2")); var suggestionFirstCat2 = new ShowSuggestion(showId, 2, PricingCategoryRequested.First, SeatFactory.BuildSeats(PricingCategory.Second, "A1", "A2")); var suggestionSecondCat = new ShowSuggestion(showId, 2, PricingCategoryRequested.Second, SeatFactory.BuildSeats(PricingCategory.Second, "B5", "B6")); var partyRequested = 2; var showSuggestionsMade = new ShowSuggestionsMade(showId, partyRequested, new List <ShowSuggestion> { suggestionFirstCat1, suggestionFirstCat2 }, new List <ShowSuggestion> { suggestionSecondCat }, new List <ShowSuggestion>(), new List <ShowSuggestion>()); var sameShowSuggestionsMade = new ShowSuggestionsMade(showId, partyRequested, new List <ShowSuggestion> { suggestionFirstCat1, suggestionFirstCat2 }, new List <ShowSuggestion> { suggestionSecondCat }, new List <ShowSuggestion>(), new List <ShowSuggestion>()); Check.That(sameShowSuggestionsMade).IsEqualTo(showSuggestionsMade); var suggestionsMadeWithPrices = showSuggestionsMade.ComputePrices(new PricingMatrix(100, 80, 40)); Check.That(sameShowSuggestionsMade).IsEqualTo(showSuggestionsMade); Check.That(sameShowSuggestionsMade).IsNotEqualTo(suggestionsMadeWithPrices); }