public void AddChildNodesToGroupTest()
        {
            Application application = new Application();

            try
            {
                // Where ever we are creating object for WorkflowController_Accessor, we need to set the ThisAddIn_Accessor.ExcelApplication to
                // wither null or actual application object.
                ThisAddIn_Accessor.ExcelApplication = application;

                Group childGroup = new Group("Earth", GroupType.ReferenceFrame, null);
                Layer layer = new Layer();
                layer.Name = "Layer1";
                layer.Group = childGroup;
                LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
                localLayerMap.MapType = LayerMapType.Local;

                GroupChildren groupChild = LayerMapExtensions_Accessor.AddChildNodesToGroup(localLayerMap);
                Assert.AreEqual("Earth", groupChild.Name);
                Assert.AreEqual(1, groupChild.AllChildren.Count);
                Assert.AreEqual(1, groupChild.Layers.Count);
                foreach (Layer layerVal in groupChild.Layers)
                {
                    Assert.AreEqual("Layer1", layerVal.Name);
                }
            }
            finally
            {
                application.Close();
            }
        }
        public void OnLayerSelectionChangedEventTest()
        {
            LayerDetailsViewModel_Accessor target = new LayerDetailsViewModel_Accessor();
            Layer layer = new Layer();

            layer.Name      = "Layer1";
            layer.StartTime = DateTime.Now;

            LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);

            localLayerMap.MapType          = LayerMapType.Local;
            localLayerMap.RangeDisplayName = "Sheet_1";
            localLayerMap.HeaderRowData    = new Collection <string>();
            localLayerMap.HeaderRowData.Add("Lat");

            localLayerMap.MappedColumnType = new Collection <ColumnType>();
            localLayerMap.MappedColumnType.Add(ColumnType.RA);
            target.currentLayer = localLayerMap;

            object    sender = localLayerMap;
            EventArgs e      = null;

            target.OnLayerSelectionChangedEvent(sender, e);

            Assert.AreEqual("Layer1", target.SelectedLayerText);
        }
示例#3
0
        public void AddChildNodesToGroupTest()
        {
            Application application = new Application();

            try
            {
                // Where ever we are creating object for WorkflowController_Accessor, we need to set the ThisAddIn_Accessor.ExcelApplication to
                // wither null or actual application object.
                ThisAddIn_Accessor.ExcelApplication = application;

                Group childGroup = new Group("Earth", GroupType.ReferenceFrame, null);
                Layer layer      = new Layer();
                layer.Name  = "Layer1";
                layer.Group = childGroup;
                LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
                localLayerMap.MapType = LayerMapType.Local;

                GroupChildren groupChild = LayerMapExtensions_Accessor.AddChildNodesToGroup(localLayerMap);
                Assert.AreEqual("Earth", groupChild.Name);
                Assert.AreEqual(1, groupChild.AllChildren.Count);
                Assert.AreEqual(1, groupChild.Layers.Count);
                foreach (Layer layerVal in groupChild.Layers)
                {
                    Assert.AreEqual("Layer1", layerVal.Name);
                }
            }
            finally
            {
                application.Close();
            }
        }
        public void OnMapColumnSelectionChangedEventRAGeoTest()
        {
            LayerDetailsViewModel_Accessor target = new LayerDetailsViewModel_Accessor();

            ColumnViewModel columnView = new ColumnViewModel();

            columnView.ExcelHeaderColumn = "RA";
            columnView.WWTColumns        = new ObservableCollection <Column>();
            ColumnExtensions.PopulateColumnList().ToList().ForEach(col => columnView.WWTColumns.Add(col));
            columnView.SelectedWWTColumn = columnView.WWTColumns.Where(column => column.ColType == ColumnType.RA).FirstOrDefault();

            target.ColumnsView = new ObservableCollection <ColumnViewModel>();
            target.ColumnsView.Add(columnView);

            target.sizeColumnList = new ObservableCollection <System.Collections.Generic.KeyValuePair <int, string> >();
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(0, "LAT"));
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(1, "MAG"));
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(2, "LONG"));
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(3, "DEPTH"));

            target.hoverTextColumnList = new ObservableCollection <System.Collections.Generic.KeyValuePair <int, string> >();
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(0, "LAT"));
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(1, "MAG"));
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(2, "LONG"));
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(3, "DEPTH"));

            Layer layer = new Layer();

            layer.Name      = "Layer1";
            layer.StartTime = DateTime.Now;

            LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);

            localLayerMap.MapType          = LayerMapType.Local;
            localLayerMap.RangeDisplayName = "Sheet_1";
            target.currentLayer            = localLayerMap;

            EventArgs e = null;

            target.OnMapColumnSelectionChanged(columnView, e);

            Assert.AreEqual(true, target.isMarkerTabEnabled);
            Assert.AreEqual(false, target.isDistanceVisible);
            Assert.AreEqual(true, target.IsRAUnitVisible);
            Assert.AreEqual(AngleUnit.Hours, target.selectedRAUnit.Key);

            columnView.SelectedWWTColumn = columnView.WWTColumns.Where(column => column.ColType == ColumnType.Geo).FirstOrDefault();

            target.ColumnsView = new ObservableCollection <ColumnViewModel>();
            target.ColumnsView.Add(columnView);

            target.OnMapColumnSelectionChanged(columnView, e);
            Assert.AreEqual(true, target.isMarkerTabEnabled);
            Assert.AreEqual(false, target.isDistanceVisible);
            Assert.AreEqual(false, target.IsRAUnitVisible);
        }
