-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
118 lines (99 loc) · 4.17 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Text;
using System.Xml;
using Microsoft.Data.Schema.ScriptDom;
using Microsoft.Data.Schema.ScriptDom.Sql;
using NUnit.Framework;
namespace SSRSTest
{
public class ReportInfo
{
public string reportInfoPath;
public string ssrsUrl;
public ReportInfo(string r, string ssrs)//constructor accepting path to report
{
this.reportInfoPath = r;
this.ssrsUrl = ssrs;
}
public ReportInfo()
{
this.reportInfoPath = ConfigurationManager.AppSettings["ReportInfoPath"];
#if(DEV)
this.ssrsUrl = ConfigurationManager.AppSettings["DEV_SSRS_WebService"];
#elif(PRESIT)
this.ssrsUrl = ConfigurationManager.AppSettings["PRESIT_SSRS_WebService"];
#elif(SIT)
this.ssrsUrl = ConfigurationManager.AppSettings["SIT_SSRS_WebService"];
#elif(PROD)
this.ssrsUrl = ConfigurationManager.AppSettings["PROD_SSRS_WebService"];
#endif
}
/// <summary>
/// See http://www.nunit.org/index.php?p=testCaseSource&r=2.5.9f
/// For reference
/// Also https://msdn.microsoft.com/en-us/library/9k7k7cf0.aspx
/// for info re use of Yield keyword, in summary (from MSDN)
/// When you use the yield keyword in a statement, you indicate that the method, operator,
/// or get accessor in which it appears is an iterator. Using yield to define an iterator removes the need
/// for an explicit extra class (the class that holds the state for an enumeration, see IEnumerator<T> for an example)
/// when you implement the IEnumerable and IEnumerator pattern for a custom collection type.
/// </summary>
public IEnumerable GetReportTestCases
{
get
{
using (var reports = XmlReader.Create(this.reportInfoPath))
{
while (reports.Read())
{
if (reports.Name == "report")
{
int reportNumber;
if (!int.TryParse(reports["filename"].Substring(0, 3), out reportNumber))
{
reportNumber = 0;
}
string reportPath = string.Concat(reports["subfolder"].ToString().Length > 0 ? "/" : "", reports["subfolder"], "/", reports.ReadElementContentAsString());
yield return new TestCaseData(reportNumber, reportPath, this.ssrsUrl);
}
}
}
}
}
}
}
namespace SSRSTest
{
[TestFixture]
public class ReportRenderTest
{
public string ROOT_PATH = ConfigurationManager.AppSettings["RootPath"];
[Test]
[TestCaseSource(typeof(ReportInfo), "GetReportTestCases")]
[Category("SSRSTest")]
public void DoesReportRender(int reportNumber, string reportPath, string ssrsUrl)
{
Console.WriteLine("Testing report: {0}: {1} @ {2}", reportNumber.ToString("000"), reportPath, DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss"));
bool result = ReportTester.RenderReport(ROOT_PATH + reportPath, ssrsUrl);
Assert.AreEqual(true, result);
}
}
[TestFixture]
public class ReportDeploymentTest
{
public string ROOT_PATH = ConfigurationManager.AppSettings["RootPath"];
[Test]
[TestCaseSource(typeof(ReportInfo), "GetReportTestCases")]
[Category("SSRSTest")]
public void DoesReportExist(int reportNumber, string reportPath, string ssrsUrl)
{
Console.WriteLine("Testing report: {0}: {1} @ {2}", reportNumber.ToString("000"), reportPath, DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss"));
bool result = ReportTester.ReportExists(ROOT_PATH + reportPath, ssrsUrl);
Assert.AreEqual(true, result);
}
}
}