11 changed files with 251 additions and 13 deletions
@ -0,0 +1,27 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 03.04.2013 |
||||||
|
* Time: 20:35 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.BaseClasses |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of Page.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
public interface IPage{ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public class Page:IPage |
||||||
|
{ |
||||||
|
public Page() |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,55 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 03.04.2013 |
||||||
|
* Time: 20:32 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using ICSharpCode.Reporting.BaseClasses; |
||||||
|
using ICSharpCode.Reporting.Interfaces; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.PageBuilder |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of BasePageBuilder.
|
||||||
|
/// </summary>
|
||||||
|
public class BasePageBuilder:IReportCreator |
||||||
|
{ |
||||||
|
private readonly object addLock = new object(); |
||||||
|
|
||||||
|
public BasePageBuilder(IReportModel reportModel) |
||||||
|
{ |
||||||
|
if (reportModel == null) { |
||||||
|
throw new ArgumentNullException("reportModel"); |
||||||
|
} |
||||||
|
ReportModel = reportModel; |
||||||
|
Pages = new List<IPage>(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
protected IPage InitNewPage(){ |
||||||
|
return new Page(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
protected virtual void AddPage(IPage page) { |
||||||
|
Pages.Add(page); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public virtual void BuildExportList() |
||||||
|
{ |
||||||
|
this.Pages.Clear(); |
||||||
|
} |
||||||
|
|
||||||
|
protected IReportModel ReportModel {get; private set;} |
||||||
|
|
||||||
|
public IPage CurrentPage {get; protected set;} |
||||||
|
|
||||||
|
public List<IPage> Pages {get; private set;} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,49 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 03.04.2013 |
||||||
|
* Time: 20:21 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using ICSharpCode.Reporting.BaseClasses; |
||||||
|
using ICSharpCode.Reporting.Interfaces; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.PageBuilder |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of FormPageBuilder.
|
||||||
|
/// </summary>
|
||||||
|
public class FormPageBuilder:BasePageBuilder |
||||||
|
{ |
||||||
|
|
||||||
|
private readonly object addLock = new object(); |
||||||
|
|
||||||
|
public FormPageBuilder(IReportModel reportModel):base(reportModel) |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public override void BuildExportList() |
||||||
|
{ |
||||||
|
base.BuildExportList(); |
||||||
|
WritePages (); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void WritePages() |
||||||
|
{ |
||||||
|
CurrentPage = base.InitNewPage(); |
||||||
|
this.BuildReportHeader(); |
||||||
|
base.AddPage(CurrentPage); |
||||||
|
} |
||||||
|
|
||||||
|
void BuildReportHeader() |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,65 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 03.04.2013 |
||||||
|
* Time: 20:09 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
using System.Reflection; |
||||||
|
|
||||||
|
using ICSharpCode.Reporting.BaseClasses; |
||||||
|
using ICSharpCode.Reporting.PageBuilder; |
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.Test.PageBuilder |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class PageBuilderFixture |
||||||
|
{ |
||||||
|
private Stream stream; |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void CanCreateFormsPageBuilder() |
||||||
|
{ |
||||||
|
var reportingFactory = new ReportingFactory(); |
||||||
|
var reportCreator = reportingFactory.ReportCreator(stream); |
||||||
|
Assert.IsNotNull(reportCreator); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void PagesCountIsZero () { |
||||||
|
var reportingFactory = new ReportingFactory(); |
||||||
|
var reportCreator = reportingFactory.ReportCreator(stream); |
||||||
|
Assert.That(reportCreator.Pages.Count,Is.EqualTo(0)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void BuildExportPagesCountIsOne() { |
||||||
|
var reportingFactory = new ReportingFactory(); |
||||||
|
var reportCreator = reportingFactory.ReportCreator(stream); |
||||||
|
reportCreator.BuildExportList(); |
||||||
|
Assert.That(reportCreator.Pages.Count,Is.EqualTo(1)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void CurrentPageIsSet() { |
||||||
|
var reportingFactory = new ReportingFactory(); |
||||||
|
var reportCreator = (FormPageBuilder)reportingFactory.ReportCreator(stream); |
||||||
|
reportCreator.BuildExportList(); |
||||||
|
Assert.That(reportCreator.CurrentPage,Is.Not.Null); |
||||||
|
} |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void LoadFromStream() |
||||||
|
{ |
||||||
|
System.Reflection.Assembly asm = Assembly.GetExecutingAssembly(); |
||||||
|
stream = asm.GetManifestResourceStream(TestHelper.PlainReportFileName); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 03.04.2013 |
||||||
|
* Time: 20:10 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.Test |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of TestHelper.
|
||||||
|
/// </summary>
|
||||||
|
public class TestHelper |
||||||
|
{ |
||||||
|
private const string nameSpace = "ICSharpCode.Reporting.Test.src.TestReports."; |
||||||
|
private const string plainReportName = "PlainModel.srd"; |
||||||
|
|
||||||
|
public TestHelper() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public static string PlainReportFileName{ |
||||||
|
get{return nameSpace + plainReportName;} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue