Hello,
I've been running mssql nunit tests, and noticed that there are about
160 failures, which look pretty much. (I guess, those failures also
happen on you guys' machines.)
So I have started to fix couple of bugs to practically start
implementing our missing bits mainly in System.Data.Linq functionality.
The first patch fixes the following tests in Test_NUnit_MsSql:
- Test_NUnit_MsSql.EntitySet.Add
- Test_NUnit_MsSql.WriteTest.G1_InsertProduct
- Test_NUnit_MsSql.WriteTest.G2_DeleteTest
Note that it is *not* Test_NUnit_MsSql_Strict i.e. I ran this as dblinq
tests but with System.Data.Linq.dll of MONO_STRICT mode.
And since the fix is in EntitySet.cs, and this change didn't seem to fix
any nunit tests under .NET, the fixes are actually only for MONO_STRICT.
(complicated? yeees it is :/)
I have added a few more tests for EntitySet that are verified on both
under .NET and mono.
If they look fine, I'll commit them later. And similar compatibility
fixes will follow. (Right now I'm fixing test failures that happens only
under mono. Those failures likely show bugs in things in
System.Data.Linq.dll i.e. things that we implement, not .NET ones).
Atsushi Eno
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DbLinq" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/dblinq?hl=en
-~----------~----~----~----~------~----~------~--~---
Index: src/DbLinq/Data/Linq/EntitySet.cs
===================================================================
--- src/DbLinq/Data/Linq/EntitySet.cs (revision 947)
+++ src/DbLinq/Data/Linq/EntitySet.cs (working copy)
@@ -121,8 +121,10 @@
/// </summary>
public void Add(TEntity entity)
{
+ if (Contains (entity))
+ return;
+ sourceAsList.Add(entity);
OnAdd(entity);
- sourceAsList.Add(entity);
}
[DbLinqToDo]
@@ -155,6 +157,8 @@
/// <param name="entity">The entity.</param>
public void Insert(int index, TEntity entity)
{
+ if (Contains(entity))
+ throw new ArgumentOutOfRangeException();
OnAdd(entity);
sourceAsList.Insert(index, entity);
}
@@ -266,8 +270,11 @@
{
if (value is TEntity)
{
- this.Add(value as TEntity);
- return this.IndexOf(value as TEntity);
+ var v = value as TEntity;
+ if (this.IndexOf(v) >= 0)
+ throw new ArgumentOutOfRangeException();
+ this.Add(v);
+ return this.Count - 1;
}
else
throw new NotSupportedException();
@@ -377,10 +384,9 @@
{
foreach (var entity in collection)
{
- OnAdd(entity);
+ Add(entity);
}
}
- sourceAsList.AddRange(collection);
}
/// <summary>
Index: tests/Test_NUnit/ReadTests_EntitySet.cs
===================================================================
--- tests/Test_NUnit/ReadTests_EntitySet.cs (revision 947)
+++ tests/Test_NUnit/ReadTests_EntitySet.cs (working copy)
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -270,12 +271,31 @@
{
var db = CreateDB();
var customer = db.Customers.First();
+ Assert.AreEqual("jacques", customer.ContactName, "#1");
int beforeCount = customer.Orders.Count;
- customer.Orders.Add(new Order());
- Assert.AreEqual(customer.Orders.Count, beforeCount + 1);
+ Assert.AreEqual(1, beforeCount, "#2");
+ var order = new Order();
+ customer.Orders.Add(order);
+ Assert.AreEqual(beforeCount + 1, customer.Orders.Count, "#3");
+ customer.Orders.Add(order); // do not actually add
+ Assert.AreEqual(beforeCount + 1, customer.Orders.Count, "#4");
}
[Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void IList_Add()
+ {
+ var db = CreateDB();
+ var customer = db.Customers.First();
+ Assert.AreEqual("jacques", customer.ContactName, "#1");
+ int beforeCount = customer.Orders.Count;
+ Assert.AreEqual(1, beforeCount, "#2");
+ var order = new Order();
+ ((IList)customer.Orders).Add(order);
+ ((IList)customer.Orders).Add(order); // raises
ArgumentOutOfRangeException for duplicate
+ }
+
+ [Test]
public void Clear()
{
var db = CreateDB();
@@ -294,8 +314,11 @@
var db = CreateDB();
var customer = db.Customers.First();
int beforeCount = customer.Orders.Count;
- customer.Orders.AddRange(new Order[] { new Order(), new Order() });
- Assert.AreEqual(customer.Orders.Count, beforeCount + 2);
+ var order = new Order();
+ customer.Orders.AddRange(new Order[] { order, new Order() });
+ Assert.AreEqual(beforeCount + 2, customer.Orders.Count);
+ customer.Orders.AddRange(new Order[] { new Order(), order }); //
one is existing -> not added
+ Assert.AreEqual(beforeCount + 3, customer.Orders.Count);
}
[Test]