diff UnitTests/Linq/Exceptions/DmlTest.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UnitTests/Linq/Exceptions/DmlTest.cs	Thu Mar 27 21:46:09 2014 +0400
@@ -0,0 +1,61 @@
+using System;
+using BLToolkit.Data.Linq;
+
+using NUnit.Framework;
+
+namespace Data.Exceptions
+{
+	using Linq;
+	using Linq.Model;
+
+	[TestFixture]
+	public class DmlTest : TestBase
+	{
+		[Test, ExpectedException(typeof(LinqException))]
+		public void InsertOrUpdate1()
+		{
+			try
+			{
+				ForEachProvider(db =>
+					db.Doctor.InsertOrUpdate(
+						() => new Doctor
+						{
+							PersonID  = 10,
+							Taxonomy = "....",
+						},
+						p => new Doctor
+						{
+							Taxonomy = "...",
+						}));
+			}
+			catch (Exception ex)
+			{
+				Assert.IsTrue(ex.Message.StartsWith("InsertOrUpdate method requires the 'Doctor' table to have a primary key."));
+				throw;
+			}
+		}
+
+		[Test, ExpectedException(typeof(LinqException))]
+		public void InsertOrUpdate2()
+		{
+			try
+			{
+				ForEachProvider(db =>
+					db.Patient.InsertOrUpdate(
+						() => new Patient
+						{
+							Diagnosis = "....",
+						},
+						p => new Patient
+						{
+							Diagnosis = "...",
+						}));
+			}
+			catch (Exception ex)
+			{
+				Assert.IsTrue(ex.Message.StartsWith("InsertOrUpdate method requires the 'Patient.PersonID' field to be included in the insert setter."));
+				throw;
+			}
+		}
+	}
+}