Skip to content

Commit 2e7fc15

Browse files
committed
CSHARP-1653: Convert MongoDB.Driver.Legacy.VB.Tests from NUnit to xUnit.net.
1 parent 6d3a39c commit 2e7fc15

13 files changed

+3996
-3930
lines changed

src/MongoDB.Driver.Legacy.Tests/Jira/CSharp93Tests.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,9 @@ public void CreateIndex_SetUniqueTrue_Success()
5353

5454
if (collection.Exists())
5555
{
56-
collection.DropAllIndexes();
57-
}
58-
else
59-
{
60-
collection.Insert(new BsonDocument()); // make sure collection exists
56+
collection.Drop();
6157
}
58+
collection.Insert(new BsonDocument()); // make sure collection exists
6259

6360
collection.CreateIndex(IndexKeys.Ascending("x"), IndexOptions.SetUnique(true));
6461
collection.CreateIndex(IndexKeys.Ascending("y"), IndexOptions.SetUnique(false));
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
' Copyright 2010-2014 MongoDB Inc.
1+
' Copyright 2016 MongoDB Inc.
22
'*
33
'* Licensed under the Apache License, Version 2.0 (the "License");
44
'* you may not use this file except in compliance with the License.
@@ -13,20 +13,6 @@
1313
'* limitations under the License.
1414
'
1515

16-
Imports MongoDB.Driver
17-
Imports NUnit.Framework
16+
Imports Xunit
1817

19-
Namespace MongoDB.Driver.VB.Tests
20-
21-
<SetUpFixture()>
22-
Public Class SetUpFixture
23-
24-
<OneTimeTearDown>
25-
Public Sub OneTimeTearDown()
26-
Dim cluster = CoreTestConfiguration.Cluster ' force cluster to be created so database can be dropped
27-
CoreTestConfiguration.TearDown()
28-
End Sub
29-
30-
End Class
31-
32-
End Namespace
18+
<Assembly: CollectionBehavior(DisableTestParallelization:=True)>

src/MongoDB.Driver.Legacy.VB.Tests/Jira/CSharp542.vb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
' Copyright 2010-2014 MongoDB Inc.
1+
' Copyright 2010-2016 MongoDB Inc.
22
'*
33
'* Licensed under the Apache License, Version 2.0 (the "License");
44
'* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
1717
Imports System.Collections.Generic
1818
Imports System.Linq
1919
Imports System.Text
20-
Imports NUnit.Framework
20+
Imports Xunit
2121

2222
Imports MongoDB.Bson
2323
Imports MongoDB.Bson.Serialization.Attributes
@@ -26,7 +26,6 @@ Imports MongoDB.Driver.Linq
2626

2727
Namespace MongoDB.Driver.VB.Tests.Jira
2828

29-
<TestFixture()>
3029
Public Class CSharp542
3130

3231
Public Class Test
@@ -35,7 +34,7 @@ Namespace MongoDB.Driver.VB.Tests.Jira
3534
Public MyNullableInt As Nullable(Of Integer)
3635
End Class
3736

38-
<Test()>
37+
<Fact>
3938
Public Sub TestNullableComparison()
4039

4140
Dim server = LegacyTestConfiguration.Server

src/MongoDB.Driver.Legacy.VB.Tests/Jira/CSharp718.vb

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
' Copyright 2010-2014 MongoDB Inc.
1+
' Copyright 2010-2016 MongoDB Inc.
22
'
33
' Licensed under the Apache License, Version 2.0 (the "License");
44
' you may not use this file except in compliance with the License.
@@ -16,53 +16,57 @@
1616
Imports System.Linq
1717
Imports MongoDB.Driver
1818
Imports MongoDB.Driver.Linq
19-
Imports NUnit.Framework
19+
Imports Xunit
2020

2121
Namespace MongoDB.Driver.VB.Tests.Jira
2222

23-
<TestFixture()>
2423
Public Class CSharp718
2524

2625
Public Class C
2726
Public Id As Integer
2827
Public Foo() As Integer
2928
End Class
3029

31-
Private _server As MongoServer
32-
Private _database As MongoDatabase
33-
Private _collection As MongoCollection(Of C)
30+
Private Shared __server As MongoServer
31+
Private Shared __database As MongoDatabase
32+
Private Shared __collection As MongoCollection(Of C)
33+
Private Shared __lazyOneTimeSetup As Lazy(Of Boolean) = New Lazy(Of Boolean)(OneTimeSetup)
3434

