forked from mrpinkzh/exas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wrote test for icollection-has-any-assertion.. but works without modi…
…fication. fixes mrpinkzh#22
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/ExAs.Tests/Api/Collections/Collection_HasAny_Feature.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); } | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters