Permalink
Browse files

Linq/ProjectionsTests.cs: Make tests independent of id generation str…

…ategy.
  • Loading branch information...
1 parent 8439190 commit f357194d3db87a0f44a72d3d96894b5d31e30aed @oskarb oskarb committed Mar 17, 2012
Showing with 12 additions and 14 deletions.
  1. +12 −14 src/NHibernate.Test/Linq/ProjectionsTests.cs
@@ -242,7 +242,7 @@ public void CanProjectComplexDictionaryIndexer()
var query = from item in db.Users
select new
{
- index = Array.IndexOf(lookup[item.Id].Codes, item.Id, 0) / 7,
+ index = Array.IndexOf(lookup[item.Id % 4].Codes, item.Id % 4, 0) / 7,
};
var result = query.ToList();
@@ -258,7 +258,7 @@ public void CanProjectComplexParameterDictionaryIndexer()
var query = from item in db.Users
select new
{
- index = lookup[item.Id],
+ index = lookup[item.Id % 4],
};
var result = query.ToList();
@@ -274,7 +274,7 @@ public void CanProjectParameterDictionaryIndexer()
var query = from item in db.Users
select new
{
- index = lookup[item.Id],
+ index = lookup[item.Id % 4],
};
var result = query.ToList();
@@ -290,7 +290,7 @@ public void CanProjectParameterDictionaryContainsKey()
var query = from item in db.Users
select new
{
- index = lookup.ContainsKey(item.Id),
+ isPresent = lookup.ContainsKey(item.Id),
};
var result = query.ToList();
@@ -306,7 +306,7 @@ public void CanProjectParameterArrayContains()
var query = from item in db.Users
select new
{
- index = lookup.Contains(item.Id),
+ isPresent = lookup.Contains(item.Id),
};
var result = query.ToList();
@@ -322,7 +322,7 @@ public void CanProjectParameterStringContains()
var query = from item in db.Users
select new
{
- index = lookup.Contains(item.Id),
+ isPresent = lookup.Contains(item.Id),
};
var result = query.ToList();
@@ -339,18 +339,16 @@ public void CanProjectParameterSubstring()
var query = from item in db.Users
select new
{
- Value = value.Substring(item.Id),
+ Start = item.Id % 10,
+ Value = value.Substring(item.Id % 10),
};
- var result = query.ToList()
- .Select(x => x.Value)
- .OrderBy(x => x)
- .ToList();
+ var result = query.ToList();
Assert.That(result.Count, Is.EqualTo(3));
- Assert.That(result[0], Is.EqualTo("234567890"));
- Assert.That(result[1], Is.EqualTo("34567890"));
- Assert.That(result[2], Is.EqualTo("4567890"));
+ Assert.That(result[0].Value, Is.EqualTo(value.Substring(result[0].Start)));
+ Assert.That(result[1].Value, Is.EqualTo(value.Substring(result[1].Start)));
+ Assert.That(result[2].Value, Is.EqualTo(value.Substring(result[2].Start)));
}
private string FormatName(string name, DateTime? lastLoginDate)

0 comments on commit f357194

Please sign in to comment.