Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog/6.0.6_dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[main] Fixed possible cases of broken serialization due to comparers
50 changes: 23 additions & 27 deletions Extensions/Xtensive.Orm.Reprocessing.Tests/Tests/Other.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System.Linq;
using System.Linq;
using System.Transactions;
using NUnit.Framework;
using TestCommon.Model;
using Xtensive.Orm.Configuration;
using Xtensive.Orm.Reprocessing.Configuration;

namespace Xtensive.Orm.Reprocessing.Tests
{
Expand All @@ -13,27 +12,25 @@ private class TestExecuteStrategy : HandleUniqueConstraintViolationStrategy
{
#region Non-public methods

protected override bool OnError(ExecuteErrorEventArgs context)
{
return context.Attempt < 2;
}
protected override bool OnError(ExecuteErrorEventArgs context) => context.Attempt < 2;

#endregion
}

[Test]
public void ExecuteStrategy()
{
int i = 0;
var i = 0;
try {
ReprocessingConfiguration config = Domain.GetReprocessingConfiguration();
var config = Domain.GetReprocessingConfiguration();
config.DefaultExecuteStrategy = typeof (TestExecuteStrategy);
Domain.Execute(
session => {
new Foo(session) {Name = "test"};
_ = new Foo(session) {Name = "test"};
i++;
if (i < 5)
new Foo(session) {Name = "test"};
if (i < 5) {
_ = new Foo(session) {Name = "test"};
}
});
}
catch {
Expand All @@ -55,41 +52,40 @@ public void NestedNewSession()
[Test]
public void NestedSessionReuse()
{
Domain.Execute(session1 => Domain.Execute(session2 => Assert.That(session1, Is.SameAs(session2))));
Domain.Execute(session1 =>
Domain.WithSession(session1)
.Execute(session2 => Assert.That(session1, Is.SameAs(session2))));
}

[Test]
public void Test()
{
Domain.Execute(session => {
new Foo(session);
_ = new Foo(session);
});
Domain.Execute(session => {
session.Query.All<Foo>().ToArray();
_ = session.Query.All<Foo>().ToArray();
Domain.WithIsolationLevel(IsolationLevel.Serializable).Execute(session2 => {
session2.Query.All<Foo>().ToArray();
_ = session2.Query.All<Foo>().ToArray();
});
});
}

[Test]
public void ParentIsDisconnectedState()
{
Domain.Execute(session =>
{
new Bar(session);
});
Domain.Execute(session => {
_ = new Bar(session);
});
using (var session = Domain.OpenSession(new SessionConfiguration(SessionOptions.ClientProfile)))
using(session.Activate())
{
using(session.Activate()) {
var bar = session.Query.All<Bar>().FirstOrDefault();
bar=new Bar(session);
bar = new Bar(session);
session.SaveChanges();
Domain.Execute(session1 =>
{
bar = session1.Query.All<Bar>().FirstOrDefault();
bar=new Bar(session1);
});
Domain.WithSession(session).Execute(session1 => {
bar = session1.Query.All<Bar>().FirstOrDefault();
bar = new Bar(session1);
});
session.SaveChanges();
}
Domain.Execute(session => Assert.That(session.Query.All<Bar>().Count(), Is.EqualTo(3)));
Expand Down
Loading