Skip to content

Commit

Permalink
Updated tests to removed ExpectedException and replace it with NUnit'…
Browse files Browse the repository at this point in the history
…s 2.5 approach to doing this, described at http://mint.litemedia.se/2009/05/30/new-expectedexception-model-in-nunit-25/.  Also updated a couple of version references within csproj files.
  • Loading branch information
wmccafferty committed Jun 16, 2009
1 parent 68a3a56 commit c819067
Show file tree
Hide file tree
Showing 25 changed files with 17 additions and 12 deletions.
Binary file modified bin/SharpArch.Core.NHibernateValidator.dll
Binary file not shown.
Binary file modified bin/SharpArch.Core.NHibernateValidator.pdb
Binary file not shown.
Binary file modified bin/SharpArch.Core.dll
Binary file not shown.
Binary file modified bin/SharpArch.Core.pdb
Binary file not shown.
Binary file modified bin/SharpArch.Data.dll
Binary file not shown.
Binary file modified bin/SharpArch.Data.pdb
Binary file not shown.
Binary file modified bin/SharpArch.Testing.NUnit.dll
Binary file not shown.
Binary file modified bin/SharpArch.Testing.NUnit.pdb
Binary file not shown.
Binary file modified bin/SharpArch.Testing.dll
Binary file not shown.
Binary file modified bin/SharpArch.Testing.pdb
Binary file not shown.
Binary file modified bin/SharpArch.Wcf.dll
Binary file not shown.
Binary file modified bin/SharpArch.Wcf.pdb
Binary file not shown.
Binary file modified bin/SharpArch.WcfClient.Castle.dll
Binary file not shown.
Binary file modified bin/SharpArch.WcfClient.Castle.pdb
Binary file not shown.
Binary file modified bin/SharpArch.Web.Castle.dll
Binary file not shown.
Binary file modified bin/SharpArch.Web.Castle.pdb
Binary file not shown.
Binary file modified bin/SharpArch.Web.dll
Binary file not shown.
Binary file modified bin/SharpArch.Web.pdb
Binary file not shown.
Expand Up @@ -33,7 +33,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="NHibernate.Validator, Version=1.0.0.4000, Culture=neutral, PublicKeyToken=70154e18752585bd, processorArchitecture=MSIL">
<Reference Include="NHibernate.Validator, Version=1.2.0.1004, Culture=neutral, PublicKeyToken=70154e18752585bd, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\bin\NHibernate.Validator.dll</HintPath>
</Reference>
Expand Down
2 changes: 1 addition & 1 deletion src/SharpArch/SharpArch.Core/DomainModel/ValueObject.cs
Expand Up @@ -29,7 +29,7 @@ public abstract class ValueObject : BaseObject
IEnumerable<PropertyInfo> invalidlyDecoratedProperties = GetType().GetProperties()
.Where(p => Attribute.IsDefined(p, typeof(DomainSignatureAttribute), true));

Check.Ensure(!invalidlyDecoratedProperties.Any(),
Check.Require(!invalidlyDecoratedProperties.Any(),
"Properties were found within " + GetType() + @" having the
[DomainSignature] attribute. The domain signature of a value object includes all
of the properties of the object by convention; consequently, adding [DomainSignature]
Expand Down
2 changes: 1 addition & 1 deletion src/SharpArch/SharpArch.Data/SharpArch.Data.csproj
Expand Up @@ -37,7 +37,7 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\bin\FluentNHibernate.dll</HintPath>
</Reference>
<Reference Include="NHibernate, Version=2.0.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
<Reference Include="NHibernate, Version=2.1.0.2001, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\bin\NHibernate.dll</HintPath>
</Reference>
Expand Down
Expand Up @@ -70,11 +70,13 @@ public class HasUniqueObjectSignatureValidatorTests
}

[Test]
[ExpectedException(typeof(PreconditionException))]
public void MayNotUseValidatorWithEntityHavingDifferentIdType() {
ObjectWithStringIdAndValidatorForIntId invalidCombination =
new ObjectWithStringIdAndValidatorForIntId() { Name = "whatever" };
IEnumerable<IValidationResult> invalidValues = invalidCombination.ValidationResults();

Assert.Throws<PreconditionException>(
() => invalidCombination.ValidationResults()
);
}

private class DuplicateCheckerStub : IEntityDuplicateChecker
Expand Down
Expand Up @@ -13,15 +13,17 @@ public class DesignByContractTests
}

[Test]
[ExpectedException(typeof(PreconditionException))]
public void CanEnforcePrecondition() {
Assert.AreEqual("-20%", ConvertToPercentage(-.2m));
Assert.Throws<PreconditionException>(
() => ConvertToPercentage(-.2m)
);
}

[Test]
[ExpectedException(typeof(PostconditionException))]
public void CanEnforcePostcondition() {
Assert.AreEqual("200%", ConvertToPercentage(2m));
Assert.Throws<PostconditionException>(
() => ConvertToPercentage(2m)
);
}

private string ConvertToPercentage(decimal fractionalPercentage) {
Expand Down
Expand Up @@ -8,12 +8,13 @@ namespace Tests.SharpArch.Core.DomainModel
public class ValueObjectTests
{
[Test]
[ExpectedException(typeof(PostconditionException))]
public void CannotHaveValueObjectWithDomainSignatureProperties() {
ValueObjectWithDomainSignature invalidValueObject =
new ValueObjectWithDomainSignature();

invalidValueObject.GetSignatureProperties();
Assert.Throws<PreconditionException>(
() => invalidValueObject.GetSignatureProperties()
);
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion src/SharpArch/SharpArch.Web/SharpArch.Web.csproj
Expand Up @@ -43,7 +43,7 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\bin\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NHibernate, Version=2.0.0.2001, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
<Reference Include="NHibernate, Version=2.1.0.2001, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\bin\NHibernate.dll</HintPath>
</Reference>
Expand Down

0 comments on commit c819067

Please sign in to comment.