1: internal class TestReportFactory
2: {
3: private static string _reportOpen = @"<report version='4.0'>";
4: private static string _key = @"<key>FiscalYearByBrowser</key>";
5: private static string _title = @"<title>Fiscal Year by Browser</title>";
6:
7: private static string _description =
8: @"<description>Shows page views per browser (IE, FireFox, etc..)
9: for each fiscal year.</description>";
10:
11: private static string _connectionString =
12: @"<connectionString>TelligentAnalyticsAnalysisServer</connectionString>";
13:
14: private static string _query =
15: @"<query>
16: select non empty [Time].[Fiscal Year].Members on columns,
17: non empty [Dim Browser].[Browser Name].Members on rows
18: from [Evolution Reporting]
19: </query>";
20:
21: private static string _chartTypes =
22: @"<chartTypes>
23: <add type=""fancy 3d chart"" />
24: <add type=""plain 2d chart"" />
25: </chartTypes>";
26:
27: private static string _reportClose = @"</report>";
28:
29:
30: public static string GetValidXml()
31: {
32: XElement doc = CreateValidReportXElement();
33: return doc.ToString();
34: }
35:
36: private static XElement CreateValidReportXElement()
37: {
38: var _outgoing = new StringBuilder();
39: _outgoing.Append(_reportOpen);
40: _outgoing.Append(_key);
41: _outgoing.Append(_title);
42: _outgoing.Append(_description);
43: _outgoing.Append(_connectionString);
44: _outgoing.Append(_query);
45: _outgoing.Append(_chartTypes);
46: _outgoing.Append(_reportClose);
47: XElement doc = XElement.Parse(_outgoing.ToString());
48: return doc;
49: }
50:
51:
52: internal static string GetWithoutQuery()
53: {
54: return CreateXmlStringWithoutElement("query");
55: }
56:
57: private static string CreateXmlStringWithoutElement(string elementName)
58: {
59: XElement doc = CreateValidReportXElement();
60: XElement element = doc.Element(elementName);
61: element.Remove();
62: return doc.ToString();
63: }
64:
65:
66: internal static string GetWithoutKey()
67: {
68: return CreateXmlStringWithoutElement("key");
69: }
70:
71: internal static string GetWithoutDescription()
72: {
73: return CreateXmlStringWithoutElement("description");
74: }
75:
76: internal static string GetWithoutConnectionString()
77: {
78: return CreateXmlStringWithoutElement("connectionString");
79: }
80:
81: internal static string GetWithoutChartTypes()
82: {
83: return CreateXmlStringWithoutElement("chartTypes");
84: }
85:
86: internal static string GetWithoutTitle()
87: {
88: return CreateXmlStringWithoutElement("title");
89: }
90:
91: internal static string GetWithoutVersion()
92: {
93: XElement doc = CreateValidReportXElement();
94: XAttribute ver = doc.Attribute("version");
95: ver.Remove();
96: return doc.ToString();
97: }
98:
99: internal static string GetInvalidXml()
100: {
101: return "<report>";
102: }
103: }
104: