annotate SSRS/SSRS.Tests/ReportExecutionFixture.cs @ 113:954f66bb8dbf

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