diff SSRS/SSRS.Tests/ReportExecutionFixture.cs @ 112:b9d5f934cb21

Initial upload
author adminsh@apollo
date Sat, 19 May 2012 16:09:07 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSRS/SSRS.Tests/ReportExecutionFixture.cs	Sat May 19 16:09:07 2012 +0100
@@ -0,0 +1,56 @@
+using System.IO;
+using NUnit.Framework;
+using SSRS.Services;
+using SSRS.Services.DTO;
+using SSRS.Services.ReportExecutionServiceReference;
+
+namespace SSRS.Tests
+{
+    [TestFixture]
+    class ReportExecutionFixture
+    {
+        private const string ReportPath = "/SSRSProject/Stock Price List";
+
+        [Test]
+        public void WhenExecute_With_SSRSProject_StockPriceList_And_Excel_ShouldReturnNotNullResult()
+        {
+            var client = new ReportExecutionService();
+
+            var request = new ReportExecutionRequest { Name = ReportPath, Format = "EXCEL" };
+            var parameters = new Parameter[1];
+            parameters[0] = new Parameter {Name = "ListPriceReportParameter1", Value = "0"};
+            request.Parameters = parameters;           
+            
+            var response = client.Execute(request) as ReportExecutionResponse;
+            
+            Assert.NotNull(response);
+
+            string fileName = Path.GetTempPath() + "Stock Price List.xls";
+            using (FileStream stream = File.OpenWrite(fileName))
+            {
+                stream.Write(response.Result, 0, response.Result.Length);
+            }
+        }
+
+        [Test]
+        public void WhenExecute_With_SSRSProject_StockPriceList_And_Pdf_ShouldReturnNotNullResult()
+        {
+            var client = new ReportExecutionService();
+
+            var request = new ReportExecutionRequest { Name = ReportPath, Format = "PDF" };
+            var parameters = new Parameter[1];
+            parameters[0] = new Parameter { Name = "ListPriceReportParameter1", Value = "0" };
+            request.Parameters = parameters;
+
+            var response = client.Execute(request) as ReportExecutionResponse;
+
+            Assert.NotNull(response);
+
+            string fileName = Path.GetTempPath() + "samplereport.pdf";
+            using (FileStream stream = File.OpenWrite(fileName))
+            {
+                stream.Write(response.Result, 0, response.Result.Length);
+            }
+        }
+    }
+}