public void OnSerializingMethodNegativeTest() { Application application = new Application(); try { Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false); // 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; using (WorkflowController_Accessor target = new WorkflowController_Accessor()) { Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest()); Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost"); target.OnWorkbookOpen(book); target.currentWorkbookMap.SelectedLayerMap.RangeName.RefersTo = null; Assert.IsNotNull(target.currentWorkbookMap.SelectedLayerMap); StreamingContext context = new StreamingContext(); target.currentWorkbookMap.OnSerializingMethod(context); Assert.IsNull(target.currentWorkbookMap.SelectedLayerMap); } } finally { application.Close(); } }
public void CleanLayerMapTest() { Application application = new Application(); try { Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false); // 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; using (WorkflowController_Accessor target = new WorkflowController_Accessor()) { Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest()); Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost"); target.OnNewWorkbook(book); Name namedRange = book.Names.GetNamedRange("TestProperties_1"); namedRange.RefersTo = null; // CurrentWorkbookMap cannot be accessed directly through WorkflowController_Accessor object. WorkbookMap currentWorkbookMap = target.currentWorkbookMap.Target as WorkbookMap; // Before making call to CleanLayerMap method, AllLayerMaps count should be 1. Assert.AreEqual(currentWorkbookMap.AllLayerMaps.Count, 2); Addin.WorkbookExtensions_Accessor.CleanLayerMap(book, target.currentWorkbookMap); // After the call to CleanLayerMap method, AllLayerMaps count should be 0. Assert.AreEqual(currentWorkbookMap.AllLayerMaps.Count, 1); } } finally { application.Close(); } }
/// <summary> /// Gets an instance of WorkflowController_Accessor. Also, sets the ExcelApplication object of ThisAddIn_Accessor. /// </summary> /// <param name="excelApplication">Application object</param> /// <returns>Instance of WorkflowController_Accessor</returns> private static WorkflowController_Accessor GetWorkflowControllerAccessor(Application excelApplication) { // 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 = excelApplication; WorkflowController_Accessor target = new WorkflowController_Accessor(); return target; }