public void TestSubmenuUpdate()
        {
            var context = MockContextFactory.Create();

            var testSubmenu = new Database.Models.Submenu()
            {
                Id          = 1,
                Number      = 1,
                Name        = "Vorspeisen",
                Description = "Vorspeisen"
            };

            context.Submenu.Add(testSubmenu);
            context.SaveChanges();

            var service = new SubmenuService(new MockDataService(context));
            var result  = service.GetSubmenus(0);

            Assert.Equal("Vorspeisen", result.ElementAt(0).Name);

            testSubmenu.Name        = "Hauptspeisen";
            testSubmenu.Description = "Hauptspeisen";

            Assert.False(result.ElementAt(0).Name == "Vorspeisen");
        }
        public void TestGetSubmenues()
        {
            var builder = new DbContextOptionsBuilder <WaitlessContext>();

            builder.UseInMemoryDatabase("unittest");
            var context = new WaitlessContext(builder.Options);

            context.Submenu.Add(new Database.Models.Submenu());
            context.SaveChanges();

            var service = new SubmenuService(context);
            var result  = service.GetSubmenus(0);

            Assert.Equal(1, result.Count());
        }
        public void TestSubmenuCount()
        {
            var context = MockContextFactory.Create();

            var testSubmenu2 = new Database.Models.Submenu()
            {
                Id          = 1,
                Number      = 1,
                Name        = "Vorspeisen",
                Description = "Vorspeisen"
            };

            var testSubmenu3 = new Database.Models.Submenu()
            {
                Id          = 2,
                Number      = 2,
                Name        = "Hauptspeisen",
                Description = "Hauptspeisen"
            };

            var testSubmenu4 = new Database.Models.Submenu()
            {
                Id          = 3,
                Number      = 3,
                Name        = "Desserts",
                Description = "Desserts"
            };

            context.Submenu.Add(testSubmenu2);
            context.Submenu.Add(testSubmenu3);
            context.Submenu.Add(testSubmenu4);
            context.SaveChanges();

            var service = new SubmenuService(new MockDataService(context));
            var result  = service.GetSubmenus(0);

            Assert.Equal(3, result.Count());

            context.Submenu.Remove(testSubmenu2);
            context.SaveChanges();
            result = service.GetSubmenus(0);

            Assert.Equal(2, result.Count());
        }
        public void TestGetSubmenus()
        {
            var context = MockContextFactory.Create();

            var testSubmenu = new Database.Models.Submenu()
            {
                Id          = 1,
                Number      = 1,
                Name        = "Vorspeisen",
                Description = "Vorspeisen"
            };

            context.Submenu.Add(testSubmenu);
            context.SaveChanges();

            var service = new SubmenuService(new MockDataService(context));
            var result  = service.GetSubmenus(0);

            Assert.Equal(1, result.Count());
        }
Beispiel #5
0
        public void TestMenuHub()
        {
            var context = MockContextFactory.Create();

            var getMenuService  = new MenuService(new MockDataService(context));
            var SubmenuService  = new SubmenuService(new MockDataService(context));
            var getItemsService = new ItemTypeService(new MockDataService(context));

            context.Menu.Add(new Database.Models.Menu
            {
                Id          = 1,
                Number      = 1,
                Description = "Sommer",
                Name        = "Sommerspeisen",
            });

            var request = new GetMenuRequest();

            var command = new Command <GetMenuRequest>();

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

            var called = false;

            var hub = new MenuHub(getMenuService, SubmenuService, getItemsService);

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

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

            Assert.True(called);
        }
Beispiel #6
0
 public MenuHub(MenuService getMenuService, SubmenuService getSubMenuService, ItemTypeService getItemsService)
 {
     this.getMenuService    = getMenuService;
     this.getSubMenuService = getSubMenuService;
     this.getItemsService   = getItemsService;
 }