/// <summary> /// Verify TimelineStyle Added. /// </summary> /// <param name="filePath">Target file path</param> /// <param name="log">Logger</param> public void VerifyAddedTimelineStyle(string filePath, VerifiableLog log) { //Verify TimelineStyle added using (SpreadsheetDocument package = SpreadsheetDocument.Open(filePath, false)) { int stylesheetExtensionCount = package.WorkbookPart.WorkbookStylesPart.Stylesheet.StylesheetExtensionList.Descendants <StylesheetExtension>().Where(e => e.Uri == this.StylesheetExtensionUri).Count(); log.Verify(stylesheetExtensionCount != 0, "X15.TimelineStyles extension element exist."); X15.TimelineStyles timelineStyles = package.WorkbookPart.WorkbookStylesPart.Stylesheet.StylesheetExtensionList.Descendants <X15.TimelineStyles>().Single(); log.Verify(timelineStyles.DefaultTimelineStyle.Value == this.timelineStyleName3, "Verify DefaultTimelineStyle attribute value in X15.TimelineStyles element. DefaultTimelineStyle attribute value=[{0}]", timelineStyles.DefaultTimelineStyle.Value); } }
/// <summary> /// Constructor /// Get URI attribute value of StylesheetExtension /// </summary> /// <param name="filePath">Generated file path</param> public TestEntities(string filePath) { using (SpreadsheetDocument package = SpreadsheetDocument.Open(filePath, false)) { //Get Extension Uri value X15.TimelineStyles timelineStyles = package.WorkbookPart.WorkbookStylesPart.Stylesheet.StylesheetExtensionList.Descendants <X15.TimelineStyles>().Single(); StylesheetExtension stylesheetExtension = (StylesheetExtension)timelineStyles.Parent; this.StylesheetExtensionUri = stylesheetExtension.Uri; if (string.IsNullOrEmpty(this.StylesheetExtensionUri)) { throw new Exception("Uri attribute value in Extension element is not set."); } } }
/// <summary> /// Delete X15.TimelineStyles element /// </summary> /// <param name="filePath">Target file path</param> /// <param name="log">Logger</param> public void DeleteTimelineStyle(string filePath, VerifiableLog log) { //Delete TimelineStyle using (SpreadsheetDocument package = SpreadsheetDocument.Open(filePath, true)) { X15.TimelineStyles timelineStyles = package.WorkbookPart.WorkbookStylesPart.Stylesheet.StylesheetExtensionList.Descendants <X15.TimelineStyles>().Single(); StylesheetExtension stylesheetExtension = (StylesheetExtension)timelineStyles.Parent; timelineStyles.Remove(); log.Pass("Deleted X15.TimelineStyles element."); stylesheetExtension.Remove(); log.Pass("Deleted X15.TimelineStyles extension element."); } }
/// <summary> /// Edit TimeLine attributes /// </summary> /// <param name="filePath">Editing target file path</param> /// <param name="log">Logger</param> public void EditAttributes(string filePath, VerifiableLog log) { using (SpreadsheetDocument package = SpreadsheetDocument.Open(filePath, true)) { X15.Timeline timeline = null; //ShowTimeLevel try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine01); timeline.ShowTimeLevel = true; log.Pass("Set \"ShowTimeLevel\" attribute, timeline control name is \"{0}\". set value is true.", timeline.Name); timeline = GetTimeLine(package.WorkbookPart, this.TileLine02); timeline.ShowTimeLevel = false; log.Pass("Set \"ShowTimeLevel\" attribute. timeline control name is \"{0}\". set value is false.", timeline.Name); } catch (Exception e) { log.Fail(e.Message); } //Cache try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine03); timeline.Cache = "NativeTimeline_Date"; log.Pass("Set \"Cache\" attribute. timeline control name is \"{0}\". set value is \"NativeTimeline_Date\".", timeline.Name); timeline = GetTimeLine(package.WorkbookPart, this.TileLine04); timeline.Cache = "NativeTimeline_DeliveryDate"; log.Pass("Set \"Cache\" attribute. timeline control name is \"{0}\". set value is \"NativeTimeline_DeliveryDate\".", timeline.Name); } catch (Exception e) { log.Fail(e.Message); } //ShowSelectionLabel try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine05); timeline.ShowSelectionLabel = true; log.Pass("Set \"ShowSelectionLabel\" attribute. timeline control name is \"{0}\". set value is true.", timeline.Name); timeline = GetTimeLine(package.WorkbookPart, this.TileLine06); timeline.ShowSelectionLabel = false; log.Pass("Set \"ShowSelectionLabel\" attribute. timeline control name is \"{0}\". set value is false.", timeline.Name); } catch (Exception e) { log.Fail(e.Message); } //ShowHeader try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine07); timeline.ShowHeader = true; log.Pass("Set \"ShowHeader\" attribute. timeline control name is \"{0}\". set value is true.", timeline.Name); timeline = GetTimeLine(package.WorkbookPart, this.TileLine08); timeline.ShowHeader = false; log.Pass("Set \"ShowHeader\" attribute. timeline control name is \"{0}\". set value is false.", timeline.Name); } catch (Exception e) { log.Fail(e.Message); } //Style try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine09); timeline.Style = "TimeSlicerStyleLight2"; log.Pass("Set \"Style\" attribute. timeline control name is \"{0}\". set value is \"TimeSlicerStyleLight2\".", timeline.Name); timeline = GetTimeLine(package.WorkbookPart, this.TileLine10); timeline.Style = null; log.Pass("Set \"Style\" attribute. timeline control name is \"{0}\". set value is null.", timeline.Name); } catch (Exception e) { log.Fail(e.Message); } //Caption try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine11); timeline.Caption = null; log.Pass("Set \"Caption\" attribute. timeline control name is \"{0}\". set value is null.", timeline.Name); timeline = GetTimeLine(package.WorkbookPart, this.TileLine12); timeline.Caption = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"; log.Pass("Set \"Caption\" attribute. timeline control name is \"{0}\". set value is \"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\".", timeline.Name); } catch (Exception e) { log.Fail(e.Message); } //ScrollPosition try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine13); timeline.ScrollPosition = DateTime.Parse("1900-01-01"); log.Pass("Set \"ScrollPosition\" attribute. timeline control name is \"{0}\". set value is \"1900-01-01\".", timeline.Name); timeline = GetTimeLine(package.WorkbookPart, this.TileLine14); timeline.ScrollPosition = DateTime.Parse("2010-12-31"); log.Pass("Set \"ScrollPosition\" attribute. timeline control name is \"{0}\". set value is \"2010-12-31\".", timeline.Name); } catch (Exception e) { log.Fail(e.Message); } //Level try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine15); timeline.Level.Value = 0U; log.Pass("Set \"ScrollPosition\" attribute. timeline control name is \"{0}\". set value is 0(Years).", timeline.Name); timeline = GetTimeLine(package.WorkbookPart, this.TileLine16); timeline.Level.Value = 1U; log.Pass("Set \"ScrollPosition\" attribute. timeline control name is \"{0}\". set value is 1(Quarters).", timeline.Name); timeline = GetTimeLine(package.WorkbookPart, this.TileLine17); timeline.Level.Value = 2U; log.Pass("Set \"ScrollPosition\" attribute. timeline control name is \"{0}\". set value is 2(Months).", timeline.Name); timeline = GetTimeLine(package.WorkbookPart, this.TileLine18); timeline.Level.Value = 3U; log.Pass("Set \"ScrollPosition\" attribute. timeline control name is \"{0}\". set value is 3(Days).", timeline.Name); } catch (Exception e) { log.Fail(e.Message); } //ShowHorizontalScrollbar try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine19); timeline.ShowHorizontalScrollbar = true; log.Pass("Set \"ShowHorizontalScrollbar\" attribute. timeline control name is \"{0}\". set value is true.", timeline.Name); timeline = GetTimeLine(package.WorkbookPart, this.TileLine20); timeline.ShowHorizontalScrollbar = false; log.Pass("Set \"ShowHorizontalScrollbar\" attribute. timeline control name is \"{0}\". set value is false.", timeline.Name); } catch (Exception e) { log.Fail(e.Message); } //DefaultTimelineStyle attribute in TimelineStyle element try { X15.TimelineStyles timelineStyles = package.WorkbookPart.WorkbookStylesPart.Stylesheet.StylesheetExtensionList.Descendants <X15.TimelineStyles>().Single(); timelineStyles.DefaultTimelineStyle.Value = this.timelineStyleName2; log.Pass("Set DefaultTimelineStyle attribute value in \"X15.TimelineStyles\" element. Set value is [{0}].", this.timelineStyleName2); } catch (Exception e) { log.Fail(e.Message); } } }
/// <summary> /// Verify the TileLine attributes value. /// </summary> /// <param name="filePath">Target file path</param> /// <param name="log">Logger</param> public void VerifyEditedAttribute(string filePath, VerifiableLog log) { using (SpreadsheetDocument package = SpreadsheetDocument.Open(filePath, false)) { X15.Timeline timeline = null; //verify ShowTimeLevel try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine01); log.Verify(timeline.ShowTimeLevel == true, "Timeline control in \"ShowTimeLevel\" attribute value is Verify. Name=[{0}],Value=[true].", timeline.Name); timeline = GetTimeLine(package.WorkbookPart, this.TileLine02); log.Verify(timeline.ShowTimeLevel == false, "Timeline control in \"ShowTimeLevel\" attribute value is Verify. Name=[{0}],Value=[false].", timeline.Name); } catch (Exception e) { log.Fail(e.Message); } //Verify Cache try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine03); log.Verify(timeline.Cache == "NativeTimeline_Date", "Timeline control in Cache attribute value is Verify. Name=[{0}],Value=[{1}].", timeline.Name, timeline.Cache); timeline = GetTimeLine(package.WorkbookPart, this.TileLine04); log.Verify(timeline.Cache == "NativeTimeline_DeliveryDate", "Timeline control in Cache attribute value is Verify. Name=[{0}],Value=[{1}].", timeline.Name, timeline.Cache); } catch (Exception e) { log.Fail(e.Message); } //Verify ShowSelectionLabel try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine05); log.Verify(timeline.ShowSelectionLabel, "Timeline control in \"ShowSelectionLabel\" attribute value is Verify. Name=[{0}],Value=[true].", timeline.Name); timeline = GetTimeLine(package.WorkbookPart, this.TileLine06); log.Verify(timeline.ShowSelectionLabel == false, "Timeline control in \"ShowSelectionLabel\" attribute value is Verify. Name=[{0}],Value=[false].", timeline.Name); } catch (Exception e) { log.Fail(e.Message); } //Verify ShowHeader try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine07); log.Verify(timeline.ShowHeader == true, "Timeline control in \"ShowHeader\" attribute value is Verify. Name=[{0}],Value=[true].", timeline.Name); timeline = GetTimeLine(package.WorkbookPart, this.TileLine08); log.Verify(timeline.ShowHeader == false, "Timeline control in \"ShowHeader\" attribute value is Verify. Name=[{0}],Value=[false].", timeline.Name); } catch (Exception e) { log.Fail(e.Message); } //Verify Style try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine09); log.Verify(timeline.Style == "TimeSlicerStyleLight2", "Timeline control in \"Style\" attribute value is Verify. Name=[{0}],Value=[{1}].", timeline.Name, timeline.Style); timeline = GetTimeLine(package.WorkbookPart, this.TileLine10); log.Verify(timeline.Style == null, "Timeline control in \"Style\" attribute value is Verify. Name=[{0}],Value=[{1}].", timeline.Name, timeline.Style); } catch (Exception e) { log.Fail(e.Message); } //Verify Caption try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine11); log.Verify(timeline.Caption == null, "Timeline control in \"Caption\" attribute value is Verify. Name=[{0}],Value=[{1}].", timeline.Name, timeline.Caption); timeline = GetTimeLine(package.WorkbookPart, this.TileLine12); log.Verify(timeline.Caption == "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", "Timeline control in \"Caption\" attribute value is Verify. Name=[{0}],Value=[{1}].", timeline.Name, timeline.Caption); } catch (Exception e) { log.Fail(e.Message); } //Verify ScrollPosition try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine13); log.Verify(timeline.ScrollPosition.Value == DateTime.Parse("1900-01-01"), "Timeline control in \"ScrollPosition\" attribute value is Verify. Name=[{0}],Value=[{1}].", timeline.Name, timeline.ScrollPosition); timeline = GetTimeLine(package.WorkbookPart, this.TileLine14); log.Verify(timeline.ScrollPosition.Value == DateTime.Parse("2010-12-31"), "Timeline control in \"ScrollPosition\" attribute value is Verify. Name=[{0}],Value=[{1}].", timeline.Name, timeline.ScrollPosition); } catch (Exception e) { log.Fail(e.Message); } //Verify Level try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine15); log.Verify(timeline.Level == 0U, "Timeline control in \"Level\" attribute value is Verify. Name=[{0}],Value=[{1}].", timeline.Name, timeline.Level); timeline = GetTimeLine(package.WorkbookPart, this.TileLine16); log.Verify(timeline.Level == 1U, "Timeline control in \"Level\" attribute value is Verify. Name=[{0}],Value=[{1}].", timeline.Name, timeline.Level); timeline = GetTimeLine(package.WorkbookPart, this.TileLine17); log.Verify(timeline.Level == 2U, "Timeline control in \"Level\" attribute value is Verify. Name=[{0}],Value=[{1}].", timeline.Name, timeline.Level); timeline = GetTimeLine(package.WorkbookPart, this.TileLine18); log.Verify(timeline.Level == 3U, "Timeline control in \"Level\" attribute value is Verify. Name=[{0}],Value=[{1}].", timeline.Name, timeline.Level); } catch (Exception e) { log.Fail(e.Message); } //Verify ShowHorizontalScrollbar try { timeline = GetTimeLine(package.WorkbookPart, this.TileLine19); log.Verify(timeline.ShowHorizontalScrollbar, "Timeline control in \"ShowHorizontalScrollbar\" attribute value is Verify. Name=[{0}],Value=[true].", timeline.Name); timeline = GetTimeLine(package.WorkbookPart, this.TileLine20); log.Verify(timeline.ShowHorizontalScrollbar == false, "Timeline control in \"ShowHorizontalScrollbar\" attribute value is Verify. Name=[{0}],Value=[false].", timeline.Name); } catch (Exception e) { log.Fail(e.Message); } //Verify DefaultTimelineStyle attribute in TimelineStyle element try { X15.TimelineStyles timelineStyles = package.WorkbookPart.WorkbookStylesPart.Stylesheet.StylesheetExtensionList.Descendants <X15.TimelineStyles>().Single(); log.Verify(timelineStyles.DefaultTimelineStyle == this.timelineStyleName2, "Verify \"DefaultTimelineStyle\" attribute. Value=[{0}]", timelineStyles.DefaultTimelineStyle); } catch (Exception e) { log.Fail(e.Message); } } }