-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathIssueJira0222_GroupByBooleanColumn.cs
More file actions
62 lines (53 loc) · 1.64 KB
/
IssueJira0222_GroupByBooleanColumn.cs
File metadata and controls
62 lines (53 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (C) 2011 Xtensive LLC.
// All rights reserved.
// For conditions of distribution and use, see license.
// Created by: Denis Krjuchkov
// Created: 2011.11.22
using System.Linq;
using NUnit.Framework;
using Xtensive.Orm.Configuration;
using Xtensive.Orm.Tests.Issues.IssueJira0222_GroupByBooleanColumnModel;
namespace Xtensive.Orm.Tests.Issues.IssueJira0222_GroupByBooleanColumnModel
{
[HierarchyRoot]
public class Message : Entity
{
[Field, Key]
public int Id { get; private set; }
[Field]
public bool IsReceived { get; set; }
}
}
namespace Xtensive.Orm.Tests.Issues
{
public class IssueJira0222_GroupByBooleanColumn : AutoBuildTest
{
protected override DomainConfiguration BuildConfiguration()
{
var config = base.BuildConfiguration();
config.Types.Register(typeof (Message).Assembly, typeof (Message).Namespace);
return config;
}
[Test]
public void MainTest()
{
using (Domain.OpenSession()) {
using (var t = Session.Current.OpenTransaction()) {
new Message {IsReceived = true};
new Message {IsReceived = true};
new Message {IsReceived = false};
var result = Query.All<Message>()
.GroupBy(m => m.IsReceived)
.OrderBy(g => g.Key)
.Select(g => new {IsReceived = g.Key, Count = g.Count()})
.ToList();
var trueResult = result.Single(item => item.IsReceived).Count;
var falseResult = result.Single(item => !item.IsReceived).Count;
Assert.AreEqual(2, trueResult);
Assert.AreEqual(1, falseResult);
// Rollback
}
}
}
}
}