コード例 #1
0
        public void SiteGetDescendants()
        {
            Site site = new Site();

            Assert.That(site.GetDescendants(), Is.Empty);

            Area area1 = new Area();

            site.Area.Add(area1);

            Assert.That(site.GetDescendants(), Is.Not.Empty);
            Assert.That(site.GetDescendants().Count, Is.EqualTo(1));
            Assert.That(site.GetDescendants()[0], Is.EqualTo(area1));

            WorkCentre wc2 = new WorkCentre {
                name = "WC2"
            };

            area1.WorkCentre.Add(wc2);

            Assert.That(site.GetDescendants(), Is.Not.Empty);
            Assert.That(site.GetDescendants().Count, Is.EqualTo(2));
            Assert.That(site.GetDescendants()[0], Is.EqualTo(area1));
            Assert.That(site.GetDescendants()[1], Is.EqualTo(wc2));
        }
コード例 #2
0
        public void AreaGetDescendants()
        {
            Area area = new Area();

            Assert.That(area.GetDescendants(), Is.Empty);

            WorkCentre wc1 = new WorkCentre {
                name = "WC1"
            };

            area.WorkCentre.Add(wc1);

            Assert.That(area.GetDescendants(), Is.Not.Empty);
            Assert.That(area.GetDescendants().Count, Is.EqualTo(1));
            Assert.That(area.GetDescendants()[0], Is.EqualTo(wc1));

            WorkCentre wc2 = new WorkCentre {
                name = "WC2"
            };

            area.WorkCentre.Add(wc2);

            Assert.That(area.GetDescendants(), Is.Not.Empty);
            Assert.That(area.GetDescendants().Count, Is.EqualTo(2));
            Assert.That(area.GetDescendants()[0], Is.EqualTo(wc1));
            Assert.That(area.GetDescendants()[1], Is.EqualTo(wc2));
        }
コード例 #3
0
        private Item ReadFromRow(int row, IWorksheetReader reader, Item[] history)
        {
            Item item = null;

            reader.MoveTo(row, 1);
            string firstValue = reader.Read();

            if (firstValue != string.Empty)
            {
                int depth;
                int.TryParse(firstValue, out depth);
                string isa95Type  = reader.Read();
                string isa95Class = reader.Read();

                if ((depth < 1) || (depth > 9))
                {
                    throw new InvalidOperationException("Depth must be between 1 and 9");
                }

                reader.MoveTo(row, depth + 3);
                string name = reader.Read();

                switch (isa95Type)
                {
                case "Enterprise":
                {
                    item = new Enterprise(name);
                    break;
                }

                case "Site":
                {
                    item = new Site(name);
                    break;
                }

                case "Area":
                {
                    item = new Area(name);
                    break;
                }

                case "WorkCentre":
                {
                    item = new WorkCentre(name);
                    break;
                }

                default:
                {
                    throw new InvalidOperationException("Invalid ISA95 type:" + isa95Type);
                }
                }

                history[depth] = item;
                history[depth - 1].AddItem(item);
            }
            return(item);
        }
コード例 #4
0
 public override void CommitAction()
 {
     _staff.WorkCentres.Clear();
     for (int i = 0; i < _staffWorkCentreAllocation.checkedListBox1.Items.Count; i++)
     {
         if (_staffWorkCentreAllocation.checkedListBox1.GetItemChecked(i))
         {
             WorkCentre seleted = base.GetSelectedworkCentre(_staffWorkCentreAllocation.checkedListBox1.Items[i].ToString());
             if (seleted != null)
             {
                 _staff.WorkCentres.Add(seleted);
             }
         }
     }
 }
コード例 #5
0
        public void WorkCentreGetDescendants()
        {
            WorkCentre workCentre = new WorkCentre();

            Assert.That(workCentre.GetDescendants(), Is.Empty);
        }
コード例 #6
0
        protected WorkCentre GetSelectedworkCentre(string wc)
        {
            WorkCentre workCentre = WorkCentres.Find(x => x.WorkCentreName == wc);

            return(workCentre);
        }
コード例 #7
0
        private bool FindWorkCentre(string wc)
        {
            WorkCentre workCentre = _staff.WorkCentres.Find(x => x.WorkCentreName == wc);

            return(workCentre != null);
        }
コード例 #8
0
        private Item ReadFromRow(int row, IWorksheetReader reader, Item[] history, int maxDepth)
        {
            Item item = null;

            reader.MoveTo(row, 1);

            int    depth = 1;
            string value = reader.Read();

            while (value == string.Empty && depth <= maxDepth)
            {
                depth++;
                value = reader.Read();
            }

            if (depth <= maxDepth)
            {
                string name = value;

                switch (depth)
                {
                case 1:
                {
                    item = new Enterprise(name);
                    break;
                }

                case 2:
                {
                    item = new Site(name);
                    break;
                }

                case 3:
                {
                    item = new Area(name);
                    break;
                }

                case 4:
                {
                    item = new WorkCentre(name);
                    break;
                }

                default:
                {
                    throw new InvalidOperationException("Maximum depth currently supported is 4");
                }
                }
                history[depth] = item;
                Item parent = history[depth - 1];
                if (parent == null)
                {
                    string message = string.Format("Unable to add {0} at Level {1} as there is no parent.", item,
                                                   depth);
                    throw new InvalidOperationException(message);
                }
                parent.AddItem(item);
            }
            else
            {
                reader.MoveTo(row, 1);
                if (!reader.IsEndOfData())
                {
                    string message = string.Format("Unable to read item from row {0}", row);
                    throw new InvalidOperationException(message);
                }
            }


            return(item);
        }