示例#5
0
        public void AddLayerNodeTest()
        {
            Application application = new Application();

            try
            {
                // Where ever we are creating object for WorkflowController_Accessor, we need to set the ThisAddIn_Accessor.ExcelApplication to
                // wither null or actual application object.
                ThisAddIn_Accessor.ExcelApplication = application;
                List <GroupChildren> groups       = new List <GroupChildren>();
                List <GroupChildren> nestedGroups = new List <GroupChildren>();

                Group parentGroup = new Group("Earth", GroupType.ReferenceFrame, null);
                Layer layer       = new Layer();
                layer.Name  = "Layer1";
                layer.Group = parentGroup;

                LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
                localLayerMap.MapType          = LayerMapType.Local;
                localLayerMap.RangeDisplayName = "Sheet_1";

                Group childGroup  = new Group("Earth", GroupType.ReferenceFrame, parentGroup);
                Layer nestedLayer = new Layer();
                nestedLayer.Name  = "Layer1";
                nestedLayer.Group = childGroup;

                LayerMap_Accessor nestedLayerMap = new LayerMap_Accessor(nestedLayer);
                nestedLayerMap.MapType          = LayerMapType.Local;
                nestedLayerMap.RangeDisplayName = "Sheet_1";

                LayerMapExtensions_Accessor.AddLayerNode(groups, localLayerMap);
                LayerMapExtensions_Accessor.AddLayerNode(nestedGroups, nestedLayerMap);

                Assert.AreEqual(1, groups.Count);
                foreach (GroupChildren group in groups)
                {
                    Assert.AreEqual("Earth", group.Name);
                    Assert.AreEqual(1, group.AllChildren.Count);
                    foreach (LayerMap layerVal in group.AllChildren)
                    {
                        Assert.AreEqual("Layer1", layerVal.LayerDetails.Name);
                    }
                }

                Assert.AreEqual(1, nestedGroups.Count);
                foreach (GroupChildren group in nestedGroups)
                {
                    Assert.AreEqual("Earth", group.Name);
                    Assert.AreEqual(1, group.Children.Count);
                }
            }
            finally
            {
                application.Close();
            }
        }
        public void OnGroupSelectionChangedTest()
        {
            LayerDetailsViewModel_Accessor target = new LayerDetailsViewModel_Accessor();
            Group group    = new Group("Sun", GroupType.ReferenceFrame, null);
            Group skyGroup = new Group("Sky", GroupType.ReferenceFrame, null);
            Layer layer    = new Layer();

            layer.Name      = "Layer1";
            layer.StartTime = DateTime.Now;

            LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);

            localLayerMap.MapType          = LayerMapType.Local;
            localLayerMap.RangeDisplayName = "Sheet_1";
            localLayerMap.HeaderRowData    = new Collection <string>();
            localLayerMap.HeaderRowData.Add("Lat");

            localLayerMap.MappedColumnType = new Collection <ColumnType>();
            localLayerMap.MappedColumnType.Add(ColumnType.RA);
            target.currentLayer = localLayerMap;

            ColumnViewModel columnView = new ColumnViewModel();

            columnView.ExcelHeaderColumn = "RA";
            columnView.WWTColumns        = new ObservableCollection <Column>();
            ColumnExtensions.PopulateColumnList().ToList().ForEach(col => columnView.WWTColumns.Add(col));
            columnView.SelectedWWTColumn = columnView.WWTColumns.Where(column => column.ColType == ColumnType.RA).FirstOrDefault();

            target.ColumnsView = new ObservableCollection <ColumnViewModel>();
            target.ColumnsView.Add(columnView);

            target.selectedScaleType = new System.Collections.Generic.KeyValuePair <ScaleType, string>(ScaleType.StellarMagnitude, "StellarMagnitude");

            object    sender = group;
            EventArgs e      = null;

            target.OnGroupSelectionChanged(sender, e);

            Assert.AreEqual(false, target.isRAUnitVisible);
            Assert.AreEqual("Sun", target.selectedGroupText);
            Assert.AreEqual(ScaleType.Power, target.selectedScaleType.Key);

            sender = skyGroup;
            target.OnGroupSelectionChanged(sender, e);
            Assert.AreEqual(ScaleType.StellarMagnitude, target.selectedScaleType.Key);
        }
