112
|
1 using System.IO;
|
|
2 using NUnit.Framework;
|
|
3 using SSRS.Services.DTO;
|
|
4
|
|
5 namespace SSRS.Services.UnitTests
|
|
6 {
|
|
7 [TestFixture]
|
|
8 class ReportExecutionFixture
|
|
9 {
|
|
10 private const string ReportPath = "/SSRSProject/Stock Price List";
|
|
11
|
|
12 [Test]
|
|
13 public void WhenExecute_With_SSRSProject_StockPriceList_And_Excel_ShouldReturnNotNullResult()
|
|
14 {
|
|
15 var client = new ReportExecutionService();
|
|
16 var request = new ReportExecutionRequest { Name = ReportPath, Format = "EXCEL" };
|
|
17 var parameters = new Parameter[1];
|
|
18 parameters[0] = new Parameter {Name = "ListPriceReportParameter1", Value = "0"};
|
|
19 request.Parameters = parameters;
|
|
20
|
|
21 var response = client.Execute(request) as ReportExecutionResponse;
|
|
22
|
|
23 Assert.NotNull(response);
|
|
24
|
|
25 string fileName = Path.GetTempPath() + "Stock Price List.xls";
|
|
26 using (FileStream stream = File.OpenWrite(fileName))
|
|
27 {
|
|
28 stream.Write(response.Result, 0, response.Result.Length);
|
|
29 }
|
|
30 }
|
|
31
|
|
32 [Test]
|
|
33 public void WhenExecute_With_SSRSProject_StockPriceList_And_Pdf_ShouldReturnNotNullResult()
|
|
34 {
|
|
35 var client = new ReportExecutionService();
|
|
36
|
|
37 var request = new ReportExecutionRequest { Name = ReportPath, Format = "PDF" };
|
|
38 var parameters = new Parameter[1];
|
|
39 parameters[0] = new Parameter { Name = "ListPriceReportParameter1", Value = "0" };
|
|
40 request.Parameters = parameters;
|
|
41
|
|
42 var response = client.Execute(request) as ReportExecutionResponse;
|
|
43
|
|
44 Assert.NotNull(response);
|
|
45
|
|
46 string fileName = Path.GetTempPath() + "samplereport.pdf";
|
|
47 using (FileStream stream = File.OpenWrite(fileName))
|
|
48 {
|
|
49 stream.Write(response.Result, 0, response.Result.Length);
|
|
50 }
|
|
51 }
|
|
52 }
|
|
53 }
|