public void WriteEnterpriseSiteArea()
        {
            Hierarchy hierarchy = new Hierarchy();
            hierarchy.Enterprise = new Enterprise("My Company");
            hierarchy.Enterprise.Site.Add(new Site("My Site"));
            hierarchy.Enterprise.Site[0].Area.Add(new Area("My Area"));

            using (IExcelSpreadsheet spreadsheet = ExcelSpreadsheet.CreateNew(Filename))
            {
                HierarchyWriterCommand command = new HierarchyWriterCommand(hierarchy, spreadsheet);
                command.Execute();
            }

            using (IExcelSpreadsheet spreadsheet = ExcelSpreadsheet.OpenReadOnly(Filename))
            {
                using (IWorksheetReader reader = spreadsheet.ReadWorksheet("Hierarchy"))
                {
                    reader.MoveTo("A1");
                    Assert.That(reader.ReadRow(), Is.EquivalentTo(expectedHeader));
                    CheckRow(reader, "A2", 1, "Enterprise", string.Empty, "My Company");
                    CheckRow(reader, "A3", 2, "Site", string.Empty, "My Site");
                    CheckRow(reader, "A4", 3, "Area", string.Empty, "My Area");

                }
            }
        }
        public static Hierarchy CreateDefaultHierarchy()
        {
            var hierarchy = new Hierarchy {Enterprise = new Enterprise {name = "Enterprise", id = "enterprise"}};
            hierarchy.Enterprise.Site.Add(new Site {name = "Site A"});

            Assert.That(hierarchy.GetCount(), Is.EqualTo(2));

            return hierarchy;
        }
        public void Count()
        {
            Hierarchy hierarchy = new Hierarchy();
            Assert.That(hierarchy.GetCount(), Is.EqualTo(0));
            hierarchy.Enterprise = new Enterprise();
            Assert.That(hierarchy.GetCount(), Is.EqualTo(1));

            hierarchy.Enterprise = new Enterprise {Site = {new Site {name = "Site A", id = "enterprise.site a"}}};
            Assert.That(hierarchy.GetCount(), Is.EqualTo(2));
        }
        public void CountMultiple()
        {
            Hierarchy hierarchy = new Hierarchy
                {
                    Enterprise =
                        new Enterprise
                            {
                                name = "Enterprise",
                                id = "enterprise",
                                Site =  {new Site {name = "Site A", id = "enterprise.site a"}}
                            }
                };

            Assert.That(hierarchy.GetCount(), Is.EqualTo(2));
        }
 public SimpleHierarchyReaderCommand(IExcelSpreadsheet spreadsheet, Hierarchy hierarchy)
     : base(spreadsheet, "Hierarchy")
 {
     this.hierarchy = hierarchy;
 }
 private ICommand CreateCommand(IExcelSpreadsheet spreadsheet, Hierarchy hierarchy)
 {
     return new SimpleHierarchyReaderCommand(spreadsheet, hierarchy);
 }
 public EquipmentHierarchyCommand(Hierarchy hierarchy, XmlWriter outputWriter)
     : base(outputWriter)
 {
     this.hierarchy = hierarchy;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HierarchyWriterCommand"/> class.
 /// </summary>
 /// <param name="hierarchy">The hierarchy.</param>
 /// <param name="spreadsheet">The spreadsheet.</param>
 public HierarchyWriterCommand(Hierarchy hierarchy, IExcelSpreadsheet spreadsheet)
     : base(spreadsheet, "Hierarchy")
 {
     this.hierarchy = hierarchy;
 }
        public void Default()
        {
            Hierarchy hierarchy = new Hierarchy();
            Assert.That(hierarchy.Enterprise, Is.Null);

            Assert.That(hierarchy.GetCount(), Is.EqualTo(0));
        }
 public ValidateCommand(Hierarchy hierarchy, ValidationMessages validationMessages)
 {
     this.hierarchy = hierarchy;
     this.validationMessages = validationMessages;
 }
        public void AddItemWorkCentre()
        {
            Hierarchy hierarchy = Hierarchy.Empty();

            Assert.Throws <ArgumentException>(() => hierarchy.AddItem(new WorkCentre("Work Centre")));
        }
        public void AddItemArea()
        {
            Hierarchy hierarchy = Hierarchy.Empty();

            Assert.Throws <ArgumentException>(() => hierarchy.AddItem(new Area("Area 1")));
        }
        public void AddItemSite()
        {
            Hierarchy hierarchy = Hierarchy.Empty();

            Assert.Throws <ArgumentException>(() => hierarchy.AddItem(new Site("Site 1")));
        }
        public void AddItemNull()
        {
            Hierarchy hierarchy = Hierarchy.Empty();

            Assert.Throws <ArgumentNullException>(() => hierarchy.AddItem(null));
        }