示例#7
0
        public void SetMappingOnSizeColumnTest()
        {
            Collection <ColumnType> mappedColTypes = new Collection <ColumnType>();

            mappedColTypes.Add(ColumnType.RA);
            mappedColTypes.Add(ColumnType.Dec);
            mappedColTypes.Add(ColumnType.None);
            mappedColTypes.Add(ColumnType.Long);

            Layer layer = new Layer();

            layer.Name       = "Layer1";
            layer.StartTime  = DateTime.Now;
            layer.SizeColumn = 2;

            LayerMap_Accessor layerMapAccessor = new LayerMap_Accessor(layer);

            layerMapAccessor.MappedColumnType = mappedColTypes;

            Assert.AreEqual(mappedColTypes[2], ColumnType.None);
            layerMapAccessor.SetMappingOnSizeColumn();
            Assert.AreEqual(mappedColTypes[2], ColumnType.Mag);
        }
        public void OnUpdateLayerClickedEventTest()
        {
            Application application = new Application();

            try
            {
                Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false);
                WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);
                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");
                target.OnWorkbookOpen(book);

                Name targetRangeName = book.Names.GetNamedRange("UpdateLayerRangeInitial");

                WorkbookMap_Accessor workbookMap = Microsoft.Research.Wwt.Excel.Addin.WorkbookExtensions_Accessor.GetWorkbookMap(book);
                LayerMap_Accessor layerMap = new LayerMap_Accessor(targetRangeName);

                workbookMap.SelectedLayerMap = layerMap;
                target.currentWorkbookMap = workbookMap;

                Range updateRangeFinal = targetRangeName.RefersToRange.Worksheet.get_Range("A1:F15");
                updateRangeFinal.Select();
                target.OnUpdateLayerClickedEvent(this, new EventArgs());

                Assert.AreEqual("$A$1:$F$15", target.currentWorkbookMap.SelectedLayerMap.RangeName.RefersToRange.Address);
            }
            finally
            {
                application.Close();
            }
        }
        public void SetGetLayerDataDisplayNameTest()
        {
            WorkflowController_Accessor target = GetWorkflowControllerAccessor(null);
            Layer layer = new Layer();

            LayerMap_Accessor selectedLayerMap = new LayerMap_Accessor(layer);
            target.layerDetailsViewModel = new LayerDetailsViewModel();

            // When MapType is Local/WWT, LayerDataDisplayName will be "Get Layer Data";
            string actual = "Get Layer Data";
            selectedLayerMap.MapType = LayerMapType.Local;
            target.SetGetLayerDataDisplayName(selectedLayerMap);

            string expected = target.layerDetailsViewModel.LayerDataDisplayName;

            Assert.AreEqual(actual, expected);

            // When MapType is LocalInWWT, LayerDataDisplayName will be "Refresh";
            actual = "Refresh";
            selectedLayerMap.MapType = LayerMapType.LocalInWWT;
            target.SetGetLayerDataDisplayName(selectedLayerMap);

            expected = target.layerDetailsViewModel.LayerDataDisplayName;

            Assert.AreEqual(actual, expected);
        }
        public void OnViewInWWTClickedTest()
        {
            Application application = new Application();
            bool createdWtmlKey = false;

            try
            {
                // .wtml registry key is needed to be there for this test case to pass. Key will be created and deleted, if it doesn't exist.
                createdWtmlKey = CreateWwtKeyIfNotExists();
                Workbook book = application.OpenWorkbook("TestData.xlsx", false);
                WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);

                target.currentWorkbookMap = new WorkbookMap_Accessor(book);

                // Get the named range stored in the test data excel file.
                Name name = book.Names.GetNamedRange("ColumnList");
                Group parentGroup = new Group("Sun", GroupType.ReferenceFrame, null);

                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");

                string layerId = "2cf4374f-e1ce-47a9-b08c-31079765ddcf";
                LayerMap_Accessor localLayerMap = new LayerMap_Accessor(name);
                localLayerMap.LayerDetails.Name = "Layer1";
                localLayerMap.LayerDetails.ID = layerId;
                localLayerMap.LayerDetails.Group = parentGroup;
                localLayerMap.MapType = LayerMapType.LocalInWWT;

                parentGroup.LayerIDs.Add(layerId);

                LayerMap currentlayer = new LayerMap(name);
                currentlayer.LayerDetails.Name = "Layer2";
                currentlayer.LayerDetails.ID = layerId;
                currentlayer.LayerDetails.Group = parentGroup;
                currentlayer.MapType = LayerMapType.LocalInWWT;

                currentlayer.HeaderRowData = new Collection<string>();
                currentlayer.HeaderRowData.Add("LAT");
                currentlayer.HeaderRowData.Add("Long");
                currentlayer.HeaderRowData.Add("Depth");

                target.layerDetailsViewModel = new LayerDetailsViewModel();
                target.layerDetailsViewModel.Currentlayer = currentlayer;
                target.layerDetailsViewModel.SelectedLayerName = "Layer1";

                Collection<ColumnType> mappedType = new Collection<ColumnType>();
                mappedType.Add(ColumnType.Lat);
                mappedType.Add(ColumnType.Long);
                mappedType.Add(ColumnType.Depth);

                target.currentWorkbookMap.SelectedLayerMap = localLayerMap;
                target.currentWorkbookMap.SelectedLayerMap.MappedColumnType = mappedType;

                EventArgs e = null;
                target.OnViewInWWTClicked(null, e);
                string expected = "Layer1 (linked)";

                Assert.AreEqual(layerId, target.currentWorkbookMap.SelectedLayerMap.LayerDetails.ID);
                Assert.AreEqual(expected, target.layerDetailsViewModel.SelectedLayerText);
                Assert.AreEqual(false, target.layerDetailsViewModel.IsViewInWWTEnabled);
                Assert.AreEqual(false, target.layerDetailsViewModel.IsCallOutVisible);
                Assert.AreEqual(true, target.layerDetailsViewModel.IsGetLayerDataEnabled);
                Assert.AreEqual(false, target.layerDetailsViewModel.IsReferenceGroupEnabled);
                Assert.AreEqual("Refresh", target.layerDetailsViewModel.LayerDataDisplayName);

                localLayerMap.LayerDetails.ID = string.Empty;
                localLayerMap.MapType = LayerMapType.Local;
                target.OnViewInWWTClicked(null, e);

                Assert.AreEqual(layerId, target.currentWorkbookMap.SelectedLayerMap.LayerDetails.ID);
                Assert.AreEqual(expected, target.layerDetailsViewModel.SelectedLayerText);
                Assert.AreEqual(false, target.layerDetailsViewModel.IsViewInWWTEnabled);
                Assert.AreEqual(false, target.layerDetailsViewModel.IsCallOutVisible);
                Assert.AreEqual(true, target.layerDetailsViewModel.IsGetLayerDataEnabled);
                Assert.AreEqual(false, target.layerDetailsViewModel.IsReferenceGroupEnabled);
                Assert.AreEqual("Refresh", target.layerDetailsViewModel.LayerDataDisplayName);
            }
            finally
            {
                application.Close();
                if (createdWtmlKey)
                {
                    // Delete the registry key if it is created by this test case.
                    Registry.ClassesRoot.DeleteSubKey(@".wtml", false);
                }
            }
        }
        public void OnCustomTaskPaneChangedStateTest()
        {
            Application application = new Application();

            try
            {
                Workbook book = application.OpenWorkbook("TestData.xlsx", false);

                WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);
                target.currentWorkbookMap = new WorkbookMap_Accessor(book);

                // Get the named range stored in the test data excel file.
                Name name = book.Names.GetNamedRange("ColumnList");
                Group parentGroup = new Group("Sun", GroupType.ReferenceFrame, null);

                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");

                LayerMap_Accessor localLayerMap = new LayerMap_Accessor(name);
                localLayerMap.LayerDetails.Name = "Layer";
                localLayerMap.LayerDetails.Group = parentGroup;
                localLayerMap.MapType = LayerMapType.LocalInWWT;

                target.currentWorkbookMap.SelectedLayerMap = localLayerMap;
                target.layerDetailsViewModel = new LayerDetailsViewModel();

                target.layerDetailsViewModel.ColumnsView = new System.Collections.ObjectModel.ObservableCollection<ColumnViewModel>();
                target.layerDetailsViewModel.ColumnsView.Add(new ColumnViewModel()
                {
                    ExcelHeaderColumn = "Header",
                    SelectedWWTColumn = new Column(ColumnType.Alt, "ss", new System.Collections.ObjectModel.Collection<string>() { "s" })
                });

                LayerMap currentLayer = new LayerMap(name);
                currentLayer.LayerDetails.Name = "Layer";
                currentLayer.LayerDetails.Group = parentGroup;
                currentLayer.MapType = LayerMapType.LocalInWWT;

                target.layerDetailsViewModel.Currentlayer = currentLayer;
                target.layerDetailsViewModel.SelectedLayerName = "Layer1";
                target.layerDetailsViewModel.SelectedGroup = parentGroup;
                target.layerDetailsViewModel.IsDistanceVisible = true;
                target.layerDetailsViewModel.SelectedDistanceUnit = new KeyValuePair<AltUnit, string>(AltUnit.AstronomicalUnits, "Alt");
                target.layerDetailsViewModel.IsRAUnitVisible = true;
                target.layerDetailsViewModel.SelectedFadeType = new KeyValuePair<FadeType, string>(FadeType.Both, "f");
                target.layerDetailsViewModel.SelectedScaleType = new KeyValuePair<ScaleType, string>(ScaleType.Constant, "Constant");
                target.layerDetailsViewModel.SelectedScaleRelative = new KeyValuePair<ScaleRelativeType, string>(ScaleRelativeType.Screen, "Screen");
                target.layerDetailsViewModel.ScaleFactor.SelectedSliderValue = 10;
                target.layerDetailsViewModel.LayerOpacity.SelectedSliderValue = 10;
                target.layerDetailsViewModel.SelectedSize = new KeyValuePair<int, string>(1, "2");
                target.layerDetailsViewModel.SelectedHoverText = new KeyValuePair<int, string>(1, "2");

                object sender = null;
                EventArgs e = null;
                target.OnCustomTaskPaneChangedState(sender, e);

                Assert.AreEqual(target.currentWorkbookMap.SelectedLayerMap.LayerDetails.Group, parentGroup);
                Assert.AreEqual(target.currentWorkbookMap.SelectedLayerMap.name, localLayerMap.name);
                Assert.AreEqual(target.currentWorkbookMap.SelectedLayerMap.LayerDetails.AltUnit, target.layerDetailsViewModel.SelectedDistanceUnit.Key);
                Assert.AreEqual(target.currentWorkbookMap.SelectedLayerMap.LayerDetails.FadeType, target.layerDetailsViewModel.SelectedFadeType.Key);
                Assert.AreEqual(target.currentWorkbookMap.SelectedLayerMap.LayerDetails.PointScaleType, target.layerDetailsViewModel.SelectedScaleType.Key);
                Assert.AreEqual(target.currentWorkbookMap.SelectedLayerMap.LayerDetails.MarkerScale, target.layerDetailsViewModel.SelectedScaleRelative.Key);
                Assert.AreEqual(target.currentWorkbookMap.SelectedLayerMap.LayerDetails.ScaleFactor, 0.125);
                Assert.AreEqual(target.currentWorkbookMap.SelectedLayerMap.LayerDetails.Opacity, target.layerDetailsViewModel.LayerOpacity.SelectedSliderValue / 100);
                Assert.AreEqual(target.currentWorkbookMap.SelectedLayerMap.LayerDetails.SizeColumn, target.layerDetailsViewModel.SelectedSize.Key);
            }
            finally
            {
                application.Close();
            }
        }
