public PositionListViewModel(IDialogService dialogService, PositionListFacade positionList)
        {
            this.dialogService = dialogService;
            this.positionList  = positionList;
            positionList.LoadPositionList();
            Name = "Position List";

            #region Command Initialization
            CloseCommand            = new ActionCommand(p => CloseRequested?.Invoke(this, EventArgs.Empty));
            AddPositionCommand      = new ActionCommand(p => AddPosition());
            DeletePositionCommand   = new ActionCommand(p => DeletePosition());
            EditPositionCommand     = new ActionCommand(p => EditPosition());
            AddSizeCommand          = new ActionCommand(p => AddSize());
            DeleteSizeCommand       = new ActionCommand(p => DeleteSize());
            EditSizeCommand         = new ActionCommand(p => EditSize());
            AddIngredientCommand    = new ActionCommand(p => AddIngredient());
            DeleteIngredientCommand = new ActionCommand(p => DeleteIngredient());
            #endregion

            dataGridController = new DataGridController(positionList);

            #region Observable Collections Initialization
            Positions = new ObservableCollection <Position>();
            Sizes     = new ObservableCollection <Size>();
            #endregion
        }
        public void LoadPositionListWorks()
        {
            var facade = new PositionListFacade(new PositionListStub(), new SizeListStub(), new IngredientListStub());
            var list   = facade.LoadPositionList();

            Assert.AreEqual(new Position(1, "1", "1"), list[0]);
            Assert.AreEqual(new Position(2, "2", "2"), list[1]);
        }
Exemplo n.º 3
0
        public void AddExistedRowWorks()
        {
            var facade = new PositionListFacade(new PositionListStub(), new SizeListStub(),
                                                new IngredientListStub());
            var controller = new DataGridController(facade);

            controller.Position = facade.LoadPositionList()[0];
            controller.AddRow(new Consumable(1, "1", 1));
            Assert.AreEqual(1, controller.IngredientRows.Count);
            Assert.AreEqual("1", controller.IngredientRows.ToList()[0].Consumable);
            Assert.AreEqual(1.0, controller.IngredientRows.ToList()[0].Columns["size1"]);
        }
Exemplo n.º 4
0
        public void RemoveRowMethod_AffectsDomain()
        {
            var ingredientList = new IngredientListStub();
            var facade         = new PositionListFacade(new PositionListStub(), new SizeListStub(),
                                                        ingredientList);
            var controller = new DataGridController(facade);

            controller.Position = facade.LoadPositionList()[0];
            controller.AddRow(new Consumable(2, "2", 1));
            controller.SelectedRow = controller.IngredientRows.ToList()[0];
            controller.RemoveRow();
            Assert.AreEqual(2, ingredientList.Ingredients.Count);
        }
Exemplo n.º 5
0
        public void AddRowMethod_AffectsDomain()
        {
            var ingredientList = new IngredientListStub();
            var facade         = new PositionListFacade(new PositionListStub(), new SizeListStub(),
                                                        ingredientList);
            var controller = new DataGridController(facade);

            controller.Position = facade.LoadPositionList()[0];
            controller.AddRow(new Consumable(2, "2", 1));
            Assert.AreEqual(4, ingredientList.Ingredients.Count);
            Assert.AreEqual("2", ingredientList.Ingredients[2].Consumable.Name);
            Assert.AreEqual(0, ingredientList.Ingredients[2].Amount);
        }
Exemplo n.º 6
0
        public void FillDataGrid_fillsRowsCorrect()
        {
            var facade = new PositionListFacade(new PositionListStub(), new SizeListStub(),
                                                new IngredientListStub());
            var controller = new DataGridControllerStub(facade);

            controller.Position = facade.LoadPositionList()[0];
            var sizes = facade.GetSizeList(controller.Position);

            controller.Position.Sizes = sizes.ToImmutableList();
            controller.ClearIngredientListTest();
            controller.FillDataGridTest(sizes);
            Assert.AreEqual(1, controller.IngredientRows.Count);
            Assert.AreEqual("1", controller.IngredientRows.ToList()[0].Consumable);
            Assert.AreEqual(1.0, controller.IngredientRows.ToList()[0].Columns["size1"]);
        }
Exemplo n.º 7
0
        public void SynchroniseExistedRow()
        {
            var facade = new PositionListFacade(new PositionListStub(), new SizeListStub(),
                                                new IngredientListStub());
            var controller = new DataGridControllerStub(facade);
            var consumable = new Consumable(1, "1", 1);
            var row        = new IngredientDataGridRow()
            {
                Consumable = consumable.Name
            };

            controller.Position = facade.LoadPositionList()[0];
            controller.SynchroniseTest(row, consumable);
            Assert.AreEqual(1.0, row.Columns["size1"]);
            Assert.AreEqual(1.0, row.Columns["size2"]);
        }