annotate SSRS/SSRS.Services.UnitTests/ReportExecutionFixture.cs @ 117:9eadccc3b46c

REST working, next step unit tests
author stevenh7776
date Sun, 27 May 2012 15:06:35 +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.DTO;
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
4
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
5 namespace SSRS.Services.UnitTests
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
6 {
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
7 [TestFixture]
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
8 class ReportExecutionFixture
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
9 {
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
10 private const string ReportPath = "/SSRSProject/Stock Price List";
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
11
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
12 [Test]
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
13 public void WhenExecute_With_SSRSProject_StockPriceList_And_Excel_ShouldReturnNotNullResult()
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
14 {
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
15 var client = new ReportExecutionService();
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
16 var request = new ReportExecutionRequest { Name = ReportPath, Format = "EXCEL" };
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
17 var parameters = new Parameter[1];
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
18 parameters[0] = new Parameter {Name = "ListPriceReportParameter1", Value = "0"};
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
19 request.Parameters = parameters;
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
20
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
21 var response = client.Execute(request) as ReportExecutionResponse;
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
22
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
23 Assert.NotNull(response);
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
24
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
25 string fileName = Path.GetTempPath() + "Stock Price List.xls";
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
26 using (FileStream stream = File.OpenWrite(fileName))
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
27 {
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
28 stream.Write(response.Result, 0, response.Result.Length);
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
29 }
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
30 }
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
31
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
32 [Test]
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
33 public void WhenExecute_With_SSRSProject_StockPriceList_And_Pdf_ShouldReturnNotNullResult()
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
34 {
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
35 var client = new ReportExecutionService();
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
36
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
37 var request = new ReportExecutionRequest { Name = ReportPath, Format = "PDF" };
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
38 var parameters = new Parameter[1];
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
39 parameters[0] = new Parameter { Name = "ListPriceReportParameter1", Value = "0" };
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
40 request.Parameters = parameters;
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
41
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
42 var response = client.Execute(request) as ReportExecutionResponse;
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
43
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
44 Assert.NotNull(response);
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
45
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
46 string fileName = Path.GetTempPath() + "samplereport.pdf";
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
47 using (FileStream stream = File.OpenWrite(fileName))
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
48 {
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
49 stream.Write(response.Result, 0, response.Result.Length);
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
50 }
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
51 }
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
52 }
b9d5f934cb21 Initial upload
adminsh@apollo
parents:
diff changeset
53 }