public static void Main(string[] args) { handler = new ConsoleEventDelegate(ConsoleEventCallback); SetConsoleCtrlHandler(handler, true); IHost host = CreateHostBuilder(args).Build(); IEventBroker broker = host.Services.GetRequiredService <IEventBroker>(); // initialize evenk broker // instantiate mediators OrderingMediator mediator = host.Services.GetRequiredService <OrderingMediator>(); PaymentMediator paymentMediator = host.Services.GetRequiredService <PaymentMediator>(); // POC Task.Run(() => { Thread.Sleep(1500); IAttendant att = host.Services.GetRequiredService <IAttendant>(); att.StartOrder(b => b.WithHeader("TST123456", "9262147116", "IVG", Locale.Latvia, Lang.Lv) .WithObtainingMethod(GoodsObtainingMethod.Warehouse) .WithItems(OrderLine.Create("0141", Money.Create(10.0m, CurrencyCode.Euro))) .WithTotalValues(Money.Create(10.0m, CurrencyCode.Euro), 15.95m) .WithExtraData("Kiosk", "LRK0123456") .WithExtraData("SelectedMonth", "february 2021")); IPaymentProvider paymentProvider = host.Services.GetRequiredService <IPaymentProvider>(); ICashPaymentService cashPaymentService = host.Services.GetRequiredService <ICashPaymentService>(); // пользователь выбрал оплату кешем (не payment provider так решил, а пользователь) paymentProvider.Collect(PaymentSource.UVS, att.Order, (p) => { }); Task.Factory.StartNew(() => { Thread.Sleep(10000); att.CompleteOrder(); }); /*IStorageService s2 = host.Services.GetRequiredService<IStorageService>(); * * ICompositeDispenser dispenser = host.Services.GetRequiredService<ICompositeDispenser>(); * * ILayout layout = host.Services.GetRequiredService<ILayout>(); * if (layout == null) * { * var t = s2.Get(x => true); * } * * dispenser.OnDispensing += S1_OnDispensing; * * dispenser.Dispense(CompositDispenseAddress.Create(vendingMachineId: layout.Machines.First().Number.ToString(), layout.Machines.First().Trays.First().Belts.First().Address)); * * dispenser.OnDispensing -= S1_OnDispensing;*/ }); host.Run(); }
public void Test_StartOrder(string productId, uint qty, decimal amount) { // Prepare IAttendant vendor = GetAttendant(); Money money = Money.Create(amount, Currency); // Perform vendor.StartOrder(b => b.WithItems(OrderLine.Create(productId, qty, money, Money.Create(qty * amount, Currency))) .WithTotalValues(money)); // Post-validate Assert.NotNull(vendor.Order); Assert.NotEqual(Guid.Empty, vendor.Order.Id); }