-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split the jumbo test class into small test classes
- Loading branch information
Showing
3 changed files
with
109 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...amework.Tests/Infrastructure/Linq/Translation/ExpressionTranslationTests_Instantiation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using MongoDB.Bson; | ||
using MongoFramework.Infrastructure.Linq.Translation; | ||
|
||
namespace MongoFramework.Tests.Infrastructure.Linq.Translation | ||
{ | ||
[TestClass] | ||
public class ExpressionTranslationTests_Instantiation : QueryTestBase | ||
{ | ||
[TestMethod] | ||
public void TranslateInstantiation_Anonymous() | ||
{ | ||
var expression = GetTransform(e => new | ||
{ | ||
e.Id, | ||
MyNumber = e.SingleNumber | ||
}); | ||
var result = ExpressionTranslation.TranslateInstantiation(expression); | ||
var expected = new BsonDocument | ||
{ | ||
{ "Id", "Id" }, | ||
{ "MyNumber", "SingleNumber" } | ||
}; | ||
Assert.AreEqual(expected, result); | ||
} | ||
|
||
[TestMethod] | ||
public void TranslateInstantiation_RealType() | ||
{ | ||
var expression = GetTransform(e => new QueryTestModel | ||
{ | ||
Id = e.Id, | ||
SingleNumber = e.SingleNumber | ||
}); | ||
var result = ExpressionTranslation.TranslateInstantiation(expression); | ||
var expected = new BsonDocument | ||
{ | ||
{ "Id", "Id" }, | ||
{ "SingleNumber", "SingleNumber" } | ||
}; | ||
Assert.AreEqual(expected, result); | ||
} | ||
|
||
[TestMethod, ExpectedException(typeof(ArgumentException))] | ||
public void TranslateInstantiation_InvalidExpression() | ||
{ | ||
var expression = GetTransform(e => e.SingleNumber); | ||
ExpressionTranslation.TranslateInstantiation(expression); | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...MongoFramework.Tests/Infrastructure/Linq/Translation/ExpressionTranslationTests_Member.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using MongoDB.Bson; | ||
using MongoFramework.Infrastructure.Linq.Translation; | ||
|
||
namespace MongoFramework.Tests.Infrastructure.Linq.Translation | ||
{ | ||
[TestClass] | ||
public class ExpressionTranslationTests_Member : QueryTestBase | ||
{ | ||
[TestMethod] | ||
public void TranslateMember_SingleLevelMember() | ||
{ | ||
var expression = GetTransform(e => e.SingleString); | ||
var result = ExpressionTranslation.TranslateMember(expression); | ||
var expected = new BsonString("SingleString"); | ||
Assert.AreEqual(expected, result); | ||
} | ||
|
||
[TestMethod] | ||
public void TranslateMember_MultiLevelMember() | ||
{ | ||
var expression = GetTransform(e => e.SingleModel.SingleNumber); | ||
var result = ExpressionTranslation.TranslateMember(expression); | ||
var expected = new BsonString("SingleModel.SingleNumber"); | ||
Assert.AreEqual(expected, result); | ||
} | ||
|
||
[TestMethod] | ||
public void TranslateMember_MemberWithArrayIndex_AtStart() | ||
{ | ||
var expression = GetTransform(e => e.ArrayOfModels[3].SingleNumber); | ||
var result = ExpressionTranslation.TranslateMember(expression); | ||
var expected = new BsonString("ArrayOfModels.3.SingleNumber"); | ||
Assert.AreEqual(expected, result); | ||
} | ||
[TestMethod] | ||
public void TranslateMember_MemberWithArrayIndex_AtEnd() | ||
{ | ||
var expression = GetTransform(e => e.SingleModel.ArrayOfModels[2]); | ||
var result = ExpressionTranslation.TranslateMember(expression); | ||
var expected = new BsonString("SingleModel.ArrayOfModels.2"); | ||
Assert.AreEqual(expected, result); | ||
} | ||
} | ||
} |