0
|
1 using System;
|
|
2 using BLToolkit.Data.Linq;
|
|
3
|
|
4 using NUnit.Framework;
|
|
5
|
|
6 namespace Data.Exceptions
|
|
7 {
|
|
8 using Linq;
|
|
9 using Linq.Model;
|
|
10
|
|
11 [TestFixture]
|
|
12 public class DmlTest : TestBase
|
|
13 {
|
|
14 [Test, ExpectedException(typeof(LinqException))]
|
|
15 public void InsertOrUpdate1()
|
|
16 {
|
|
17 try
|
|
18 {
|
|
19 ForEachProvider(db =>
|
|
20 db.Doctor.InsertOrUpdate(
|
|
21 () => new Doctor
|
|
22 {
|
|
23 PersonID = 10,
|
|
24 Taxonomy = "....",
|
|
25 },
|
|
26 p => new Doctor
|
|
27 {
|
|
28 Taxonomy = "...",
|
|
29 }));
|
|
30 }
|
|
31 catch (Exception ex)
|
|
32 {
|
|
33 Assert.IsTrue(ex.Message.StartsWith("InsertOrUpdate method requires the 'Doctor' table to have a primary key."));
|
|
34 throw;
|
|
35 }
|
|
36 }
|
|
37
|
|
38 [Test, ExpectedException(typeof(LinqException))]
|
|
39 public void InsertOrUpdate2()
|
|
40 {
|
|
41 try
|
|
42 {
|
|
43 ForEachProvider(db =>
|
|
44 db.Patient.InsertOrUpdate(
|
|
45 () => new Patient
|
|
46 {
|
|
47 Diagnosis = "....",
|
|
48 },
|
|
49 p => new Patient
|
|
50 {
|
|
51 Diagnosis = "...",
|
|
52 }));
|
|
53 }
|
|
54 catch (Exception ex)
|
|
55 {
|
|
56 Assert.IsTrue(ex.Message.StartsWith("InsertOrUpdate method requires the 'Patient.PersonID' field to be included in the insert setter."));
|
|
57 throw;
|
|
58 }
|
|
59 }
|
|
60 }
|
|
61 }
|