File tree Expand file tree Collapse file tree 8 files changed +68
-5
lines changed Expand file tree Collapse file tree 8 files changed +68
-5
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public PagedResult()
36
36
/// <summary>
37
37
/// Collection containing items in the current page.
38
38
/// </summary>
39
- public IList < T > Items { get ; set ; }
39
+ public List < T > Items { get ; set ; }
40
40
41
41
/// <summary>
42
42
/// Calculates & returns the hashcode of the current object.
Original file line number Diff line number Diff line change 7
7
namespace tests
8
8
{
9
9
[ TestFixture ]
10
+ [ SingleThreaded ]
10
11
internal class AsynchronousTests : TestBaseContext
11
12
{
12
13
[ SetUp ]
Original file line number Diff line number Diff line change 5
5
namespace tests
6
6
{
7
7
[ TestFixture ]
8
+ //[SingleThreaded]
8
9
internal class SynchronousTests : TestBaseContext
9
10
{
10
11
[ SetUp ]
@@ -56,6 +57,7 @@ public void Pg_Skip_Count()
56
57
Log ( paged ) ;
57
58
}
58
59
[ Order ( 2 ) ]
60
+ [ RequiresThread ]
59
61
[ TestCase ( Category = SYNC_TESTS ) ]
60
62
public void Pg_With_Items ( )
61
63
{
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ internal class TestBase
6
6
{
7
7
internal const string SYNC_TESTS = "Synchronous" ;
8
8
internal const string ASYNC_TESTS = "Asynchronous" ;
9
+ internal const string SERIAL_TESTS = "Serialization" ;
9
10
10
11
internal void Log ( object obj )
11
12
=> Console . WriteLine ( obj ) ;
Original file line number Diff line number Diff line change 1
1
using Microsoft . EntityFrameworkCore ;
2
+ using NUnit . Framework ;
2
3
3
4
namespace tests
4
5
{
@@ -9,7 +10,7 @@ internal class TestBaseContext : TestBase
9
10
10
11
public TestBaseContext ( )
11
12
{ }
12
-
13
+
13
14
protected TestDbContext Context
14
15
{
15
16
get
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ public TestDbContext(DbContextOptions<TestDbContext> options)
10
10
11
11
public DbSet < Car > Cars { get ; set ; }
12
12
}
13
- internal class Car
13
+ public class Car
14
14
{
15
15
public int Id { get ; set ; }
16
16
}
Original file line number Diff line number Diff line change
1
+ using System . IO ;
2
+ using System . Xml ;
3
+ using System . Xml . Serialization ;
4
+ using Common ;
5
+ using NUnit . Framework ;
6
+ using Paginator . EntityFrameworkCore ;
7
+
1
8
namespace tests
2
9
{
10
+ [ TestFixture ]
3
11
internal class UnitTests : TestBaseContext
4
12
{
5
-
13
+ [ SetUp ]
14
+ public void Setup ( )
15
+ {
16
+ InitContx ( ) ;
17
+ }
18
+
19
+ [ TestCase ( Category = SERIAL_TESTS ) ]
20
+ public void ToJson ( )
21
+ {
22
+ Add ( new Car ( ) ) ;
23
+ Add ( new Car ( ) ) ;
24
+ Add ( new Car ( ) ) ;
25
+ Add ( new Car ( ) ) ;
26
+
27
+ var paged = Context . Cars . Paginate ( 1 , 2 , true ) ;
28
+
29
+ string json = paged . ToJson ( ) ;
30
+
31
+ Assert . IsNotEmpty ( json ) ;
32
+ Assert . That ( json . IsValidJson ( ) ) ;
33
+
34
+ System . Console . WriteLine ( json ) ;
35
+ }
36
+
37
+ [ TestCase ( Category = SERIAL_TESTS ) ]
38
+ public void ToXml ( )
39
+ {
40
+ Add ( new Car ( ) ) ;
41
+ Add ( new Car ( ) ) ;
42
+ Add ( new Car ( ) ) ;
43
+ Add ( new Car ( ) ) ;
44
+
45
+ var paged = Context . Cars . Paginate ( 1 , 2 , true ) ;
46
+
47
+ XmlSerializer xsSubmit = new XmlSerializer ( paged . GetType ( ) ) ;
48
+ var xml = "" ;
49
+
50
+ using ( var sww = new StringWriter ( ) )
51
+ {
52
+ using ( XmlWriter writer = XmlWriter . Create ( sww ) )
53
+ {
54
+ xsSubmit . Serialize ( writer , paged ) ;
55
+ xml = sww . ToString ( ) ; // Your XML
56
+ }
57
+ }
58
+
59
+ Assert . IsNotEmpty ( xml ) ;
60
+
61
+ System . Console . WriteLine ( xml ) ;
62
+ }
6
63
}
7
64
}
Original file line number Diff line number Diff line change 9
9
<ItemGroup >
10
10
<PackageReference Include =" Moq" Version =" 4.16.1" />
11
11
<PackageReference Include =" NUnit" Version =" 3.13.2" />
12
- <PackageReference Include =" NUnit3TestAdapter" Version =" 3.17 .0" />
12
+ <PackageReference Include =" NUnit3TestAdapter" Version =" 4.0 .0" />
13
13
<PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 16.10.0" />
14
14
<PackageReference Include =" Microsoft.EntityFrameworkCore.InMemory" Version =" 3.1.15" />
15
+ <PackageReference Include =" Shared.Common" Version =" 1.3.6" />
15
16
</ItemGroup >
16
17
17
18
<ItemGroup >
You can’t perform that action at this time.
0 commit comments