Browse Source

more UnitTest's

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@5778 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Peter Forstmeier 15 years ago
parent
commit
f520871e88
  1. 1
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/BaseItems/BaseTextItem.cs
  2. 36
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/BaseClasses/LayouterFixture.cs
  3. 66
      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. 41
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/Printing/SectionBoundFixture.cs
  6. 19
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/Printing/Shapes/RectangleShapeFixture.cs
  7. 32
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/TestHelpers/ConcernOf.cs

1
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/BaseItems/BaseTextItem.cs

@ -47,6 +47,7 @@ namespace ICSharpCode.Reports.Core @@ -47,6 +47,7 @@ namespace ICSharpCode.Reports.Core
return item;
}
protected TextStyleDecorator CreateItemStyle () {
TextStyleDecorator style = new TextStyleDecorator();

36
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/BaseClasses/LayouterFixture.cs

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 07.05.2010
* Time: 20:15
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using ICSharpCode.Reports.Core.Test.TestHelpers;
using NUnit.Framework;
namespace ICSharpCode.Reports.Core.Test.BaseClasses
{
[TestFixture]
public class LayouterForSectionFixture:ConcernOf<Layouter>
{
Bitmap bitmap;
Graphics graphics;
[Test]
public void CanCreateSUT()
{
Assert.IsNotNull(Sut);
}
public override void Setup()
{
bitmap = new Bitmap(1,1);
graphics = Graphics.FromImage(bitmap) ;
BaseSection section = new BaseSection();
Sut = new Layouter();
}
}
}

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

@ -11,12 +11,14 @@ using System; @@ -11,12 +11,14 @@ using System;
using System.Drawing;
using ICSharpCode.Reports.Core.Exporter;
using NUnit.Framework;
using ICSharpCode.Reports.Core.Test.TestHelpers;
namespace ICSharpCode.Reports.Core.Test.Exporter
{
[TestFixture]
public class ExportItemsConverterFixture
public class ExportItemsConverterFixture:ConcernOf<ExportItemsConverter>
{
[Test]
public void CanCreateExportItemsConverter()
{
@ -36,7 +38,7 @@ namespace ICSharpCode.Reports.Core.Test.Exporter @@ -36,7 +38,7 @@ namespace ICSharpCode.Reports.Core.Test.Exporter
[Test]
public void ConvertSimpleItems_To_Valid_Collection()
public void Convert_SimpleItems_Should_Return_Valid_Collection()
{
ReportItemCollection ri = new ReportItemCollection();
BaseReportItem r = new BaseTextItem(){
@ -54,7 +56,7 @@ namespace ICSharpCode.Reports.Core.Test.Exporter @@ -54,7 +56,7 @@ namespace ICSharpCode.Reports.Core.Test.Exporter
[Test]
public void Convert_SimpleItems_Collection ()
public void Convert_SimpleItems_Should_Calculate_Correct_Locations ()
{
ReportItemCollection ri = new ReportItemCollection();
Point itemLocation = new Point (10,10);
@ -63,14 +65,13 @@ namespace ICSharpCode.Reports.Core.Test.Exporter @@ -63,14 +65,13 @@ namespace ICSharpCode.Reports.Core.Test.Exporter
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;
Sut.ParentRectangle = parentRectangle;
ExporterCollection ec = sut.ConvertSimpleItems(offset,ri);
ExporterCollection ec = Sut.ConvertSimpleItems(offset,ri);
BaseExportColumn be = ec[0];
@ -84,18 +85,57 @@ namespace ICSharpCode.Reports.Core.Test.Exporter @@ -84,18 +85,57 @@ namespace ICSharpCode.Reports.Core.Test.Exporter
}
[Test]
public void Convert_Container_Should_Return_ExportContainer ()
{
ReportItemCollection ri = new ReportItemCollection();
Point itemLocation = new Point (10,10);
BaseRowItem row = new BaseRowItem() {
Location = itemLocation
};
Point offset = new Point(20,20);
Rectangle parentRectangle = new Rectangle (50,50,700,50);
Sut.ParentRectangle = parentRectangle;
var exportContainer = Sut.ConvertToContainer(offset,row);
Assert.IsAssignableFrom(typeof(ExportContainer),exportContainer);
}
[TestFixtureSetUp]
public void Init()
[Test]
public void Convert_Container_Should_Calculate_Correct_Locations()
{
// TODO: Add Init code.
ReportItemCollection ri = new ReportItemCollection();
Point itemLocation = new Point (10,10);
BaseRowItem row = new BaseRowItem() {
Location = itemLocation
};
Point offset = new Point(20,20);
Rectangle parentRectangle = new Rectangle (50,50,700,50);
Sut.ParentRectangle = parentRectangle;
var exportContainer = Sut.ConvertToContainer(offset,row);
Point containerLoction = new Point (itemLocation.X, offset.Y);
Assert.AreEqual(containerLoction,exportContainer.StyleDecorator.Location);
}
[TestFixtureTearDown]
public void Dispose()
public override void Setup()
{
// TODO: Add tear down code.
Sut = new ExportItemsConverter();
}
}
}

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

@ -57,6 +57,7 @@ @@ -57,6 +57,7 @@
<ItemGroup>
<Compile Include="BaseClasses\AbstractColumnFixture.cs" />
<Compile Include="BaseClasses\GroupColumnFixture.cs" />
<Compile Include="BaseClasses\LayouterFixture.cs" />
<Compile Include="BaseClasses\Parameters.cs" />
<Compile Include="BaseClasses\SortColumnFixture.cs" />
<Compile Include="BaseItems\BaseDataItemFixture.cs" />
@ -99,6 +100,7 @@ @@ -99,6 +100,7 @@
<Compile Include="ReportModelFixture.cs" />
<Compile Include="ReportSettings\ReportSettingsFixture.cs" />
<Compile Include="TestHelpers\AggregateFuctionHelper.cs" />
<Compile Include="TestHelpers\ConcernOf.cs" />
<Compile Include="TestHelpers\ContributorsList.cs" />
<EmbeddedResource Include="Resources\ArtikelSchema_Data.xsd" />
</ItemGroup>

41
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/Printing/SectionBoundFixture.cs

@ -9,16 +9,15 @@ @@ -9,16 +9,15 @@
using System;
using System.Drawing;
using ICSharpCode.Reports.Core.Test.TestHelpers;
using NUnit.Framework;
namespace ICSharpCode.Reports.Core.Test.Printing
{
[TestFixture]
public class SectionBoundFixture
public class SectionBoundFixture:ConcernOf<SectionBounds>
{
private SectionBounds sectionBounds;
[Test]
public void Can_Read_SectionBounds ()
{
@ -47,7 +46,7 @@ namespace ICSharpCode.Reports.Core.Test.Printing @@ -47,7 +46,7 @@ namespace ICSharpCode.Reports.Core.Test.Printing
[Test]
public void CheckForGap ()
{
Assert.AreEqual(1,this.sectionBounds.Gap);
Assert.AreEqual(1,Sut.Gap);
}
#region MeasureReportHeader
@ -56,7 +55,7 @@ namespace ICSharpCode.Reports.Core.Test.Printing @@ -56,7 +55,7 @@ namespace ICSharpCode.Reports.Core.Test.Printing
[ExpectedException(typeof(ArgumentNullException))]
public void MeasureReportHeaderThrowsIfSectionIsNull()
{
this.sectionBounds.MeasureReportHeader(null);
Sut.MeasureReportHeader(null);
}
@ -101,10 +100,10 @@ namespace ICSharpCode.Reports.Core.Test.Printing @@ -101,10 +100,10 @@ namespace ICSharpCode.Reports.Core.Test.Printing
BaseSection bs = new BaseSection();
bs.Location = new Point (50,50);
bs.Size = new Size (727,60);
this.sectionBounds.MeasureReportHeader(bs);
Assert.AreEqual(0,this.sectionBounds.ReportHeaderRectangle.Size.Height);
int a = this.sectionBounds.MarginBounds.Width;
Assert.AreEqual(this.sectionBounds.MarginBounds.Width,this.sectionBounds.ReportHeaderRectangle.Width);
Sut.MeasureReportHeader(bs);
Assert.AreEqual(0,Sut.ReportHeaderRectangle.Size.Height);
int a = Sut.MarginBounds.Width;
Assert.AreEqual(Sut.MarginBounds.Width,Sut.ReportHeaderRectangle.Width);
}
#endregion
@ -115,7 +114,7 @@ namespace ICSharpCode.Reports.Core.Test.Printing @@ -115,7 +114,7 @@ namespace ICSharpCode.Reports.Core.Test.Printing
[ExpectedException(typeof(ArgumentNullException))]
public void MeasurePageHeaderThrowsIfSectionIsNull()
{
this.sectionBounds.MeasurePageHeader(null);
Sut.MeasurePageHeader(null);
}
@ -143,7 +142,7 @@ namespace ICSharpCode.Reports.Core.Test.Printing @@ -143,7 +142,7 @@ namespace ICSharpCode.Reports.Core.Test.Printing
[ExpectedException(typeof(ArgumentNullException))]
public void MeasurePageFooterThrowsIfSectionIsNull()
{
this.sectionBounds.MeasurePageFooter(null);
Sut.MeasurePageFooter(null);
}
@ -174,7 +173,7 @@ namespace ICSharpCode.Reports.Core.Test.Printing @@ -174,7 +173,7 @@ namespace ICSharpCode.Reports.Core.Test.Printing
[ExpectedException(typeof(ArgumentNullException))]
public void MeasureReportFooterThrowsIfSectionIsNull()
{
this.sectionBounds.MeasureReportFooter(null);
Sut.MeasureReportFooter(null);
}
[Test]
@ -233,22 +232,10 @@ namespace ICSharpCode.Reports.Core.Test.Printing @@ -233,22 +232,10 @@ namespace ICSharpCode.Reports.Core.Test.Printing
Assert.AreEqual(p,sectionBounds.DetailEnds);
}
#region Setup/Teardown
[TestFixtureSetUp]
public void Init()
public override void Setup()
{
ReportSettings rs = new ReportSettings();
this.sectionBounds = new SectionBounds(rs,false);
}
[TestFixtureTearDown]
public void Dispose()
{
// TODO: Add tear down code.
Sut = new SectionBounds(rs,false);
}
#endregion
}
}

19
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/Printing/Shapes/RectangleShapeFixture.cs

@ -10,12 +10,14 @@ @@ -10,12 +10,14 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using ICSharpCode.Reports.Core.Test.TestHelpers;
using NUnit.Framework;
namespace ICSharpCode.Reports.Core.Test.Printing.Shapes
{
[TestFixture]
public class RectangleShapeFixture
public class RectangleShapeFixture:ConcernOf<RectangleShape>
{
[Test]
public void CreateLineShape()
@ -29,22 +31,19 @@ namespace ICSharpCode.Reports.Core.Test.Printing.Shapes @@ -29,22 +31,19 @@ namespace ICSharpCode.Reports.Core.Test.Printing.Shapes
[ExpectedException(typeof(NotImplementedException))]
public void RectangleThrow()
{
RectangleShape ls = new RectangleShape();
Point from = new Point (1,1);
Point to = new Point (10,10);
GraphicsPath p = ls.CreatePath(from,to);
GraphicsPath p = Sut.CreatePath(from,to);
}
[Test]
public void CheckGraphicsPathBounds()
{
RectangleShape ls = new RectangleShape();
Point from = new Point(1,1);
Size size = new Size (10,10);
Rectangle rect = new Rectangle (from,size);
GraphicsPath p = ls.CreatePath(rect);
GraphicsPath p = Sut.CreatePath(rect);
RectangleF r = p.GetBounds();
Assert.AreEqual(from.X,r.Left);
Assert.AreEqual(from.Y,r.Top);
@ -56,13 +55,17 @@ namespace ICSharpCode.Reports.Core.Test.Printing.Shapes @@ -56,13 +55,17 @@ namespace ICSharpCode.Reports.Core.Test.Printing.Shapes
[Test]
public void CheckLastPointFromPath()
{
RectangleShape ls = new RectangleShape();
Point from = new Point(1,1);
Size size = new Size (10,10);
Rectangle rect = new Rectangle (from,size);
GraphicsPath p = ls.CreatePath(rect);
GraphicsPath p = Sut.CreatePath(rect);
PointF last = p.GetLastPoint();
Assert.AreEqual(new Point (from.X ,from.Y + size.Height), Point.Truncate(last));
}
public override void Setup()
{
Sut = new RectangleShape();
}
}
}

32
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/TestHelpers/ConcernOf.cs

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 07.05.2010
* Time: 19:25
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using NUnit.Framework;
namespace ICSharpCode.Reports.Core.Test.TestHelpers
{
/// <summary>
/// Description of ConcernOf.
/// </summary>
public abstract class ConcernOf<T>
{
protected ConcernOf()
{
// MockRepository = new MockRepository();
}
public T Sut { get; set; }
// public MockRepository MockRepository { get; private set; }
[SetUp]
public abstract void Setup();
}
}
Loading…
Cancel
Save