public void TestProcessSelectingMoreItemsThatMaxAllowed()
        {
            this.ClearAll();

            DeviceAllocationItem selectedItem1 = new DeviceAllocationItem
            {
                SerialNumber = "1234567891"
            };

            DeviceAllocationItem selectedItem2 = new DeviceAllocationItem
            {
                SerialNumber = "646446544"
            };

            this._viewModel.StockAction = ManageStockAction.Issue;
            this._viewModel.DsrStock    = new DsrStockServerResponseObject {
                MaxAllowedUnits = 6, UnitsAllocated = 5
            };

            this._viewModel.CanProcessSelectedItems = true;

            this._viewModel.OnItemSelected.Execute(selectedItem1);
            Assert.True(this._viewModel.NextButtonEnabled);
            Assert.AreEqual(1, this._viewModel.SelectedUnits.Count);

            this._viewModel.OnItemSelected.Execute(selectedItem2);
            Assert.AreEqual(2, this._viewModel.SelectedUnits.Count);
            Assert.False(this._viewModel.NextButtonEnabled);
            string errorMessage = string.Format(this._deviceResource.MoreThanMaxUnitsSelected, this._viewModel.DsrStock.MaxAllowedUnits - this._viewModel.DsrStock.UnitsAllocated);

            Assert.That(errorMessage, Is.EqualTo(this._viewModel.ErrorMessage));
        }
Пример #2
0
        private void ProcessSelectedItem(DeviceAllocationItem selectedItem)
        {
            if (!this.CanProcessSelectedItems)
            {
                return;
            }

            if (this.SelectedUnits.Contains(selectedItem))
            {
                // item is in the list, remove it.
                this.SelectedUnits.Remove(selectedItem);
            }
            else
            {
                // item is not in the list add it.
                this.SelectedUnits.Add(selectedItem);
            }

            if (this.StockAction == ManageStockAction.Issue)
            {
                this.UpdateSelectedUnitsCountStatus();
            }
            else if (this.StockAction == ManageStockAction.Receive)
            {
                this.NextButtonEnabled = this.SelectedUnits.Count > 0;
            }
        }
Пример #3
0
        public void SectionizeSelectedUnitsList()
        {
            List <DeviceAllocationItem>         devices = new List <DeviceAllocationItem>();
            List <List <DeviceAllocationItem> > groupedSelectedUnitList = this.SelectedUnits.GroupBy(u => u.ProductTypeId).Select(grp => grp.ToList()).ToList();

            foreach (List <DeviceAllocationItem> selectedUnits in groupedSelectedUnitList)
            {
                int i = 0;
                foreach (var item in selectedUnits)
                {
                    DeviceAllocationItem serials = new DeviceAllocationItem();
                    serials.ProductTypeId = item.ProductTypeId;
                    serials.Name          = item.Name;

                    if (i == 0)
                    {
                        if (this.StockAction == ManageStockAction.Issue)
                        {
                            serials.HeaderText = this.SelectedProduct.Name;
                        }
                        else
                        {
                            serials.HeaderText = item.Name;
                        }
                    }

                    serials.SerialNumber = item.SerialNumber;
                    devices.Add(serials);

                    i++;
                }
            }

            this.SelectedUnits = new ObservableCollection <DeviceAllocationItem>(devices);
        }
        public void TestProcessSelectedItemWhenIssuingStock()
        {
            this.ClearAll();
            this._viewModel.StockAction = ManageStockAction.Receive;

            DeviceAllocationItem selectedItem = new DeviceAllocationItem
            {
                SerialNumber = "1234567891"
            };

            this._viewModel.OnItemSelected.Execute(selectedItem);
            Assert.AreEqual(0, this._viewModel.SelectedUnits.Count);
        }
        public void TestCanProcessSelectedItemsIsDisabled()
        {
            this.ClearAll();

            DeviceAllocationItem selectedItem = new DeviceAllocationItem
            {
                SerialNumber = "1234567891"
            };

            this._viewModel.CanProcessSelectedItems = false;

            this._viewModel.OnItemSelected.Execute(selectedItem);
            Assert.AreEqual(0, this._viewModel.SelectedUnits.Count);
        }
        public void TestProcessSelectingAnItemForTheFirstTime()
        {
            this.ClearAll();

            DeviceAllocationItem selectedItem = new DeviceAllocationItem
            {
                SerialNumber = "123456789"
            };

            this._viewModel.CanProcessSelectedItems = true;

            this._viewModel.OnItemSelected.Execute(selectedItem);
            Assert.AreEqual(1, this._viewModel.SelectedUnits.Count);
            Assert.AreEqual(selectedItem, this._viewModel.SelectedUnits[0]);
        }
        public void TestProcessAlreadySelectedItemBeingSelectedAgain()
        {
            this.ClearAll();

            DeviceAllocationItem selectedItem = new DeviceAllocationItem
            {
                SerialNumber = "1234567891"
            };

            this._viewModel.CanProcessSelectedItems = true;

            this._viewModel.SelectedUnits.Add(selectedItem);

            this._viewModel.OnItemSelected.Execute(selectedItem);
            Assert.AreEqual(0, this._viewModel.SelectedUnits.Count);
        }