Skip to content

Commit

Permalink
wrote test for icollection-has-any-assertion.. but works without modi…
Browse files Browse the repository at this point in the history
…fication.

fixes mrpinkzh#22
  • Loading branch information
mrpinkzh committed Mar 30, 2016
1 parent 8021bff commit e23722f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions ExAs.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<s:String x:Key="/Default/CodeEditing/GenerateMemberBody/AccessorImplementationKind/@EntryValue">BackingField</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeThisQualifier/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ThisQualifier/INSTANCE_MEMBERS_QUALIFY_MEMBERS/@EntryValue">None</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/AddImportsToDeepestScope/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String></wpf:ResourceDictionary>
49 changes: 49 additions & 0 deletions tests/ExAs.Tests/Api/Collections/Collection_HasAny_Feature.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ExAs.Utils;
using ExAs.Utils.StringExtensions;
using NUnit.Framework;
using static ExAs.Utils.Creation.CreateNinjas;
using static ExAs.Utils.Dates;

namespace ExAs.Api.Collections
{
[TestFixture]
public class Collection_HasAny_Feature
{
[Test]
public void ExpectingNarutosDojo_OnCityWithNarutosDojo_ShouldSucceed()
{
// act
var result = CityWithDojo().Evaluate(
c => c.Member(x => x.DojoCollection).HasAny(
d => d.Member(x => x.Master).Fulfills(n => n.Member(x => x.Name).IsEqualTo("Naruto")
.Member(x => x.Age) .IsEqualTo(12))
.Member(x => x.Founded).IsOnSameDayAs(StandardDay())));

// assert
result.ExAssert(r => r.p(x => x.succeeded).IsTrue()
.p(x => x.PrintLog()).IsEqualTo("CollectionCity: ( )DojoCollection = <1 match> (expected: at least 1 match)".NewLine()
.Add(" Dojo: ( )Master = Ninja: ( )Name = 'Naruto' (expected: 'Naruto')").NewLine()
.Add(" ( )Age = 12 (expected: 12)").NewLine()
.Add(" ( )Founded = 11/16/1984 (expected: 11/16/1984)")));

}

private static CollectionCity CityWithDojo()
{
return new CollectionCity(new Dojo(Naruto(), StandardDay()));
}

private class CollectionCity : City
{
public CollectionCity(params Dojo[] dojos) : base(dojos) { }

public ICollection<Dojo> DojoCollection
{
get { return this.Dojos.ToList(); }
}
}
}
}
1 change: 1 addition & 0 deletions tests/ExAs.Tests/ExAs.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Api\BooleanAssertionFeature.cs" />
<Compile Include="Api\Collections\Collection_HasAny_Feature.cs" />
<Compile Include="Api\DateTimeAssertionFeature.cs" />
<Compile Include="Api\DirectEnumerableAssertionFeature.cs" />
<Compile Include="Api\DoubleAssertionFeature.cs" />
Expand Down

0 comments on commit e23722f

Please sign in to comment.