comparison UnitTests/Linq/Exceptions/Aggregation.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 using System;
2 using System.Linq;
3
4 using NUnit.Framework;
5
6 namespace Data.Exceptions
7 {
8 using Linq;
9
10 [TestFixture]
11 public class Aggregtion : TestBase
12 {
13 [Test, ExpectedException(typeof(InvalidOperationException))]
14 public void NonNullableMax1()
15 {
16 ForEachProvider(typeof(InvalidOperationException), db =>
17 {
18 var value = db.Parent.Where(_ => _.ParentID < 0).Max(_ => _.ParentID);
19 });
20 }
21
22 [Test]
23 public void NonNullableMax2()
24 {
25 ForEachProvider(db =>
26 {
27 var q =
28 from p in db.Parent
29 select new
30 {
31 max = p.Children.Where(_ => _.ParentID < 0).Max(_ => _.ParentID)
32 };
33
34 Assert.Catch<InvalidOperationException>(() => q.ToList());
35 });
36 }
37
38 [Test, ExpectedException(typeof(InvalidOperationException))]
39 public void NonNullableAverage()
40 {
41 ForEachProvider(typeof(InvalidOperationException), db =>
42 {
43 var value = db.Parent.Where(_ => _.ParentID < 0).Average(_ => _.ParentID);
44 });
45 }
46 }
47 }