コード例 #1
0
        public void TestOnOrderAssignedWI()
        {
            var context = MockContextFactory.Create();


            String fakeIdentifier = "Laptop";

            var waiter = new Tablet()
            {
                Id         = 2,
                Identifier = "Karim",
                Mode       = Mode.Waiter
            };

            var testOrder = new Order()
            {
                Id           = 1,
                OrderStatus  = OrderStatus.New,
                CreationTime = new DateTime(2017, 2, 4, 17, 0, 0),
                UpdateTime   = new DateTime(2017, 2, 4, 17, 0, 0),
                Waiter       = waiter,
                Guests       = new List <Tablet>()
            };

            context.Tablet.Add(waiter);
            context.Order.Add(testOrder);
            context.SaveChanges();

            var service = new AssignOrderService(new MockDataService(context));
            var result  = service.OnOrderAssigned(fakeIdentifier, testOrder.Id);

            Assert.Equal(false, result);
        }
コード例 #2
0
ファイル: OrderHub.cs プロジェクト: hsr-waitless/backend
 public OrderHub(TableService getTablesService,
                 OrderService orderService,
                 OrderPosService orderPosService,
                 AssignOrderService assignOrderService,
                 TabletService tabletService
                 )
 {
     this.getTablesService   = getTablesService;
     this.orderService       = orderService;
     this.orderPosService    = orderPosService;
     this.assignOrderService = assignOrderService;
     this.tabletService      = tabletService;
 }
コード例 #3
0
        public void TestOrderHub()
        {
            var context            = MockContextFactory.Create();
            var getTablesService   = new TableService(new MockDataService(context));
            var orderService       = new OrderService(new MockDataService(context));
            var orderPosService    = new OrderPosService(new MockDataService(context), orderService);
            var assignOrderService = new AssignOrderService(new MockDataService(context));
            var tabletService      = new TabletService(new MockDataService(context));

            context.Table.Add(new Database.Models.Table
            {
                Id   = 12,
                Name = "Hera",
            });

            context.Tablet.Add(new Database.Models.Tablet
            {
                Id         = 7,
                Identifier = "Mira",
                Mode       = Database.Models.Mode.Guest
            });
            context.SaveChanges();

            var request = new CreateOrderRequest();

            request.TableId          = 12;
            request.TabletIdentifier = "Mira";

            var command = new Command <CreateOrderRequest>();

            command.RequestId = "123";
            command.Arguments = request;

            var called = false;

            var hub = new OrderHub(getTablesService, orderService, orderPosService, assignOrderService, tabletService);

            var responseType = "CreateOrderResponse";
            var action       = new Action <Command <CreateOrderResponse> >((response) =>
            {
                Assert.Equal(response.RequestId, command.RequestId);
                Assert.NotNull(response.Arguments.Order);
                called = true;
            });

            hub.Clients = MockHubFactory.CreateClients(responseType, action);
            hub.CreateOrderRequest(command);

            Assert.True(called);
        }