Skip to content

Commit a73a926

Browse files
Generate async files
1 parent d303c59 commit a73a926

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

src/NHibernate.Test/Async/CacheTest/JsonSerializerCacheFixture.cs

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public class JsonSerializerCacheFixtureAsync : TestCase
3030
protected override string[] Mappings => new[]
3131
{
3232
"CacheTest.ReadOnly.hbm.xml",
33-
"CacheTest.ReadWrite.hbm.xml"
33+
"CacheTest.ReadWrite.hbm.xml",
34+
"CacheTest.NonStrictReadWrite.hbm.xml"
3435
};
3536

3637
protected override string MappingsAssembly => "NHibernate.Test";
@@ -46,7 +47,7 @@ protected override void Configure(Configuration configuration)
4647
serializer.RegisterType(typeof(Tuple<string, object>), "tso");
4748
CoreDistributedCacheProvider.DefaultSerializer = serializer;
4849
}
49-
50+
5051
protected override void OnSetUp()
5152
{
5253
using (var s = Sfi.OpenSession())
@@ -55,36 +56,27 @@ protected override void OnSetUp()
5556
var totalItems = 6;
5657
for (var i = 1; i <= totalItems; i++)
5758
{
58-
var parent = new ReadOnly
59-
{
60-
Name = $"Name{i}"
61-
};
59+
var parent = new ReadOnly { Name = $"Name{i}" };
6260
for (var j = 1; j <= totalItems; j++)
6361
{
64-
var child = new ReadOnlyItem
65-
{
66-
Parent = parent
67-
};
68-
parent.Items.Add(child);
62+
parent.Items.Add(new ReadOnlyItem { Parent = parent });
6963
}
7064
s.Save(parent);
7165
}
7266
for (var i = 1; i <= totalItems; i++)
7367
{
74-
var parent = new ReadWrite
75-
{
76-
Name = $"Name{i}"
77-
};
68+
var parent = new ReadWrite { Name = $"Name{i}" };
7869
for (var j = 1; j <= totalItems; j++)
7970
{
80-
var child = new ReadWriteItem
81-
{
82-
Parent = parent
83-
};
84-
parent.Items.Add(child);
71+
parent.Items.Add(new ReadWriteItem { Parent = parent });
8572
}
8673
s.Save(parent);
8774
}
75+
for (var i = 1; i <= totalItems; i++)
76+
{
77+
var parent = new NonStrictReadWrite() { Name = $"Name{i}" };
78+
s.Save(parent);
79+
}
8880
tx.Commit();
8981
}
9082
}
@@ -98,12 +90,13 @@ protected override void OnTearDown()
9890
s.CreateQuery("delete from ReadWriteItem").ExecuteUpdate();
9991
s.CreateQuery("delete from ReadOnly").ExecuteUpdate();
10092
s.CreateQuery("delete from ReadWrite").ExecuteUpdate();
93+
s.CreateQuery("delete from NonStrictReadWrite").ExecuteUpdate();
10194
tx.Commit();
10295
}
10396
// Must rebuild the session factory, CoreDistribted cache being not clearable.
10497
RebuildSessionFactory();
10598
}
106-
99+
107100
[Test]
108101
public async Task CacheableScalarSqlQueryWithTransformerAsync()
109102
{
@@ -532,5 +525,20 @@ public async Task QueryFetchEntityBatchCacheTestAsync(bool future)
532525
Assert.That(Sfi.Statistics.QueryCacheMissCount, Is.EqualTo(0), "Unexpected cache miss count");
533526
Assert.That(Sfi.Statistics.QueryCacheHitCount, Is.EqualTo(future ? 2 : 1), "Unexpected cache hit count");
534527
}
528+
529+
[Test]
530+
public async Task LazyFormulaTestAsync()
531+
{
532+
using (var s = OpenSession())
533+
using (var t = s.BeginTransaction())
534+
{
535+
var l = await (s.Query<NonStrictReadWrite>().ToListAsync());
536+
foreach (var item in l)
537+
{
538+
Assert.AreEqual(item.Id, item.Count);
539+
}
540+
await (t.CommitAsync());
541+
}
542+
}
535543
}
536544
}

0 commit comments

Comments
 (0)