示例#12
0
        public void SetMappingOnSizeColumnTest()
        {
            Collection<ColumnType> mappedColTypes = new Collection<ColumnType>();
            mappedColTypes.Add(ColumnType.RA);
            mappedColTypes.Add(ColumnType.Dec);
            mappedColTypes.Add(ColumnType.None);
            mappedColTypes.Add(ColumnType.Long);

            Layer layer = new Layer();
            layer.Name = "Layer1";
            layer.StartTime = DateTime.Now;
            layer.SizeColumn = 2;

            LayerMap_Accessor layerMapAccessor = new LayerMap_Accessor(layer);
            layerMapAccessor.MappedColumnType = mappedColTypes;

            Assert.AreEqual(mappedColTypes[2], ColumnType.None);
            layerMapAccessor.SetMappingOnSizeColumn();
            Assert.AreEqual(mappedColTypes[2], ColumnType.Mag);
        }
        public void OnMapColumnSelectionChangedEventRAGeoTest()
        {
            LayerDetailsViewModel_Accessor target = new LayerDetailsViewModel_Accessor();

            ColumnViewModel columnView = new ColumnViewModel();
            columnView.ExcelHeaderColumn = "RA";
            columnView.WWTColumns = new ObservableCollection<Column>();
            ColumnExtensions.PopulateColumnList().ToList().ForEach(col => columnView.WWTColumns.Add(col));
            columnView.SelectedWWTColumn = columnView.WWTColumns.Where(column => column.ColType == ColumnType.RA).FirstOrDefault();

            target.ColumnsView = new ObservableCollection<ColumnViewModel>();
            target.ColumnsView.Add(columnView);

            target.sizeColumnList = new ObservableCollection<System.Collections.Generic.KeyValuePair<int, string>>();
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(0, "LAT"));
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(1, "MAG"));
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(2, "LONG"));
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(3, "DEPTH"));

            target.hoverTextColumnList = new ObservableCollection<System.Collections.Generic.KeyValuePair<int, string>>();
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(0, "LAT"));
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(1, "MAG"));
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(2, "LONG"));
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(3, "DEPTH"));

            Layer layer = new Layer();
            layer.Name = "Layer1";
            layer.StartTime = DateTime.Now;

            LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
            localLayerMap.MapType = LayerMapType.Local;
            localLayerMap.RangeDisplayName = "Sheet_1";
            target.currentLayer = localLayerMap;

            EventArgs e = null;
            target.OnMapColumnSelectionChanged(columnView, e);

            Assert.AreEqual(true, target.isMarkerTabEnabled);
            Assert.AreEqual(false, target.isDistanceVisible);
            Assert.AreEqual(true, target.IsRAUnitVisible);
            Assert.AreEqual(AngleUnit.Hours, target.selectedRAUnit.Key);

            columnView.SelectedWWTColumn = columnView.WWTColumns.Where(column => column.ColType == ColumnType.Geo).FirstOrDefault();

            target.ColumnsView = new ObservableCollection<ColumnViewModel>();
            target.ColumnsView.Add(columnView);

            target.OnMapColumnSelectionChanged(columnView, e);
            Assert.AreEqual(true, target.isMarkerTabEnabled);
            Assert.AreEqual(false, target.isDistanceVisible);
            Assert.AreEqual(false, target.IsRAUnitVisible);
        }
        public void UpdateHeaderTest()
        {
            Application application = new Application();

            try
            {
                Workbook book = application.OpenWorkbook("TestData.xlsx", false);
                WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);
                target.currentWorkbookMap = new WorkbookMap_Accessor(book);

                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");

                // Get the named range stored in the test data excel file.
                Name name = book.Names.GetNamedRange("ColumnList");

                LayerMap_Accessor wwtLayerMap = new LayerMap_Accessor(name);
                wwtLayerMap.LayerDetails.Name = "Layer";
                wwtLayerMap.LayerDetails.ID = "754becad-8e2c-4452-b7e9-55827d4d2786";
                wwtLayerMap.MapType = LayerMapType.WWT;

                WorkflowController_Accessor.UpdateHeader(wwtLayerMap);

                // It is expected to be in synch
                Assert.IsFalse(wwtLayerMap.IsNotInSync);

                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTInvalidMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");

                WorkflowController_Accessor.UpdateHeader(wwtLayerMap);

                // It is expected not to be in synch
                Assert.IsTrue(wwtLayerMap.IsNotInSync);

                LayerMap_Accessor localLayerMap = new LayerMap_Accessor(name);
                localLayerMap.LayerDetails.Name = "Layer";
                localLayerMap.LayerDetails.ID = "754becad-8e2c-4452-b7e9-55827d4d2786";
                localLayerMap.MapType = LayerMapType.Local;
                localLayerMap.IsNotInSync = true;

                WorkflowController_Accessor.UpdateHeader(localLayerMap);

                // It is expected not to be in synch
                Assert.IsTrue(localLayerMap.IsNotInSync);
            }
            finally
            {
                application.Close();
            }
        }
        public void SetLayerDetailsViewModelPropertiesTest()
        {
            Application application = new Application();
            try
            {
                Workbook book = application.OpenWorkbook("TestData.xlsx", false);

                Name namedRange = book.Names.GetNamedRange("ColumnList");

                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");

                LayerMap_Accessor localLayerMap = new LayerMap_Accessor(namedRange);
                localLayerMap.LayerDetails.Name = "Layer";
                localLayerMap.MapType = LayerMapType.LocalInWWT;

                LayerMap currentLayer = new LayerMap(namedRange);
                currentLayer.LayerDetails.Name = "Layer";
                currentLayer.MapType = LayerMapType.Local;

                WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);

                target.currentWorkbookMap = new WorkbookMap_Accessor(book);
                target.layerDetailsViewModel = new LayerDetailsViewModel();
                target.layerDetailsViewModel.Currentlayer = currentLayer;
                target.currentWorkbookMap.SelectedLayerMap = localLayerMap;

                string expected = "Layer (not linked)";
                target.SetLayerDetailsViewModelProperties();

                Assert.AreEqual(expected, target.layerDetailsViewModel.SelectedLayerText);
                Assert.AreEqual(false, target.layerDetailsViewModel.IsViewInWWTEnabled);
                Assert.AreEqual(false, target.layerDetailsViewModel.IsCallOutVisible);
                Assert.AreEqual(true, target.layerDetailsViewModel.IsGetLayerDataEnabled);
                Assert.AreEqual(true, target.layerDetailsViewModel.IsReferenceGroupEnabled);
            }
            finally
            {
                application.Close();
            }
        }
        public void OnTargetMachineChangedTest()
        {
            Application application = new Application();

            try
            {
                Workbook book = application.OpenWorkbook("TestData.xlsx", false);

                WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);
                target.currentWorkbookMap = new WorkbookMap_Accessor(book);

                // Get the named range stored in the test data excel file.
                Name name = book.Names.GetNamedRange("ColumnList");
                Group parentGroup = new Group("Sun", GroupType.ReferenceFrame, null);

                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTInvalidMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");

                string layerId = "2cf4374f-e1ce-47a9-b08c-31079765ddcf";
                LayerMap_Accessor wwtLayerMap = new LayerMap_Accessor(name);
                wwtLayerMap.LayerDetails.Name = "Layer1";
                wwtLayerMap.LayerDetails.ID = layerId;
                wwtLayerMap.LayerDetails.Group = parentGroup;
                wwtLayerMap.MapType = LayerMapType.WWT;

                target.currentWorkbookMap.SelectedLayerMap = wwtLayerMap;

                EventArgs e = null;
                target.OnTargetMachineChanged(null, e);

                Assert.AreEqual(null, target.currentWorkbookMap.SelectedLayerMap);
                Assert.AreEqual(null, target.layerDetailsViewModel.Currentlayer);
            }
            finally
            {
                application.Close();
            }
        }
        public void GetLastUsedGroupTestForSky()
        {
            Application application = new Application();
            try
            {
                Collection<Group> groups = new Collection<Group>();

                bool isWWTRunning = false;
                Group expected = groups.GetDefaultSkyGroup();

                Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false);

                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");

                // Get the named range stored in the test data excel file.
                Name namedRange = book.Names.GetNamedRange("GetLastUsedGroupTestRaDec");

                LayerMap_Accessor selectedlayer = new LayerMap_Accessor(namedRange);
                selectedlayer.MapType = LayerMapType.Local;
                selectedlayer.IsNotInSync = false;
                selectedlayer.LayerDetails.ID = "Exits";

                Group actual = WorkflowController_Accessor.GetLastUsedGroup(selectedlayer, isWWTRunning);
                Assert.AreEqual(expected.Name, actual.Name);
                Assert.AreEqual(expected.Path, actual.Path);
            }
            finally
            {
                application.Close();
            }
        }
        public void CreateLayerInWWTTest()
        {
            Application application = new Application();

            try
            {
                Workbook book = application.OpenWorkbook("TestData.xlsx", false);

                WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);
                target.currentWorkbookMap = new WorkbookMap_Accessor(book);

                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");

                // Get the named range stored in the test data excel file.
                Name name = book.Names.GetNamedRange("ColumnList");
                Group parentGroup = new Group("Sun", GroupType.ReferenceFrame, null);
                Group childGroup = new Group("Earth", GroupType.LayerGroup, parentGroup);

                string oldLayerId = "754becad-8e2c-4452-b7e9-55827d4d2786";

                LayerMap_Accessor localLayerMap = new LayerMap_Accessor(name);
                localLayerMap.LayerDetails.Name = "Layer";
                localLayerMap.LayerDetails.ID = oldLayerId;
                localLayerMap.LayerDetails.Group = childGroup;
                localLayerMap.MapType = LayerMapType.Local;
                localLayerMap.HeaderRowData = new System.Collections.ObjectModel.Collection<string>();
                localLayerMap.HeaderRowData.Add("LAT");
                localLayerMap.HeaderRowData.Add("Long");
                localLayerMap.HeaderRowData.Add("Time");

                bool expected = true;

                string layerId = "2cf4374f-e1ce-47a9-b08c-31079765ddcf";
                bool actual = WorkflowController_Accessor.CreateLayerInWWT(localLayerMap);
                Assert.AreEqual(expected, actual);
                Assert.AreEqual(LayerMapType.LocalInWWT, localLayerMap.MapType);
                Assert.AreEqual(layerId, localLayerMap.LayerDetails.ID);

                localLayerMap.LayerDetails.ID = oldLayerId;
                Group invalidGroup = new Group("Test", GroupType.LayerGroup, parentGroup);
                localLayerMap.LayerDetails.Group = invalidGroup;
                actual = WorkflowController_Accessor.CreateLayerInWWT(localLayerMap);
                Assert.AreEqual(expected, actual);
                Assert.AreEqual(LayerMapType.LocalInWWT, localLayerMap.MapType);
                Assert.AreEqual(layerId, localLayerMap.LayerDetails.ID);
            }
            finally
            {
                application.Close();
            }
        }
        public void DeleteMappingTest()
        {
            Application application = new Application();

            try
            {
                Workbook book = application.OpenWorkbook("TestData.xlsx", false);
                WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);
                target.currentWorkbookMap = new WorkbookMap_Accessor(book);
                Worksheet worksheet = application.ActiveSheet;
                Range address = worksheet.get_Range("A1:G8");
                Name namedRange = book.CreateNamedRange("DeleteMappingRange", address);
                LayerMap_Accessor localLayer = new LayerMap_Accessor(namedRange);
                target.currentWorkbookMap.SelectedLayerMap = localLayer;
                target.DeleteMapping();
                Assert.IsNull(book.Names.GetNamedRange("DeleteMappingRange"));
                Assert.IsNull(target.currentWorkbookMap.SelectedLayerMap);
            }
            finally
            {
                application.Close();
            }
        }
        public void ValidateLocalInWWTLayerDataTest()
        {
            Application application = new Application();
            try
            {
                Workbook book = application.OpenWorkbook("TestData.xlsx", false);

                Name namedRange = book.Names.GetNamedRange("ColumnList");

                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");

                LayerMap_Accessor localLayerMap = new LayerMap_Accessor(namedRange);
                localLayerMap.LayerDetails.Name = "Layer";
                localLayerMap.MapType = LayerMapType.LocalInWWT;

                WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);
                target.currentWorkbookMap = new WorkbookMap_Accessor(book);
                target.currentWorkbookMap.SelectedLayerMap = localLayerMap;

                // Active sheet returned will be the book.Sheets[3] object.
                book.Sheets[3].Activate();
                Range selectedRange = namedRange.RefersToRange;

                _Worksheet activeSheet = WorkflowController_Accessor.GetActiveWorksheet();

                bool expected = true;
                bool actual = target.ValidateLocalInWWTLayerData(activeSheet, selectedRange);
                Assert.AreEqual(expected, actual);
            }
            finally
            {
                application.Close();
            }
        }
        public void UpdateWWTTestSuccess()
        {
            Application application = new Application();

            try
            {
                Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false);

                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");

                // Get the named range stored in the test data excel file.
                // This range refers to address "A$1:$D$8" in sheet CreateRangeForLayer.
                Name namedRange = book.Names.GetNamedRange("GetLastUsedGroupTestLatLon");

                LayerMap_Accessor selectedlayer = new LayerMap_Accessor(namedRange);
                selectedlayer.MapType = LayerMapType.LocalInWWT;
                selectedlayer.IsNotInSync = false;
                selectedlayer.LayerDetails.ID = "Exits";

                bool actual;

                actual = WorkflowController_Accessor.UpdateWWT(selectedlayer);

                Assert.AreEqual(true, actual);
            }
            finally
            {
                application.Close();
            }
        }
        public void OnGroupSelectionChangedTest()
        {
            LayerDetailsViewModel_Accessor target = new LayerDetailsViewModel_Accessor();
            Group group = new Group("Sun", GroupType.ReferenceFrame, null);
            Group skyGroup = new Group("Sky", GroupType.ReferenceFrame, null);
            Layer layer = new Layer();
            layer.Name = "Layer1";
            layer.StartTime = DateTime.Now;

            LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
            localLayerMap.MapType = LayerMapType.Local;
            localLayerMap.RangeDisplayName = "Sheet_1";
            localLayerMap.HeaderRowData = new Collection<string>();
            localLayerMap.HeaderRowData.Add("Lat");

            localLayerMap.MappedColumnType = new Collection<ColumnType>();
            localLayerMap.MappedColumnType.Add(ColumnType.RA);
            target.currentLayer = localLayerMap;

            ColumnViewModel columnView = new ColumnViewModel();
            columnView.ExcelHeaderColumn = "RA";
            columnView.WWTColumns = new ObservableCollection<Column>();
            ColumnExtensions.PopulateColumnList().ToList().ForEach(col => columnView.WWTColumns.Add(col));
            columnView.SelectedWWTColumn = columnView.WWTColumns.Where(column => column.ColType == ColumnType.RA).FirstOrDefault();

            target.ColumnsView = new ObservableCollection<ColumnViewModel>();
            target.ColumnsView.Add(columnView);

            target.selectedScaleType = new System.Collections.Generic.KeyValuePair<ScaleType, string>(ScaleType.StellarMagnitude, "StellarMagnitude");

            object sender = group;
            EventArgs e = null;
            target.OnGroupSelectionChanged(sender, e);

            Assert.AreEqual(false, target.isRAUnitVisible);
            Assert.AreEqual("Sun", target.selectedGroupText);
            Assert.AreEqual(ScaleType.Power, target.selectedScaleType.Key);

            sender = skyGroup;
            target.OnGroupSelectionChanged(sender, e);
            Assert.AreEqual(ScaleType.StellarMagnitude, target.selectedScaleType.Key);
        }
        public void GotoViewpointOnViewInWWTTestSky()
        {
            Application application = new Application();
            bool createdWtmlKey = false;

            try
            {
                createdWtmlKey = CreateWwtKeyIfNotExists();
                Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false);
                Name namedRange = book.Names.GetNamedRange("GotoViewpointOnViewInWWTSky");

                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");

                Group skyGroup = new Group("Sky", GroupType.ReferenceFrame, null);

                LayerMap_Accessor selectedLayerMap = new LayerMap_Accessor(namedRange);
                selectedLayerMap.MapType = LayerMapType.LocalInWWT;
                selectedLayerMap.LayerDetails.Group = skyGroup;
                selectedLayerMap.LayerDetails.ID = "sunLayerID1";

                WorkflowController_Accessor.GotoViewpointOnViewInWWT(selectedLayerMap);
            }
            finally
            {
                application.Close();
                if (createdWtmlKey)
                {
                    // Delete the registry key if it is created by this test case.
                    Registry.ClassesRoot.DeleteSubKey(@".wtml", false);
                }
            }
        }
        public void OnLayerSelectionChangedEventTest()
        {
            LayerDetailsViewModel_Accessor target = new LayerDetailsViewModel_Accessor();
            Layer layer = new Layer();
            layer.Name = "Layer1";
            layer.StartTime = DateTime.Now;

            LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
            localLayerMap.MapType = LayerMapType.Local;
            localLayerMap.RangeDisplayName = "Sheet_1";
            localLayerMap.HeaderRowData = new Collection<string>();
            localLayerMap.HeaderRowData.Add("Lat");

            localLayerMap.MappedColumnType = new Collection<ColumnType>();
            localLayerMap.MappedColumnType.Add(ColumnType.RA);
            target.currentLayer = localLayerMap;

            object sender = localLayerMap;
            EventArgs e = null;
            target.OnLayerSelectionChangedEvent(sender, e);

            Assert.AreEqual("Layer1", target.SelectedLayerText);
        }
        public void CreateGroupInWWTTest()
        {
            Application application = new Application();

            try
            {
                Workbook book = application.OpenWorkbook("TestData.xlsx", false);
                WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);
                target.currentWorkbookMap = new WorkbookMap_Accessor(book);

                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");

                // Get the named range stored in the test data excel file.
                Name name = book.Names.GetNamedRange("ColumnList");
                Group parentGroup = new Group("Sun", GroupType.ReferenceFrame, null);
                Group childGroup = new Group("Earth", GroupType.LayerGroup, parentGroup);

                LayerMap_Accessor wwtLayerMap = new LayerMap_Accessor(name);
                wwtLayerMap.LayerDetails.Name = "Layer";
                wwtLayerMap.LayerDetails.ID = "754becad-8e2c-4452-b7e9-55827d4d2786";
                wwtLayerMap.LayerDetails.Group = childGroup;
                wwtLayerMap.MapType = LayerMapType.WWT;

                bool expected = true;
                bool actual = WorkflowController_Accessor.CreateGroupInWWT(wwtLayerMap);
                Assert.AreEqual(expected, actual);
            }
            finally
            {
                application.Close();
            }
        }
        public void GetSelectedLayerMapWWTTest()
        {
            Application application = new Application();

            try
            {
                Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false);
                WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);
                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");
                target.OnNewWorkbook(book);

                Layer layer = new Layer();
                LayerMap_Accessor localLayer = new LayerMap_Accessor(layer);
                localLayer.MapType = LayerMapType.WWT;
                localLayer.LayerDetails.ID = "2cf4374f-e1ce-47a9-b08c-31079765ddcf";

                // CurrentWorkbookMap cannot be accessed directly through WorkflowController_Accessor object.
                WorkbookMap currentWorkbookMap = target.currentWorkbookMap.Target as WorkbookMap;
                currentWorkbookMap.AllLayerMaps[0].LayerDetails.ID = "2cf4374f-e1ce-47a9-b08c-31079765ddcf";
                currentWorkbookMap.AllLayerMaps[0].MapType = LayerMapType.WWT;
                LayerMap_Accessor layerMapAccessor = target.GetSelectedLayerMap(localLayer);

                // Make sure LayerMap is returned and the expected LayerMap ID is returned.
                Assert.IsNotNull(layerMapAccessor);
                Assert.AreEqual(layerMapAccessor.LayerDetails.ID, "2cf4374f-e1ce-47a9-b08c-31079765ddcf");
            }
            finally
            {
                application.Close();
            }
        }
        public void ShowSelectedRangeNonActiveSheetTest()
        {
            Application application = new Application();

            try
            {
                Workbook book = application.OpenWorkbook("TestData.xlsx", false);
                WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);

                target.currentWorkbookMap = new WorkbookMap_Accessor(book);
                Worksheet worksheet = application.Worksheets[1];
                Range inputRange = worksheet.get_Range("A1:G8");
                Name namedRange = book.CreateNamedRange("ShowSelectedRange", inputRange);
                LayerMap_Accessor localLayer = new LayerMap_Accessor(namedRange);
                target.currentWorkbookMap.SelectedLayerMap = localLayer;
                application.Worksheets[2].Activate();
                target.ShowSelectedRange();
                Range selectedRange = application.Selection as Range;
                Assert.AreEqual(selectedRange.Address, inputRange.Address);
            }
            finally
            {
                application.Close();
            }
        }
        public void GetSelectedLayerWorksheetTest()
        {
            Application application = new Application();

            try
            {
                Workbook book = application.OpenWorkbook("TestData.xlsx", false);

                // Get the named range stored in the test data excel file.
                // This range refers to address "$A$1:$D$7".
                Name name = book.Names.GetNamedRange("GetSelectedLayerWorksheet");

                ThisAddIn_Accessor.ExcelApplication = application;
                LayerMap_Accessor selectedLayerMap = new LayerMap_Accessor(name);

                // Active the first sheet, to verify the actual sheet to which the range belongs to is getting selected.
                book.Sheets[1].Activate();

                // GetSelectedLayerWorksheet range belongs to sheet 6.
                _Worksheet expected = book.Sheets[6];
                _Worksheet actual = WorkflowController_Accessor.GetSelectedLayerWorksheet(selectedLayerMap);

                // Verify that both Worksheet objects are same.
                Assert.AreEqual(expected, actual);

                // Also verify that the active sheet is same as the one returned.
                Assert.AreEqual(application.ActiveSheet, actual);
            }
            finally
            {
                application.Close();
            }
        }
        public void GotoViewpointOnViewInWWTTestEarthGeo()
        {
            Application application = new Application();
            try
            {
                Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false);
                Name namedRange = book.Names.GetNamedRange("GotoViewpointOnViewInWWTGeo");

                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");

                Group sunGroup = new Group("Sun", GroupType.ReferenceFrame, null);

                LayerMap_Accessor selectedLayerMap = new LayerMap_Accessor(namedRange);
                selectedLayerMap.MapType = LayerMapType.LocalInWWT;
                selectedLayerMap.LayerDetails.Group = sunGroup;
                selectedLayerMap.LayerDetails.ID = "sunLayerID1";

                WorkflowController_Accessor.GotoViewpointOnViewInWWT(selectedLayerMap);
            }
            finally
            {
                application.Close();
            }
        }
        public void AddLayerNodeTest()
        {
            Application application = new Application();

            try
            {
                // Where ever we are creating object for WorkflowController_Accessor, we need to set the ThisAddIn_Accessor.ExcelApplication to
                // wither null or actual application object.
                ThisAddIn_Accessor.ExcelApplication = application;
                List<GroupChildren> groups = new List<GroupChildren>();
                List<GroupChildren> nestedGroups = new List<GroupChildren>();

                Group parentGroup = new Group("Earth", GroupType.ReferenceFrame, null);
                Layer layer = new Layer();
                layer.Name = "Layer1";
                layer.Group = parentGroup;

                LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
                localLayerMap.MapType = LayerMapType.Local;
                localLayerMap.RangeDisplayName = "Sheet_1";

                Group childGroup = new Group("Earth", GroupType.ReferenceFrame, parentGroup);
                Layer nestedLayer = new Layer();
                nestedLayer.Name = "Layer1";
                nestedLayer.Group = childGroup;

                LayerMap_Accessor nestedLayerMap = new LayerMap_Accessor(nestedLayer);
                nestedLayerMap.MapType = LayerMapType.Local;
                nestedLayerMap.RangeDisplayName = "Sheet_1";

                LayerMapExtensions_Accessor.AddLayerNode(groups, localLayerMap);
                LayerMapExtensions_Accessor.AddLayerNode(nestedGroups, nestedLayerMap);

                Assert.AreEqual(1, groups.Count);
                foreach (GroupChildren group in groups)
                {
                    Assert.AreEqual("Earth", group.Name);
                    Assert.AreEqual(1, group.AllChildren.Count);
                    foreach (LayerMap layerVal in group.AllChildren)
                    {
                        Assert.AreEqual("Layer1", layerVal.LayerDetails.Name);
                    }
                }

                Assert.AreEqual(1, nestedGroups.Count);
                foreach (GroupChildren group in nestedGroups)
                {
                    Assert.AreEqual("Earth", group.Name);
                    Assert.AreEqual(1, group.Children.Count);
                }
            }
            finally
            {
                application.Close();
            }
        }
        public void OnReferenceSelectionChangedTest()
        {
            Application application = new Application();

            try
            {
                Workbook book = application.OpenWorkbook("TestData.xlsx", false);
                WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);
                target.currentWorkbookMap = new WorkbookMap_Accessor(book);

                // Get the named range stored in the test data excel file.
                Name name = book.Names.GetNamedRange("ColumnList");
                Group parentGroup = new Group("Sun", GroupType.ReferenceFrame, null);

                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");

                string layerId = "2cf4374f-e1ce-47a9-b08c-31079765ddcf";
                LayerMap_Accessor localLayerMap = new LayerMap_Accessor(name);
                localLayerMap.LayerDetails.Name = "Layer1";
                localLayerMap.LayerDetails.ID = layerId;
                localLayerMap.LayerDetails.Group = parentGroup;
                localLayerMap.MapType = LayerMapType.LocalInWWT;

                LayerMap currentlayer = new LayerMap(name);
                currentlayer.LayerDetails.Name = "Layer2";
                currentlayer.LayerDetails.ID = layerId;
                currentlayer.LayerDetails.Group = parentGroup;
                currentlayer.MapType = LayerMapType.LocalInWWT;

                currentlayer.HeaderRowData = new Collection<string>();
                currentlayer.HeaderRowData.Add("LAT");
                currentlayer.HeaderRowData.Add("Long");
                currentlayer.HeaderRowData.Add("Depth");

                target.layerDetailsViewModel = new LayerDetailsViewModel();
                target.layerDetailsViewModel.Currentlayer = currentlayer;
                target.currentWorkbookMap.SelectedLayerMap = localLayerMap;
                EventArgs e = null;
                target.OnReferenceSelectionChanged(null, e);

                Collection<ColumnType> mappedType = new Collection<ColumnType>();
                mappedType.Add(ColumnType.Lat);
                mappedType.Add(ColumnType.Long);
                mappedType.Add(ColumnType.Depth);

                Assert.AreEqual(target.currentWorkbookMap.SelectedLayerMap.LayerDetails.Name, target.layerDetailsViewModel.Currentlayer.LayerDetails.Name);
                Assert.AreEqual(target.currentWorkbookMap.SelectedLayerMap.MappedColumnType.Count, target.layerDetailsViewModel.Currentlayer.MappedColumnType.Count);

                int index = 0;
                foreach (ColumnType colType in mappedType)
                {
                    Assert.AreEqual(target.layerDetailsViewModel.Currentlayer.MappedColumnType[index], colType);
                    index++;
                }
            }
            finally
            {
                application.Close();
            }
        }