mono /mcs/class/System.Data.Linq/src/DbLinq/Test/Providers/DataLoadOptions_Test.cs

Language C# Lines 132
MD5 Hash bd052068f3c2cf76b928fdd050c0e1db Estimated Cost $2,839 (why?)
Repository https://bitbucket.org/danipen/mono.git View Raw File View Project SPDX
  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
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Test_NUnit;

using nwind;

#if MONO_STRICT
using System.Data.Linq;
#else
using DbLinq.Data.Linq;
#endif

namespace nwind
{
    public partial class Customer
    {
        public object ExtraneousMethod()
        {
            return null;
        }
    }
}

// test ns 
#if MYSQL
    namespace Test_NUnit_MySql
#elif ORACLE && ODP
    namespace Test_NUnit_OracleODP
#elif ORACLE
    namespace Test_NUnit_Oracle
#elif POSTGRES
    namespace Test_NUnit_PostgreSql
#elif SQLITE
    namespace Test_NUnit_Sqlite
#elif INGRES
    namespace Test_NUnit_Ingres
#elif MSSQL && L2SQL
    namespace Test_NUnit_MsSql_Strict
#elif MSSQL
    namespace Test_NUnit_MsSql
#elif FIREBIRD
    namespace Test_NUnit_Firebird
#endif
{
    [TestFixture]
    public class DataLoadOptions_Test : TestBase
    {
        static object ThrowException()
        {
            throw new ApplicationException();
        }

        [Test]
        [ExpectedException(typeof(InvalidOperationException))]
        public void LoadWith_BadExpression1()
        {
            new DataLoadOptions().LoadWith<Customer>(cc => cc.ExtraneousMethod());
        }

        [Test]
        [ExpectedException(typeof(InvalidOperationException))]
        public void LoadWith_BadExpression2()
        {
            new DataLoadOptions().LoadWith<Customer>(cc => 1);
        }

        [Test]
        [ExpectedException(typeof(InvalidOperationException))]
        public void LoadWith_BadExpression3()
        {
            new DataLoadOptions().LoadWith<Customer>(cc => ThrowException());
        }

        [Test]
        [ExpectedException(typeof(InvalidOperationException))]
        public void LoadWith_BadExpression4()
        {
            new DataLoadOptions().LoadWith<Customer>(cc => cc.Orders.Select(o => o));
        }

        [Test]
        [ExpectedException(typeof(InvalidOperationException))]
        public void LoadWith_BadExpression5()
        {
            new DataLoadOptions().LoadWith<Order> (o => o.Customer.Orders);
        }

#if !DEBUG && (MSSQL && !L2SQL)
        [Explicit]
#endif
        [Test]
        [ExpectedException(typeof(InvalidOperationException))]
        public void LoadWith_BadCycles1()
        {
            var lo = new DataLoadOptions();
            lo.LoadWith<Customer>(c => c.Orders);
            lo.LoadWith<Order>(o => o.Customer);
        }

#if !DEBUG && (MSSQL && !L2SQL)
        [Explicit]
#endif
        [Test]
        [ExpectedException(typeof(InvalidOperationException))]
        public void LoadWith_BadCycles2()
        {
            var lo = new DataLoadOptions();
            lo.LoadWith<Order>(o => o.Customer);
            lo.LoadWith<Customer>(c => c.Orders);
        }

        [Test]
        public void LoadWith_Good1()
        {
            var lo = new DataLoadOptions();
            lo.LoadWith<Customer>(c => c.Orders);
            lo.LoadWith<Order>(o => o.Employee);
        }

        [Test]
        public void LoadWith_Good2()
        {
            var lo = new DataLoadOptions();
            lo.LoadWith<Order>(o => o.Employee);
            lo.LoadWith<Customer>(c => c.Orders);
        }
    }
}
Back to Top