Browse Source

Add UnitTest's for ExportItemsConverter

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@5771 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Peter Forstmeier 15 years ago
parent
commit
ed9a8b114b
  1. 5
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/BaseItems/BaseRowItem.cs
  2. 8
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Exporter/ExportItemsConverter.cs
  3. 101
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/Exporter/ExportItemsConverterFixture.cs
  4. 2
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/ICSharpCode.Reports.Core.Test.csproj

5
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/BaseItems/BaseRowItem.cs

@ -46,14 +46,15 @@ namespace ICSharpCode.Reports.Core{ @@ -46,14 +46,15 @@ namespace ICSharpCode.Reports.Core{
style.ForeColor = this.ForeColor;
style.FrameColor = this.FrameColor;
/*
if (this.Parent != null) {
Rectangle rect = base.DrawingRectangle;
style.Location = new Point(rect.Left,this.Location.Y);
} else {
style.Location = this.Location;
}
//style.Location = this.Location;
*/
style.Location = this.Location;
style.Size = this.Size;
style.DrawBorder = this.DrawBorder;
return style;

8
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Exporter/ExportItemsConverter.cs

@ -36,7 +36,13 @@ namespace ICSharpCode.Reports.Core.Exporter @@ -36,7 +36,13 @@ namespace ICSharpCode.Reports.Core.Exporter
return col;
}
/// <summary>
/// Convert a single item, Location is calculated as follows
/// (X = ParentRectangle.X + Item.X Y = offset.Y + Item.Y)
/// </summary>
/// <param name="offset"> only Y value is used, gives the offset to Items location.Y </param>
/// <param name="item">Item to convert</param>
/// <returns></returns>
private BaseExportColumn ConvertToLineItem (Point offset,BaseReportItem item)
{
if (item == null) {

101
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/Exporter/ExportItemsConverterFixture.cs

@ -0,0 +1,101 @@ @@ -0,0 +1,101 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 06.05.2010
* Time: 19:54
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using ICSharpCode.Reports.Core.Exporter;
using NUnit.Framework;
namespace ICSharpCode.Reports.Core.Test.Exporter
{
[TestFixture]
public class ExportItemsConverterFixture
{
[Test]
public void CanCreateExportItemsConverter()
{
IExportItemsConverter sut = new ExportItemsConverter();
Assert.IsNotNull(sut);
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void ConvertSimpleItems_Throw_On_Null_Items()
{
IExportItemsConverter sut = new ExportItemsConverter();
ExporterCollection ec = sut.ConvertSimpleItems(new Point (10,10),null);
}
[Test]
public void ConvertSimpleItems_To_Valid_Collection()
{
ReportItemCollection ri = new ReportItemCollection();
BaseReportItem r = new BaseTextItem(){
Location = new Point (10,10),
Size = new Size(20,100)
};
ri.Add(r);
IExportItemsConverter sut = new ExportItemsConverter();
ExporterCollection ec = sut.ConvertSimpleItems(new Point (10,10),ri);
Assert.IsNotNull(ec);
Assert.AreEqual(1,ec.Count);
}
[Test]
public void Convert_SimpleItems_Collection ()
{
ReportItemCollection ri = new ReportItemCollection();
Point itemLocation = new Point (10,10);
BaseReportItem r = new BaseTextItem(){
Location = itemLocation,
Size = new Size(20,100)
};
ri.Add(r);
IExportItemsConverter sut = new ExportItemsConverter();
Point offset = new Point(20,20);
//
Rectangle parentRectangle = new Rectangle (50,50,700,50);
sut.ParentRectangle = parentRectangle;
ExporterCollection ec = sut.ConvertSimpleItems(offset,ri);
BaseExportColumn be = ec[0];
// this.ParentRectangle.Location.X + lineItem.StyleDecorator.Location.X,
// lineItem.StyleDecorator.Location.Y + offset.Y);
Point resultLocation = new Point (parentRectangle.Location.X + itemLocation.X,itemLocation.Y + offset.Y);
Assert.AreEqual(resultLocation,be.StyleDecorator.Location);
}
[TestFixtureSetUp]
public void Init()
{
// TODO: Add Init code.
}
[TestFixtureTearDown]
public void Dispose()
{
// TODO: Add tear down code.
}
}
}

2
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/ICSharpCode.Reports.Core.Test.csproj

@ -73,6 +73,7 @@ @@ -73,6 +73,7 @@
<Compile Include="DataManager\IListDataManagerFixture.cs" />
<Compile Include="DataManager\MockDataAccess.cs" />
<Compile Include="DataManager\TableDataManagerFixture.cs" />
<Compile Include="Exporter\ExportItemsConverterFixture.cs" />
<Compile Include="Printing\SectionBoundFixture.cs" />
<Compile Include="Printing\Shapes\BaseLineFixture.cs" />
<Compile Include="Printing\Shapes\EllipseShapeFixture.cs" />
@ -115,6 +116,7 @@ @@ -115,6 +116,7 @@
<Folder Include="DataManager" />
<Folder Include="Collections" />
<Folder Include="BaseClasses" />
<Folder Include="Exporter" />
<Folder Include="Printing\Shapes" />
<Folder Include="TestHelpers" />
<Folder Include="Printing" />

Loading…
Cancel
Save