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