public void Test_Place_Order() { TblFoodOrder OrderedFoodDetails = new TblFoodOrder() { TblRestaurantId = 10, TblCustomerId = 10, DeliveryAddress = "test address", TblFoodOrderMapping = new List <TblFoodOrderMapping>() { new TblFoodOrderMapping() { TblMenuId = 1, Price = 10000 } } }; var options = new DbContextOptionsBuilder <OrderManagementContext>() .UseInMemoryDatabase(databaseName: "OrderManagement") .Options; PlaceOrderDbAccess placeOrderDbAccess = new PlaceOrderDbAccess(new OrderManagementContext(options)); int OrderId = placeOrderDbAccess.PlaceOrder(OrderedFoodDetails); Assert.Greater(OrderId, 0); }
public void TestCheckoutListTwoBooksSqLite() { //SETUP var showlog = false; var options = SqliteInMemory.CreateOptionsWithLogging <EfCoreContext>(log => { if (showlog) { _output.WriteLine(log.Message); } }); using (var context = new EfCoreContext(options)) { context.Database.EnsureCreated(); context.SeedDatabaseFourBooks(); var dbAccess = new PlaceOrderDbAccess(context); //ATTEMPT showlog = true; var booksDict = dbAccess.FindBooksByIdsWithPriceOffers(new [] { 1, 4 }); //VERIFY booksDict.Count.ShouldEqual(2); booksDict[1].Promotion.ShouldBeNull(); booksDict[4].Promotion.ShouldNotBeNull(); } }
public PlaceOrderServiceWithVal( IRequestCookieCollection cookiesIn, IResponseCookies cookiesOut, DataContext dataContext) { IPlaceOrderDbAccess dbAccess = new PlaceOrderDbAccess(dataContext); IPlaceOrderAction placeOrderAction = new PlaceOrderAction(dbAccess); runner = new RunnerWriteDbWithValidation <PlaceOrderInDto, Order>(placeOrderAction, dataContext); checkoutCookie = new CheckoutCookie(cookiesIn, cookiesOut); }
public PlaceOrderServiceTransact( IRequestCookieCollection cookiesIn, IResponseCookies cookiesOut, DataContext dataContext) { IPlaceOrderDbAccess dbAccess = new PlaceOrderDbAccess(dataContext); PlaceOrderPart1 placeOrderPart1 = new PlaceOrderPart1(dbAccess); PlaceOrderPart2 placeOrderPart2 = new PlaceOrderPart2(dbAccess); runner = new RunnerTransact2WriteDb <PlaceOrderInDto, Part1ToPart2Dto, Order>(dataContext, placeOrderPart1, placeOrderPart2); checkoutCookie = new CheckoutCookie(cookiesIn, cookiesOut); }
public void TestCheckoutListTwoBooksSqLite() { //SETUP var inMemDb = new SqliteInMemory(); using (var context = inMemDb.GetContextWithSetup()) { context.SeedDatabaseFourBooks(); context.SaveChanges(); var dbAccess = new PlaceOrderDbAccess(context); //ATTEMPT var booksDict = dbAccess.FindBooksByIdsWithPriceOffers(new [] { 1, 4 }); //VERIFY booksDict.Count.ShouldEqual(2); booksDict[1].Promotion.ShouldBeNull(); booksDict[4].Promotion.ShouldNotBeNull(); } }
public void ExampleCodeForBook() { //SETUP var userId = Guid.NewGuid(); var options = SqliteInMemory.CreateOptions <EfCoreContext>(); using (var context = new EfCoreContext(options, new FakeUserIdService(userId))) { context.Database.EnsureCreated(); context.SeedDatabaseDummyBooks(); var lineItems = new List <OrderLineItem> { new OrderLineItem { BookId = 1, NumBooks = 4 }, new OrderLineItem { BookId = 2, NumBooks = 5 }, new OrderLineItem { BookId = 3, NumBooks = 6 } }; //ATTEMPT var dbAccess = new PlaceOrderDbAccess(context); var action1 = new PlaceOrderPart1(dbAccess); var action2 = new PlaceOrderPart2(dbAccess); var runner = new RunnerTransact2WriteDb < PlaceOrderInDto, Part1ToPart2Dto, Order>(context, action1, action2); var order = runner.RunAction(new PlaceOrderInDto(true, userId, lineItems.ToImmutableList())); //VERIFY runner.HasErrors.ShouldBeFalse(); context.Orders.Count().ShouldEqual(1); } }
public void ExampleCodeForBook() { //SETUP var inMemDb = new SqliteInMemory(); using (var context = inMemDb.GetContextWithSetup()) { context.SeedDatabaseDummyBooks(); var lineItems = new List <OrderLineItem> { new OrderLineItem { BookId = 1, NumBooks = 4 }, new OrderLineItem { BookId = 2, NumBooks = 5 }, new OrderLineItem { BookId = 3, NumBooks = 6 } }; var userId = Guid.NewGuid(); //ATTEMPT var dbAccess = new PlaceOrderDbAccess(context); var action1 = new PlaceOrderPart1(dbAccess); var action2 = new PlaceOrderPart2(dbAccess); var runner = new RunnerTransact2WriteDb < PlaceOrderInDto, Part1ToPart2Dto, Order>(context, action1, action2); var order = runner.RunAction(new PlaceOrderInDto(true, userId, lineItems.ToImmutableList())); //VERIFY runner.HasErrors.ShouldBeFalse(); context.Orders.Count().ShouldEqual(1); } }