35-
<OneTimeSetUp()>
36-
Public Sub Setup()
37-
_server = LegacyTestConfiguration.Server
38-
_database = LegacyTestConfiguration.Database
39-
_collection = LegacyTestConfiguration.GetCollection(Of C)()
40-
TestSetup()
35+
Public Sub New()
36+
Dim x = __lazyOneTimeSetup.Value
4137
End Sub
4238

43-
<Test()>
39+
Private Shared Function OneTimeSetup() As Boolean
40+
__server = LegacyTestConfiguration.Server
41+
__database = LegacyTestConfiguration.Database
42+
__collection = LegacyTestConfiguration.GetCollection(Of C)()
43+
TestSetup()
44+
Return True
45+
End Function
46+
47+
<Fact>
4448
Public Sub TestLinqIsNothing()
45-
Dim postsWithFoo = (From d In _collection.AsQueryable(Of C)()
46-
Where d.Foo Is Nothing
47-
Select d).Count()
48-
Assert.AreEqual(2, postsWithFoo)
49+
Dim postsWithFoo = (From d In __collection.AsQueryable(Of C)()
50+
Where d.Foo Is Nothing
51+
Select d).Count()
52+
Assert.Equal(2, postsWithFoo)
4953
End Sub
5054

51-
<Test()>
55+
<Fact>
5256
Public Sub TestLinqIsNotNothing()
53-
Dim postsWithFoo = (From d In _collection.AsQueryable(Of C)()
54-
Where d.Foo IsNot Nothing
55-
Select d).Count()
56-
Assert.AreEqual(3, postsWithFoo)
57+
Dim postsWithFoo = (From d In __collection.AsQueryable(Of C)()
58+
Where d.Foo IsNot Nothing
59+
Select d).Count()
60+
Assert.Equal(3, postsWithFoo)
5761
End Sub
5862

59-
Private Sub TestSetup()
60-
_collection.RemoveAll()
61-
_collection.Insert(New C() With {.Id = 1})
62-
_collection.Insert(New C() With {.Id = 2, .Foo = Nothing})
63-
_collection.Insert(New C() With {.Id = 3, .Foo = {1}})
64-
_collection.Insert(New C() With {.Id = 4, .Foo = {1, 2}})
65-
_collection.Insert(New C() With {.Id = 5, .Foo = {1, 2, 3}})
63+
Private Shared Sub TestSetup()
64+
__collection.RemoveAll()
65+
__collection.Insert(New C() With {.Id = 1})
66+
__collection.Insert(New C() With {.Id = 2, .Foo = Nothing})
67+
__collection.Insert(New C() With {.Id = 3, .Foo = {1}})
68+
__collection.Insert(New C() With {.Id = 4, .Foo = {1, 2}})
69+
__collection.Insert(New C() With {.Id = 5, .Foo = {1, 2, 3}})
6670
End Sub
6771
End Class
6872
End Namespace

src/MongoDB.Driver.Legacy.VB.Tests/Linq/MongoQueryProviderTests.vb

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
' Copyright 2010-2014 MongoDB Inc.
1+
' Copyright 2010-2016 MongoDB Inc.
22
'*
33
'* Licensed under the Apache License, Version 2.0 (the "License");
44
'* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ Imports System.Collections.Generic
1818
Imports System.Linq
1919
Imports System.Linq.Expressions
2020
Imports System.Text
21-
Imports NUnit.Framework
21+
Imports Xunit
2222

2323
Imports MongoDB.Bson
2424
Imports MongoDB.Bson.Serialization.Attributes
@@ -28,7 +28,6 @@ Imports MongoDB.Driver.Linq
2828
Imports MongoDB.Driver.Tests
2929

3030
Namespace MongoDB.Driver.VB.Tests.Linq
31-
<TestFixture()> _
3231
Public Class MongoQueryProviderTests
3332
Private Class C
3433
Public Property Id() As ObjectId
@@ -42,37 +41,36 @@ Namespace MongoDB.Driver.VB.Tests.Linq
4241
Private _database As MongoDatabase
4342
Private _collection As MongoCollection
4443

45-
<OneTimeSetUp()>
46-
Public Sub Setup()
44+
Public Sub New()
4745
_server = LegacyTestConfiguration.Server
4846
_server.Connect()
4947
_database = LegacyTestConfiguration.Database
5048
_collection = LegacyTestConfiguration.Collection
5149
End Sub
5250

