-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1022 from mikependon/repodb-fixes-issue-1015
#1015 - Added the Unit Tests.
- Loading branch information
Showing
9 changed files
with
290 additions
and
32 deletions.
There are no files selected for viewing
219 changes: 219 additions & 0 deletions
219
RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Extensions/DataEntityExtensionTest.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,219 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using RepoDb.Extensions; | ||
using RepoDb.UnitTests.CustomObjects; | ||
|
||
namespace RepoDb.UnitTests.Extensions | ||
{ | ||
[TestClass] | ||
public class DataEntityExtensionTest | ||
{ | ||
[TestCleanup] | ||
public void Cleanup() | ||
{ | ||
PropertyValueAttributeMapper.Clear(); | ||
} | ||
|
||
#region GetSchema | ||
|
||
[TestMethod] | ||
public void TestDataEntityExtensionGetSchema() | ||
{ | ||
// Prepare | ||
var dbSetting = new CustomDbSetting(); | ||
|
||
// Act | ||
var schema = DataEntityExtension.GetSchema("SchemaName.TableName", dbSetting); | ||
|
||
// Assert | ||
Assert.AreEqual("SchemaName", schema); | ||
} | ||
|
||
[TestMethod] | ||
public void TestDataEntityExtensionGetSchemaFromQuoted() | ||
{ | ||
// Prepare | ||
var dbSetting = new CustomDbSetting(); | ||
|
||
// Act | ||
var schema = DataEntityExtension.GetSchema("[SchemaName].[TableName]", dbSetting); | ||
|
||
// Assert | ||
Assert.AreEqual("[SchemaName]", schema); | ||
} | ||
|
||
[TestMethod] | ||
public void TestDataEntityExtensionGetSchemaFromWhitespaced() | ||
{ | ||
// Prepare | ||
var dbSetting = new CustomDbSetting(); | ||
|
||
// Act | ||
var schema = DataEntityExtension.GetSchema("Schema Name.TableName", dbSetting); | ||
|
||
// Assert | ||
Assert.AreEqual("Schema Name", schema); | ||
} | ||
|
||
[TestMethod] | ||
public void TestDataEntityExtensionGetSchemaFromQuotedAndIsDotted() | ||
{ | ||
// Prepare | ||
var dbSetting = new CustomDbSetting(); | ||
|
||
// Act | ||
var schema = DataEntityExtension.GetSchema("[Schema.Name].[TableName]", dbSetting); | ||
|
||
// Assert | ||
Assert.AreEqual("[Schema.Name]", schema); | ||
} | ||
|
||
[TestMethod] | ||
public void TestDataEntityExtensionGetSchemaFromQuotedAndIsWhitespaced() | ||
{ | ||
// Prepare | ||
var dbSetting = new CustomDbSetting(); | ||
|
||
// Act | ||
var schema = DataEntityExtension.GetSchema("[Schema Name].[TableName]", dbSetting); | ||
|
||
// Assert | ||
Assert.AreEqual("[Schema Name]", schema); | ||
} | ||
|
||
#endregion | ||
|
||
#region GetTableName | ||
|
||
[TestMethod] | ||
public void TestDataEntityExtensionGetTableName() | ||
{ | ||
// Prepare | ||
var dbSetting = new CustomDbSetting(); | ||
|
||
// Act | ||
var schema = DataEntityExtension.GetTableName("TableName", dbSetting); | ||
|
||
// Assert | ||
Assert.AreEqual("TableName", schema); | ||
} | ||
|
||
[TestMethod] | ||
public void TestDataEntityExtensionGetTableNameFromQuoted() | ||
{ | ||
// Prepare | ||
var dbSetting = new CustomDbSetting(); | ||
|
||
// Act | ||
var schema = DataEntityExtension.GetTableName("[TableName]", dbSetting); | ||
|
||
// Assert | ||
Assert.AreEqual("[TableName]", schema); | ||
} | ||
|
||
[TestMethod] | ||
public void TestDataEntityExtensionGetTableNameFromWhitespaced() | ||
{ | ||
// Prepare | ||
var dbSetting = new CustomDbSetting(); | ||
|
||
// Act | ||
var schema = DataEntityExtension.GetTableName("Table Name", dbSetting); | ||
|
||
// Assert | ||
Assert.AreEqual("Table Name", schema); | ||
} | ||
|
||
[TestMethod] | ||
public void TestDataEntityExtensionGetTableNameFromDotted() | ||
{ | ||
// Prepare | ||
var dbSetting = new CustomDbSetting(); | ||
|
||
// Act | ||
var schema = DataEntityExtension.GetTableName("[Table.Name]", dbSetting); | ||
|
||
// Assert | ||
Assert.AreEqual("[Table.Name]", schema); | ||
} | ||
|
||
[TestMethod] | ||
public void TestDataEntityExtensionGetTableNameFromQuotedAndIsWhitespaced() | ||
{ | ||
// Prepare | ||
var dbSetting = new CustomDbSetting(); | ||
|
||
// Act | ||
var schema = DataEntityExtension.GetTableName("[Table Name]", dbSetting); | ||
|
||
// Assert | ||
Assert.AreEqual("[Table Name]", schema); | ||
} | ||
|
||
[TestMethod] | ||
public void TestDataEntityExtensionGetTableNameWithSchema() | ||
{ | ||
// Prepare | ||
var dbSetting = new CustomDbSetting(); | ||
|
||
// Act | ||
var schema = DataEntityExtension.GetTableName("SchemaName.TableName", dbSetting); | ||
|
||
// Assert | ||
Assert.AreEqual("TableName", schema); | ||
} | ||
|
||
[TestMethod] | ||
public void TestDataEntityExtensionGetTableNameWithSchemaAndIsWhitespaced() | ||
{ | ||
// Prepare | ||
var dbSetting = new CustomDbSetting(); | ||
|
||
// Act | ||
var schema = DataEntityExtension.GetTableName("SchemaName.Table Name", dbSetting); | ||
|
||
// Assert | ||
Assert.AreEqual("Table Name", schema); | ||
} | ||
|
||
[TestMethod] | ||
public void TestDataEntityExtensionGetTableNameWithSchemaFromQuoted() | ||
{ | ||
// Prepare | ||
var dbSetting = new CustomDbSetting(); | ||
|
||
// Act | ||
var schema = DataEntityExtension.GetTableName("[SchemaName].[TableName]", dbSetting); | ||
|
||
// Assert | ||
Assert.AreEqual("[TableName]", schema); | ||
} | ||
|
||
[TestMethod] | ||
public void TestDataEntityExtensionGetTableNameWithSchemaFromQuotedAndIsDotted() | ||
{ | ||
// Prepare | ||
var dbSetting = new CustomDbSetting(); | ||
|
||
// Act | ||
var schema = DataEntityExtension.GetTableName("[SchemaName].[Table.Name]", dbSetting); | ||
|
||
// Assert | ||
Assert.AreEqual("[Table.Name]", schema); | ||
} | ||
|
||
[TestMethod] | ||
public void TestDataEntityExtensionGetTableNameWithSchemaFromQuotedAndIsWhitespaced() | ||
{ | ||
// Prepare | ||
var dbSetting = new CustomDbSetting(); | ||
|
||
// Act | ||
var schema = DataEntityExtension.GetTableName("[SchemaName].[Table Name]", dbSetting); | ||
|
||
// Assert | ||
Assert.AreEqual("[Table Name]", schema); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.