-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into users/philipthomas/subpartitioning
- Loading branch information
Showing
4 changed files
with
82 additions
and
9 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
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
72 changes: 72 additions & 0 deletions
72
Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/ValidationHelpersTests.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,72 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Tests | ||
{ | ||
using System.Data; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
[TestClass] | ||
public class ValidationHelpersTest | ||
{ | ||
[TestMethod] | ||
[DataRow(true, ConsistencyLevel.Eventual, ConsistencyLevel.Strong)] | ||
[DataRow(true, ConsistencyLevel.ConsistentPrefix, ConsistencyLevel.Strong)] | ||
[DataRow(false, ConsistencyLevel.Eventual, ConsistencyLevel.BoundedStaleness)] | ||
[DataRow(false, ConsistencyLevel.ConsistentPrefix, ConsistencyLevel.BoundedStaleness)] | ||
[DataRow(false, ConsistencyLevel.Session, ConsistencyLevel.Strong)] | ||
[DataRow(false, ConsistencyLevel.BoundedStaleness, ConsistencyLevel.Strong)] | ||
public void TestIsValidConsistencyLevelOverwrite(bool isValidConsistencyLevelOverwrite, | ||
ConsistencyLevel backendConsistencyLevel, | ||
ConsistencyLevel desiredConsistencyLevel) | ||
{ | ||
bool result = ValidationHelpers.IsValidConsistencyLevelOverwrite(backendConsistencyLevel, | ||
desiredConsistencyLevel, | ||
true, | ||
Documents.OperationType.Read, | ||
Documents.ResourceType.Document); | ||
|
||
Assert.AreEqual(isValidConsistencyLevelOverwrite, result); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(false, ConsistencyLevel.Eventual, ConsistencyLevel.Strong)] | ||
[DataRow(false, ConsistencyLevel.ConsistentPrefix, ConsistencyLevel.Strong)] | ||
public void TestIsValidConsistencyLevelOverwrite_OnlyWhenSpecifyingExplicitOverwrite(bool isValidConsistencyLevelOverwrite, | ||
ConsistencyLevel backendConsistencyLevel, | ||
ConsistencyLevel desiredConsistencyLevel) | ||
{ | ||
bool result = ValidationHelpers.IsValidConsistencyLevelOverwrite(backendConsistencyLevel, | ||
desiredConsistencyLevel, | ||
false, | ||
Documents.OperationType.Read, | ||
Documents.ResourceType.Document); | ||
|
||
Assert.AreEqual(isValidConsistencyLevelOverwrite, result); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(true, ConsistencyLevel.Eventual, ConsistencyLevel.Strong, Documents.OperationType.Read)] | ||
[DataRow(true, ConsistencyLevel.Eventual, ConsistencyLevel.Strong, Documents.OperationType.ReadFeed)] | ||
[DataRow(true, ConsistencyLevel.ConsistentPrefix, ConsistencyLevel.Strong, Documents.OperationType.Query)] | ||
[DataRow(true, ConsistencyLevel.ConsistentPrefix, ConsistencyLevel.Strong, Documents.OperationType.SqlQuery)] | ||
[DataRow(false, ConsistencyLevel.Eventual, ConsistencyLevel.Strong, Documents.OperationType.QueryPlan)] | ||
[DataRow(false, ConsistencyLevel.ConsistentPrefix, ConsistencyLevel.Strong, Documents.OperationType.Create)] | ||
[DataRow(false, ConsistencyLevel.ConsistentPrefix, ConsistencyLevel.Strong, Documents.OperationType.Batch)] | ||
public void TestIsValidConsistencyLevelOverwrite_OnlyAllowedForCertainOperationTypes( | ||
bool isValidConsistencyLevelOverwrite, | ||
ConsistencyLevel backendConsistencyLevel, | ||
ConsistencyLevel desiredConsistencyLevel, | ||
dynamic operationType) | ||
{ | ||
bool result = ValidationHelpers.IsValidConsistencyLevelOverwrite(backendConsistencyLevel, | ||
desiredConsistencyLevel, | ||
true, | ||
(Documents.OperationType) operationType, | ||
Documents.ResourceType.Document); | ||
|
||
Assert.AreEqual(isValidConsistencyLevelOverwrite, result); | ||
} | ||
} | ||
} |