53-
<Test()> _
51+
<Fact>
5452
Public Sub TestConstructor()
5553
Dim provider = New MongoQueryProvider(_collection)
5654
End Sub
5755

58-
<Test()> _
56+
<Fact>
5957
Public Sub TestCreateQuery()
6058
Dim expression = _collection.AsQueryable(Of C)().Expression
6159
Dim provider = New MongoQueryProvider(_collection)
6260
Dim query = provider.CreateQuery(Of C)(expression)
63-
Assert.AreSame(GetType(C), query.ElementType)
64-
Assert.AreSame(provider, query.Provider)
65-
Assert.AreSame(expression, query.Expression)
61+
Assert.Same(GetType(C), query.ElementType)
62+
Assert.Same(provider, query.Provider)
63+
Assert.Same(expression, query.Expression)
6664
End Sub
6765

68-
<Test()> _
66+
<Fact>
6967
Public Sub TestCreateQueryNonGeneric()
7068
Dim expression = _collection.AsQueryable(Of C)().Expression
7169
Dim provider = New MongoQueryProvider(_collection)
7270
Dim query = provider.CreateQuery(expression)
73-
Assert.AreSame(GetType(C), query.ElementType)
74-
Assert.AreSame(provider, query.Provider)
75-
Assert.AreSame(expression, query.Expression)
71+
Assert.Same(GetType(C), query.ElementType)
72+
Assert.Same(provider, query.Provider)
73+
Assert.Same(expression, query.Expression)
7674
End Sub
7775
End Class
7876
End Namespace

src/MongoDB.Driver.Legacy.VB.Tests/Linq/MongoQueryableTests.vb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
' Copyright 2010-2014 MongoDB Inc.
1+
' Copyright 2010-2016 MongoDB Inc.
22
'*
33
'* Licensed under the Apache License, Version 2.0 (the "License");
44
'* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ Imports System.Collections.Generic
1818
Imports System.Linq
1919
Imports System.Linq.Expressions
2020
Imports System.Text
21-
Imports NUnit.Framework
21+
Imports Xunit
2222

2323
Imports MongoDB.Bson
2424
Imports MongoDB.Bson.Serialization.Attributes
@@ -28,7 +28,6 @@ Imports MongoDB.Driver.Linq
2828
Imports MongoDB.Driver.Tests
2929

3030
Namespace MongoDB.Driver.VB.Tests.Linq
31-
<TestFixture()> _
3231
Public Class MongoQueryableTests
3332
Private Class C
3433
Public Property Id() As ObjectId
@@ -42,29 +41,28 @@ Namespace MongoDB.Driver.VB.Tests.Linq
4241
Private _database As MongoDatabase
4342
Private _collection As MongoCollection
4443

45-
<OneTimeSetUp()>
46-
Public Sub Setup()
44+
Public Sub New()
4745
_server = LegacyTestConfiguration.Server
4846
_server.Connect()
4947
_database = LegacyTestConfiguration.Database
5048
_collection = LegacyTestConfiguration.Collection
5149
End Sub
5250

53-
<Test()> _
51+
<Fact>
5452
Public Sub TestConstructorWithOneArgument()
5553
Dim provider = New MongoQueryProvider(_collection)
5654
Dim iqueryable = DirectCast(New MongoQueryable(Of C)(provider), IQueryable)
57-
Assert.AreSame(GetType(C), iqueryable.ElementType)
58-
Assert.AreSame(provider, iqueryable.Provider)
55+
Assert.Same(GetType(C), iqueryable.ElementType)
56+
Assert.Same(provider, iqueryable.Provider)
5957
End Sub
6058

61-
<Test()> _
59+
<Fact>
6260
Public Sub TestConstructorWithTwoArguments()
6361
Dim queryable = _collection.AsQueryable(Of C)()
6462
Dim iqueryable = DirectCast(New MongoQueryable(Of C)(DirectCast(queryable.Provider, MongoQueryProvider), queryable.Expression), IQueryable)
65-
Assert.AreSame(GetType(C), iqueryable.ElementType)
66-
Assert.AreSame(queryable.Provider, iqueryable.Provider)
67-
Assert.AreSame(queryable.Expression, iqueryable.Expression)
63+
Assert.Same(GetType(C), iqueryable.ElementType)
64+
Assert.Same(queryable.Provider, iqueryable.Provider)
65+
Assert.Same(queryable.Expression, iqueryable.Expression)
6866
End Sub
6967
End Class
7068
End Namespace

0 commit comments

Comments
 (0)