Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added summary for all NUnit tests

Change-Id: If8b683409d03352b87550db2febf7638fb5096d9
Reviewed-on: http://review.couchbase.org/23114
Reviewed-by: John C. Zablocki <john@couchbase.com>
Tested-by: John C. Zablocki <john@couchbase.com>
  • Loading branch information...
commit 9f20a63014c2234c761fce8242b651cfa1a3f245 1 parent f828a51
@saakshimanocha saakshimanocha authored John C. Zablocki committed
Showing with 845 additions and 26 deletions.
  1. +18 −2 src/Couchbase.Tests/ConfigHelperTests.cs
  2. +20 −1 src/Couchbase.Tests/CouchbaseAuthenticatedViewTests.cs
  3. +14 −2 src/Couchbase.Tests/CouchbaseClientCasTests.cs
  4. +51 −2 src/Couchbase.Tests/CouchbaseClientConcatTests.cs
  5. +8 −0 src/Couchbase.Tests/CouchbaseClientConfigTests.cs
  6. +12 −0 src/Couchbase.Tests/CouchbaseClientExtensionsTests.cs
  7. +19 −1 src/Couchbase.Tests/CouchbaseClientGenericViewTests.cs
  8. +47 −1 src/Couchbase.Tests/CouchbaseClientGetTests.cs
  9. +12 −0 src/Couchbase.Tests/CouchbaseClientMutateTests.cs
  10. +94 −3 src/Couchbase.Tests/CouchbaseClientObserveTests.cs
  11. +13 −1 src/Couchbase.Tests/CouchbaseClientRemoveTests.cs
  12. +41 −0 src/Couchbase.Tests/CouchbaseClientSpatialViewTests.cs
  13. +34 −2 src/Couchbase.Tests/CouchbaseClientStoreTests.cs
  14. +10 −0 src/Couchbase.Tests/CouchbaseClientViewNameTransformerTests.cs
  15. +21 −1 src/Couchbase.Tests/CouchbaseClientViewPagingTests.cs
  16. +78 −3 src/Couchbase.Tests/CouchbaseClientViewParameterTests.cs
  17. +10 −0 src/Couchbase.Tests/CouchbaseClientViewReduceTests.cs
  18. +11 −0 src/Couchbase.Tests/CouchbaseClientViewTests.cs
  19. +161 −5 src/Couchbase.Tests/CouchbaseClusterBucketAdminTests.cs
  20. +12 −0 src/Couchbase.Tests/CouchbaseJsonExtensionTests.cs
  21. +107 −2 src/Couchbase.Tests/DefaultCouchbaseClientConfigurationTests.cs
  22. +28 −0 src/Couchbase.Tests/HeartbeatConfigTests.cs
  23. +24 −0 src/Couchbase.Tests/HttpClientConfigTests.cs
View
20 src/Couchbase.Tests/ConfigHelperTests.cs
@@ -12,6 +12,15 @@ namespace Couchbase.Tests
[TestFixture]
public class ConfigHelperTests : CouchbaseClientTestsBase
{
+ /// <summary>
+ /// @test: Reads the information about available data buckets from pools,
+ /// generates a random key-value, stores in the available data bucket, and then
+ /// retrive the value by passing the same key for verification
+ /// @pre: Add section named "pools-config" in App.config file,
+ /// configure all the parameters required to initialize Couchbase client like Uri, bucket, etc.
+ /// mention uri = http://Url_Of_Couchbase_Server/pools
+ /// @post: Test passes if successfully stores key-value and then able to get value, fails otherwise
+ /// </summary>
[Test]
public void Client_Operations_Succeed_When_Bootstrapping_To_Pools_Root_Uri()
{
@@ -21,12 +30,19 @@ public void Client_Operations_Succeed_When_Bootstrapping_To_Pools_Root_Uri()
string key = GetUniqueKey(), value = GetRandomString();
var storeResult = client.ExecuteStore(StoreMode.Add, key, value);
StoreAssertPass(storeResult);
-
var getResult = client.ExecuteGet(key);
GetAssertPass(getResult, value);
-
}
+ /// <summary>
+ /// @test: Reads the information about available data buckets from pools/default,
+ /// generates a random key-value, stores in the default data bucket, and then
+ /// retrive the value by passing the same key for verification
+ /// @pre: Add section named "pools-default-config" in App.config file,
+ /// configure all the parameters required to initialize Couchbase client like Uri, bucket, etc.
+ /// mention uri = http://Url_Of_Couchbase_Server/pools/default
+ /// @post: Test passes if successfully stores key-value and then able to get value, fails otherwise
+ /// </summary>
[Test]
public void Client_Operations_Succeed_When_Bootstrapping_To_Pools_Default_Root_Uri()
{
View
21 src/Couchbase.Tests/CouchbaseAuthenticatedViewTests.cs
@@ -11,7 +11,13 @@ namespace Couchbase.Tests
[TestFixture]
public class CouchbaseAuthenticatedViewTests : CouchbaseClientViewTestsBase
{
-
+ /// <summary>
+ /// @test: Verifies that for the bucket which is authenticated with password, it is able to connect successfully
+ /// if correct cedentials are provided and then returns the object representing the view in specfied design document
+ /// @pre: Provide the bucket name and password in method getClient(),
+ /// provide correct design name and view name to method GetView()
+ /// @post: Test passes if connects to client successfully and get the details of View with given data, fails otherwise
+ /// </summary>
[Test]
public void When_Bucket_Is_Authenticated_View_Returns_Results()
{
@@ -21,6 +27,13 @@ public void When_Bucket_Is_Authenticated_View_Returns_Results()
Assert.That(view.Count(), Is.EqualTo(1), "Row count was not 1");
}
+ /// <summary>
+ /// @test: Verifies that for the bucket which is authenticated with password, it throws an error
+ /// if no credentials are provided and hence cannot return the object representing the view in specfied design document
+ /// @pre: Provide the bucket name but no password in method getClient(),
+ /// provide design name and view name to method GetView()
+ /// @post: Test passes if the web exception (401) is thrown
+ /// </summary>
[ExpectedException(typeof(WebException), ExpectedMessage="401", MatchType=MessageMatch.Contains)]
[Test]
public void When_Bucket_Is_Authenticated_And_No_Credentials_Are_Provided_Exception_Is_Thrown()
@@ -30,6 +43,12 @@ public void When_Bucket_Is_Authenticated_And_No_Credentials_Are_Provided_Excepti
}
+ /// <summary>
+ /// Connects to couchbase client with given configuration details
+ /// </summary>
+ /// <param name="username">Name of bucket to be used</param>
+ /// <param name="password">Password used to connect to bucket</param>
+ /// <returns>Couchbase client object</returns>
private CouchbaseClient getClient(string username, string password)
{
var config = new CouchbaseClientConfiguration();
View
16 src/Couchbase.Tests/CouchbaseClientCasTests.cs
@@ -8,11 +8,16 @@
namespace Couchbase.Tests
{
-
[TestFixture(Description = "MemcachedClient Store Tests")]
public class CouchbaseClientCasTests : CouchbaseClientTestsBase
{
-
+ /// <summary>
+ /// @test: Store a randomly generated unique key-value, use he CAS value
+ /// returned from the Store(), then use ExecuteCas() method
+ /// to compare and set a value using the specified key and return the store operation result
+ /// @pre: No section required in App.config file
+ /// @post: Test passes if successfully able to retrieve the same cas value, fails otherwise
+ /// </summary>
[Test]
public void When_Storing_Item_With_Valid_Cas_Result_Is_Successful()
{
@@ -25,6 +30,13 @@ public void When_Storing_Item_With_Valid_Cas_Result_Is_Successful()
StoreAssertPass(casResult);
}
+ /// <summary>
+ /// @test: Store a randomly generated unique key-value, use the different
+ /// cas value in ExecuteCas() mehod than what is returned by Store() method,
+ /// the ExecuteCas() fails due to invalid cas passed
+ /// @pre: No section required in App.config file
+ /// @post: Test passes if ExecuteCas() fals due to invalid cas, fails if ExecuteCas() passes
+ /// </summary>
[Test]
public void When_Storing_Item_With_Invalid_Cas_Result_Is_Not_Successful()
{
View
53 src/Couchbase.Tests/CouchbaseClientConcatTests.cs
@@ -9,6 +9,13 @@ namespace Couchbase.Tests
[TestFixture]
public class CouchbaseClientConcatTests : CouchbaseClientTestsBase
{
+ /// <summary>
+ /// @test: Store a randomly generated unique key-value, use the different
+ /// cas value in ExecuteCas() mehod than what is returned by Store() method,
+ /// the ExecuteCas() fails due to invalid cas passed
+ /// @pre: No section required in App.config file
+ /// @post: Test passes if ExecuteCas() fails due to invalid cas, fails if ExecuteCas() passes
+ /// </summary>
[Test]
public void When_Appending_To_Existing_Value_Result_Is_Successful()
{
@@ -25,9 +32,16 @@ public void When_Appending_To_Existing_Value_Result_Is_Successful()
var getResult = _Client.ExecuteGet(key);
GetAssertPass(getResult, value + toAppend);
-
}
+
+ /// <summary>
+ /// @test: Generate a unique key, use ExecuteAppend() to save data in that key,
+ /// since the key does not exist aleady, append operation would fail, then get value from
+ /// the same key, it will fail again as the key does not exist
+ /// @pre: Generate a unique key and data to append in that key
+ /// @post: Test passes if ExecuteAppend() and ExecuteGet() both fail, which is the expected behaviour
+ /// </summary>
[Test]
public void When_Appending_To_Invalid_Key_Result_Is_Not_Successful()
{
@@ -43,6 +57,12 @@ public void When_Appending_To_Invalid_Key_Result_Is_Not_Successful()
}
+ /// <summary>
+ /// @test: Generate a unique key and store it, Prepend some text to that key-value,
+ /// it should pass, then get the value against the same key, it should pass
+ /// @pre: Generate a unique key and data to prepend in that key
+ /// @post: Test passes if ExecutePrepend() and ExecuteGet() both pass
+ /// </summary>
[Test]
public void When_Prepending_To_Existing_Value_Result_Is_Successful()
{
@@ -62,6 +82,12 @@ public void When_Prepending_To_Existing_Value_Result_Is_Successful()
}
+ /// <summary>
+ /// @test: Generate a unique key but do not store it, Prepend some text to that key-value,
+ /// it should fail as key is invalid, then get the value against the same key, it should fail
+ /// @pre: Generate a unique key and data to prepend in that key
+ /// @post: Test passes if ExecutePrepend() and ExecuteGet() both fail
+ /// </summary>
[Test]
public void When_Prepending_To_Invalid_Key_Result_Is_Not_Successful()
{
@@ -77,6 +103,12 @@ public void When_Prepending_To_Invalid_Key_Result_Is_Not_Successful()
}
+ /// <summary>
+ /// @test: Generate a unique key and store it, Prepend some text to that key-value,
+ /// it should pass, then get the value against the same key, it should pass
+ /// @pre: Generate a unique key and data to append in that key
+ /// @post: Test passes if ExecutePrepend() and ExecuteGet() both pass
+ /// </summary>
[Test]
public void When_Appending_To_Existing_Value_Result_Is_Successful_With_Valid_Cas()
{
@@ -96,6 +128,12 @@ public void When_Appending_To_Existing_Value_Result_Is_Successful_With_Valid_Cas
}
+ /// <summary>
+ /// @test: Generate a unique key and store it, Append some text but use a different key
+ /// it should fail
+ /// @pre: Generate a unique key and data to append in that key
+ /// @post: Test passes if ExecuteAppend() fails
+ /// </summary>
[Test]
public void When_Appending_To_Existing_Value_Result_Is_Not_Successful_With_Invalid_Cas()
{
@@ -111,6 +149,12 @@ public void When_Appending_To_Existing_Value_Result_Is_Not_Successful_With_Inval
ConcatAssertFail(concatResult);
}
+ /// <summary>
+ /// @test: Generate a unique key and store it, Append some text and use the same cas key
+ /// then get the value against the same key
+ /// @pre: Generate a unique key and data to append in that key
+ /// @post: Test passes if ExecuteAppend() and ExecuteGet() passes
+ /// </summary>
[Test]
public void When_Prepending_To_Existing_Value_Result_Is_Successful_With_Valid_Cas()
{
@@ -127,9 +171,14 @@ public void When_Prepending_To_Existing_Value_Result_Is_Successful_With_Valid_Ca
var getResult = _Client.ExecuteGet(key);
GetAssertPass(getResult, value + tpPrepend);
-
}
+ /// <summary>
+ /// @test: Generate a unique key and store it, Append some text and use the different cas key,
+ /// the test should fail
+ /// @pre: Generate a unique key and data to append in that key
+ /// @post: Test passes if ExecuteAppend() passes
+ /// </summary>
[Test]
public void When_Prepending_To_Existing_Value_Result_Is_Not_Successful_With_Invalid_Cas()
{
View
8 src/Couchbase.Tests/CouchbaseClientConfigTests.cs
@@ -11,6 +11,14 @@ namespace Couchbase.Tests
[TestFixture]
public class CouchbaseClientConfigTests
{
+ /// <summary>
+ /// @test: Reads the information about couchbase client configuration from App.Config,
+ /// and verifies that all properties are set
+ /// @pre: Add section named "couchbase" in App.config file,
+ /// configure all the parameters required to initialize Couchbase client like Uri, bucket, username, password etc.
+ /// @post: Test passes if able to retrieve couchbase client configuration, the username and password match with
+ /// expected details, fails otherwise
+ /// </summary>
[Test]
public void When_Setting_Username_And_Password_In_Config_Section_Config_Instance_Properties_Are_Set()
{
View
12 src/Couchbase.Tests/CouchbaseClientExtensionsTests.cs
@@ -11,6 +11,12 @@ namespace Couchbase.Tests
[TestFixture]
public class CouchbaseClientExtensionsTests : CouchbaseClientTestsBase
{
+ /// <summary>
+ /// @test: Generate a unique key and store key using StoreJson(), without converting into json
+ /// the store operation would fail
+ /// @pre: Generate a unique key and data to append in that key
+ /// @post: Test passes if ExecuteAppend() passes
+ /// </summary>
[Test]
public void When_Serializing_Class_Without_Json_Property_Attributes_Properties_Are_Camel_Cased()
{
@@ -24,6 +30,12 @@ public void When_Serializing_Class_Without_Json_Property_Attributes_Properties_A
Assert.That(savedThing, Is.StringContaining("someProperty").And.StringContaining("someOtherProperty"));
}
+ /// <summary>
+ /// @test: Generate a unique key and map the properties, store the json format data.
+ /// Then get the json data and deserialize. the properties would map
+ /// @pre: set properties to random values before storing data
+ /// @post: Test passes properties are correctly mapped
+ /// </summary>
[Test]
public void When_Deserializing_Class_Without_Json_Property_Attributes_Camel_Cased_Properties_Are_Mapped()
{
View
20 src/Couchbase.Tests/CouchbaseClientGenericViewTests.cs
@@ -11,10 +11,16 @@
namespace Couchbase.Tests
{
-
[TestFixture]
public class CouchbaseClientGenericViewTests : CouchbaseClientViewTestsBase
{
+ /// <summary>
+ /// @test: Set shouldlookupDocById to true, GetView() method will retrieve
+ /// the view by id and verifies that all properties of
+ /// view type (City in this context) are correct
+ /// @pre: Define CityViews.json to create views
+ /// @post: Test passes if GetView returns results correctly
+ /// </summary>
[Test]
public void When_Should_Lookup_By_Id_Is_True_Document_Is_Retrieved_By_Id()
{
@@ -31,6 +37,13 @@ public void When_Should_Lookup_By_Id_Is_True_Document_Is_Retrieved_By_Id()
Assert.That(view.Count(), Is.GreaterThan(0), "View count was 0");
}
+ /// <summary>
+ /// @test: Set shouldlookupDocById to false, GetView() method will retrieve
+ /// the view by id and verifies that all properties of
+ /// view type (City in this context) are correct
+ /// @pre: Define CityViews.json to create views
+ /// @post: Test passes if GetView returns results correctly
+ /// </summary>
[Test]
public void When_Should_Lookup_By_Id_Is_False_Document_Is_Deserialized_By_Property_Mapping()
{
@@ -43,6 +56,11 @@ public void When_Should_Lookup_By_Id_Is_False_Document_Is_Deserialized_By_Proper
Assert.That(view.Count(), Is.GreaterThan(0), "View count was 0");
}
+ /// <summary>
+ /// @test: Store a json format document and then get the view with stale mode false
+ /// @pre: Define data to be stored in json format
+ /// @post: Test passes if GetView returns results correctly
+ /// </summary>
[Test]
public void When_Iterating_Over_A_Non_Stale_View_Deleted_Keys_Return_Null()
{
View
48 src/Couchbase.Tests/CouchbaseClientGetTests.cs
@@ -10,7 +10,11 @@ namespace Couchbase.Tests
[TestFixture]
public class CouchbaseClientGetTests : CouchbaseClientTestsBase
{
-
+ /// <summary>
+ /// @test: Store a key-value in data bucket. Then get the value associated with the given key
+ /// @pre: Default configuration to initialize client in App.config
+ /// @post: Test passes if successfully stores key-value and then able to get value, fails otherwise
+ /// </summary>
[Test]
public void When_Getting_Existing_Item_Value_Is_Not_Null_And_Result_Is_Successful()
{
@@ -23,6 +27,11 @@ public void When_Getting_Existing_Item_Value_Is_Not_Null_And_Result_Is_Successfu
GetAssertPass(getResult, value);
}
+ /// <summary>
+ /// @test: Getting a value for key that is invalid and does not exist, the test would fail
+ /// @pre: Default configuration to initialize client in App.config
+ /// @post: Test passes if Get method to retrive the value for invalid key fails
+ /// </summary>
[Test]
public void When_Getting_Item_For_Invalid_Key_HasValue_Is_False_And_Result_Is_Not_Successful()
{
@@ -33,6 +42,11 @@ public void When_Getting_Item_For_Invalid_Key_HasValue_Is_False_And_Result_Is_No
GetAssertFail(getResult);
}
+ /// <summary>
+ /// @test: Store a key-value in data bucket. Then try-get the value associated with the given key
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if successfully stores key-value and then get value, fails otherwise
+ /// </summary>
[Test]
public void When_TryGetting_Existing_Item_Value_Is_Not_Null_And_Result_Is_Successful()
{
@@ -46,6 +60,12 @@ public void When_TryGetting_Existing_Item_Value_Is_Not_Null_And_Result_Is_Succes
GetAssertPass(getResult, temp);
}
+ /// <summary>
+ /// @test: Store a key-value in data bucket. Use generic type string.
+ /// Then get the value associated with the given key
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if successfully stores key-value and then able to get value, fails otherwise
+ /// </summary>
[Test]
public void When_Generic_Getting_Existing_Item_Value_Is_Not_Null_And_Result_Is_Successful()
{
@@ -62,6 +82,11 @@ public void When_Generic_Getting_Existing_Item_Value_Is_Not_Null_And_Result_Is_S
Assert.That(getResult.Value, Is.InstanceOf<string>(), "Value was not a string");
}
+ /// <summary>
+ /// @test: Store multiple keys in data bucket. Then get the keys and verify the count
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if successfully stores all keys and count is correct
+ /// </summary>
[Test]
public void When_Getting_Multiple_Keys_Result_Is_Successful()
{
@@ -80,6 +105,12 @@ public void When_Getting_Multiple_Keys_Result_Is_Successful()
}
}
+ /// <summary>
+ /// @test: Store a key-value in data bucket. Then get the value associated with the given key
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if successfully stores key-value and then able to get value
+ /// when expiration is not null
+ /// </summary>
[Test]
public void When_Getting_Existing_Item_Value_With_Expiration_Is_Not_Null_And_Result_Is_Successful()
{
@@ -92,6 +123,11 @@ public void When_Getting_Existing_Item_Value_With_Expiration_Is_Not_Null_And_Res
GetAssertPass(getResult, value);
}
+ /// <summary>
+ /// @test: Get the value for a key that does not exist, the get operation should fail
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if get operation fails
+ /// </summary>
[Test]
public void When_Getting_Item_For_With_Expiration_And_Invalid_Key_HasValue_Is_False_And_Result_Is_Not_Successful()
{
@@ -101,6 +137,11 @@ public void When_Getting_Item_For_With_Expiration_And_Invalid_Key_HasValue_Is_Fa
GetAssertFail(getResult);
}
+ /// <summary>
+ /// @test: Store a key-value in data bucket. Then try-get the value with expiration
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if successfully stores key-value and then able to get value, fails otherwise
+ /// </summary>
[Test]
public void When_TryGetting_Existing_Item_With_Expiration_Value_Is_Not_Null_And_Result_Is_Successful()
{
@@ -114,6 +155,11 @@ public void When_TryGetting_Existing_Item_With_Expiration_Value_Is_Not_Null_And_
GetAssertPass(getResult, temp);
}
+ /// <summary>
+ /// @test: Store a key-value in data bucket. Then get the value using generic type as string
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if successfully stores key-value and then able to get value, fails otherwise
+ /// </summary>
[Test]
public void When_Generic_Getting_Existing_Item_With_Expiration_Value_Is_Not_Null_And_Result_Is_Successful()
{
View
12 src/Couchbase.Tests/CouchbaseClientMutateTests.cs
@@ -9,6 +9,12 @@ namespace Couchbase.Tests
[TestFixture]
public class CouchbaseClientMutateTests : CouchbaseClientTestsBase
{
+ /// <summary>
+ /// @test: Store a randomly generated key, with a value lets say 100, increment
+ /// the key with the delta of lets say 10, the result of mutation should be 110
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if mutate operation increments the key correctly
+ /// </summary>
[Test]
public void When_Incrementing_Value_Result_Is_Successful()
{
@@ -20,6 +26,12 @@ public void When_Incrementing_Value_Result_Is_Successful()
MutateAssertPass(mutateResult, 110);
}
+ /// <summary>
+ /// @test: Store a randomly generated key, with a value lets say 100, decrement
+ /// the key with the delta of lets say 10, the result of mutation should be 90
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if mutate operation decrements the key correctly
+ /// </summary>
[Test]
public void When_Decrementing_Value_Result_Is_Successful()
{
View
97 src/Couchbase.Tests/CouchbaseClientObserveTests.cs
@@ -16,7 +16,11 @@ namespace Couchbase.Tests
[TestFixture]
public class CouchbaseClientObserveTests : CouchbaseClientTestsBase
{
-
+ /// <summary>
+ /// @test: Generate a new key-value tuple, store the key value with master only persistence
+ /// @pre: Default configuration to initialize client in App.config
+ /// @post: Test passes if successfully stores key-value
+ /// </summary>
[Test]
public void When_Storing_A_New_Key_Observe_Will_Succeed_With_Master_Only_Persistence()
{
@@ -25,6 +29,12 @@ public void When_Storing_A_New_Key_Observe_Will_Succeed_With_Master_Only_Persist
StoreAssertPass(storeResult);
}
+ /// <summary>
+ /// @test: Generate a new key-value tuple, store the key value with master only persistence
+ /// and enable replication to single node
+ /// @pre: Default configuration to initialize client in App.config
+ /// @post: Test passes if successfully stores key-value
+ /// </summary>
[Test]
public void When_Storing_A_New_Key_Observe_Will_Succeed_With_Master_Persistence_And_Single_Node_Replication()
{
@@ -33,6 +43,12 @@ public void When_Storing_A_New_Key_Observe_Will_Succeed_With_Master_Persistence_
StoreAssertPass(storeResult);
}
+ /// <summary>
+ /// @test: Generate a new key-value tuple, store the key value with master only persistence
+ /// and replicate to multiple nodes
+ /// @pre: Default configuration to initialize client in App.config
+ /// @post: Test passes if successfully stores key-value
+ /// </summary>
[Test]
public void When_Storing_A_New_Key_Observe_Will_Succeed_With_Master_Persistence_And_Mutli_Node_Replication()
{
@@ -41,6 +57,11 @@ public void When_Storing_A_New_Key_Observe_Will_Succeed_With_Master_Persistence_
StoreAssertPass(storeResult);
}
+ /// <summary>
+ /// @test: Generate a new key-value tuple, store the key value with multiple node persistence
+ /// @pre: Default configuration to initialize client in App.config
+ /// @post: Test passes if successfully stores key-value
+ /// </summary>
[Test]
public void When_Storing_A_New_Key_Observe_Will_Succeed_With_Multi_Node_Persistence()
{
@@ -49,6 +70,12 @@ public void When_Storing_A_New_Key_Observe_Will_Succeed_With_Multi_Node_Persiste
StoreAssertPass(storeResult);
}
+ /// <summary>
+ /// @test: Generate a new key-value tuple, store the key value with multiple node persistence
+ /// and single node replication
+ /// @pre: Default configuration to initialize client in App.config
+ /// @post: Test passes if successfully stores key-value
+ /// </summary>
[Test]
public void When_Storing_A_New_Key_Observe_Will_Succeed_With_Multi_Node_Persistence_And_Single_Node_Replication()
{
@@ -57,6 +84,11 @@ public void When_Storing_A_New_Key_Observe_Will_Succeed_With_Multi_Node_Persiste
StoreAssertPass(storeResult);
}
+ /// <summary>
+ /// @test: Generate a new key-value tuple, store the key value with single node replication
+ /// @pre: Default configuration to initialize client in App.config
+ /// @post: Test passes if successfully stores key-value
+ /// </summary>
[Test]
public void When_Storing_A_New_Key_Observe_Will_Succeed_With_Single_Node_Replication()
{
@@ -65,6 +97,11 @@ public void When_Storing_A_New_Key_Observe_Will_Succeed_With_Single_Node_Replica
StoreAssertPass(storeResult);
}
+ /// <summary>
+ /// @test: Generate a new key-value tuple, store the key value with multiple node replication
+ /// @pre: Default configuration to initialize client in App.config
+ /// @post: Test passes if successfully stores key-value
+ /// </summary>
[Test]
public void When_Storing_A_New_Key_Observe_Will_Succeed_With_Multi_Node_Replication()
{
@@ -73,6 +110,12 @@ public void When_Storing_A_New_Key_Observe_Will_Succeed_With_Multi_Node_Replicat
StoreAssertPass(storeResult);
}
+ /// <summary>
+ /// @test: Generate a new key-value tuple, store the key value with three nodes for replication,
+ /// however the cluster has less than three nodes, then store operation would fail
+ /// @pre: Default configuration to initialize client in App.config
+ /// @post: Test passes if store operayion fails
+ /// </summary>
[Test]
public void When_Storing_A_New_Key_Observe_Will_Fail_When_Cluster_Has_Too_Few_Nodes_For_Replication()
{
@@ -81,6 +124,13 @@ public void When_Storing_A_New_Key_Observe_Will_Fail_When_Cluster_Has_Too_Few_No
Assert.That(storeResult.Success, Is.False);
}
+ /// <summary>
+ /// @test: Generate a new key-value tuple, store the key value. Observe the client with a
+ /// different cas value (than what is the result of store operation), and using master persistence
+ /// and replication to single node, the store operation would fail
+ /// @pre: Default configuration to initialize client in App.config
+ /// @post: Test passes if successfully stores key-value
+ /// </summary>
[Test]
public void When_Storing_A_New_Key_Observe_Will_Fail_With_Master_Persistence_And_Cas_Value_Has_Changed()
{
@@ -91,6 +141,13 @@ public void When_Storing_A_New_Key_Observe_Will_Fail_With_Master_Persistence_And
Assert.That(observeResult.Message, Is.StringMatching(ObserveOperationConstants.MESSAGE_MODIFIED));
}
+ /// <summary>
+ /// @test: Generate a new key-value tuple, store the key value. Observe the client with a
+ /// different cas value (than what is the result of store operation), and using master persistence
+ /// and replication to multiple node, the store operation would fail
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if successfully stores key-value
+ /// </summary>
[Test]
public void When_Storing_A_New_Key_Observe_Will_Fail_With_Master_Persistence_And_Replication_And_Cas_Value_Has_Changed()
{
@@ -101,6 +158,12 @@ public void When_Storing_A_New_Key_Observe_Will_Fail_With_Master_Persistence_And
Assert.That(observeResult.Message, Is.StringMatching(ObserveOperationConstants.MESSAGE_MODIFIED));
}
+ /// <summary>
+ /// @test: Create a new design document, save a new key value pair wth master persistence.
+ /// Get the view result with stale false, the view item should match successfully.
+ /// @pre: Default configuration to initialize client in App.config
+ /// @post: Test passes if successfully stores key-value and able to retrieve
+ /// </summary>
[Test]
public void When_Storing_A_New_Key_With_Master_Persistence_That_Key_Is_In_View_When_Stale_Is_False()
{
@@ -133,7 +196,14 @@ public void When_Storing_A_New_Key_With_Master_Persistence_That_Key_Is_In_View_W
Assert.That(deleteDesignDocResult, Is.True);
}
- [Test]
+ /// <summary>
+ /// @test: Store a randomly generated unique key value pair, remove the key with master persistence and
+ /// then get the value against the key, the get operation would fail
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if successfully stores and later deletes the key-value and then a
+ /// but the get operation after delete should ideally fail
+ /// </summary>
+ [Test]
public void When_Observing_A_Removed_Key_Operation_Is_Successful_With_Master_Node_Persistence()
{
var key = GetUniqueKey("observe");
@@ -149,7 +219,14 @@ public void When_Observing_A_Removed_Key_Operation_Is_Successful_With_Master_Nod
GetAssertFail(getResult);
}
- [Test]
+ /// <summary>
+ /// @test: Store a randomly generated unique key value pair, remove the key with master persistence
+ /// and replication to multiple nodes, then get the value against the key, the get operation would pass
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if successfully stores and later deletes the key-value and then a
+ /// but the get operation after delete should also pass because of replication
+ /// </summary>
+ [Test]
public void When_Observing_A_Removed_Key_Operation_Is_Successful_With_Master_And_Replication_Persistence()
{
var key = GetUniqueKey("observe");
@@ -165,6 +242,13 @@ public void When_Observing_A_Removed_Key_Operation_Is_Successful_With_Master_And
GetAssertFail(getResult);
}
+ /// <summary>
+ /// @test: Store a randomly generated unique key value pair, remove the key with no persistence and
+ /// replication to multiple nodes, then get the value against the key, the get operation would pass
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if successfully stores and later deletes the key-value and then a
+ /// but the get operation after delete should also pass because of replication
+ /// </summary>
[Test]
public void When_Observing_A_Removed_Key_Operation_Is_Successful_With_Replication_Only()
{
@@ -181,6 +265,13 @@ public void When_Observing_A_Removed_Key_Operation_Is_Successful_With_Replicatio
GetAssertFail(getResult);
}
+ /// <summary>
+ /// @test: Store a randomly generated unique key value pair, remove the key with master persistence
+ /// and no replication, then get the value against the key, the get operation would pass
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if successfully stores and later deletes the key-value and then a
+ /// but the get operation after delete should also pass because of replication
+ /// </summary>
[Test]
public void When_Observing_A_Removed_Key_Operation_Is_Successful_With_Multi_Node_Persistence()
{
View
14 src/Couchbase.Tests/CouchbaseClientRemoveTests.cs
@@ -9,6 +9,13 @@ namespace Couchbase.Tests
[TestFixture]
public class CouchbaseClientRemoveTests : CouchbaseClientTestsBase
{
+ /// <summary>
+ /// @test: Store a randomly generated key, remove that key and then get value
+ /// agsinst the same key, the Get operation should fail as key is already deleted
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if store and deletion operation are success and Get operation
+ /// must fail ideally
+ /// </summary>
[Test]
public void When_Removing_A_Valid_Key_Result_Is_Successful()
{
@@ -24,7 +31,12 @@ public void When_Removing_A_Valid_Key_Result_Is_Successful()
GetAssertFail(getResult);
}
- [Test]
+ /// <summary>
+ /// @test: Deleting a key which does not exist will fail the Remove operation
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if Remove operation fails
+ /// </summary>
+ [Test]
public void When_Removing_An_Invalid_Key_Result_Is_Not_Successful()
{
var key = GetUniqueKey("remove");
View
41 src/Couchbase.Tests/CouchbaseClientSpatialViewTests.cs
@@ -12,6 +12,13 @@ namespace Couchbase.Tests
[TestFixture]
public class CouchbaseClientSpatialViewTests : CouchbaseClientViewTestsBase
{
+ /// <summary>
+ /// @test: Get spatial view of a given design name and view name,
+ /// all the propeties of view should have correct values
+ /// @pre: Default configuration to initialize client in app.config, configure
+ /// City views in cluster
+ /// @post: Test passes if view prperties are not null
+ /// </summary>
[Test]
public void When_Querying_Spatial_View_Results_Are_Returned()
{
@@ -28,6 +35,13 @@ public void When_Querying_Spatial_View_Results_Are_Returned()
Assert.That(view.Count(), Is.GreaterThan(0), "View count was 0");
}
+ /// <summary>
+ /// @test: Get spatial view of generic type City of a given design name and view name,
+ /// set look up by id to true, all the propeties of view should have correct values
+ /// @pre: Default configuration to initialize client in app.config, configure
+ /// City views in cluster
+ /// @post: Test passes if view prperties are not null
+ /// </summary>
[Test]
public void When_Querying_Spatial_View_With_Generics_And_Should_Lookup_Doc_By_Id_Is_True_Results_Are_Returned()
{
@@ -43,6 +57,13 @@ public void When_Querying_Spatial_View_With_Generics_And_Should_Lookup_Doc_By_Id
Assert.That(view.Count(), Is.GreaterThan(0), "View count was 0");
}
+ /// <summary>
+ /// @test: Get spatial view of generic type City of a given design name and view name,
+ /// set look up by id to false, all the propeties of view should have correct values
+ /// @pre: Default configuration to initialize client in app.config, configure
+ /// City views in cluster
+ /// @post: Test passes if the count of view is greater than 0
+ /// </summary>
[Test]
public void When_Querying_Spatial_View_With_Generics_And_Should_Lookup_Doc_By_Id_Is_False_Results_Are_Returned()
{
@@ -55,6 +76,13 @@ public void When_Querying_Spatial_View_With_Generics_And_Should_Lookup_Doc_By_Id
Assert.That(view.Count(), Is.GreaterThan(0), "View count was 0");
}
+ /// <summary>
+ /// @test: Get spatial view of generic type City of a given design name and view name,
+ /// set limit to 2, then the view should return 2 rows
+ /// @pre: Default configuration to initialize client in app.config, configure
+ /// City views in cluster
+ /// @post: Test passes if view count is equal to 2
+ /// </summary>
[Test]
public void When_Querying_Spatial_View_With_Limit_Rows_Are_Limited()
{
@@ -62,6 +90,13 @@ public void When_Querying_Spatial_View_With_Limit_Rows_Are_Limited()
Assert.That(view.Count(), Is.EqualTo(2), "View count was not 2");
}
+ /// <summary>
+ /// @test: Get spatial view with bounding box, the result rows would be limited but
+ /// should have at least one record
+ /// @pre: Default configuration to initialize client in app.config, configure
+ /// City views in cluster
+ /// @post: Test passes if view count is at least one
+ /// </summary>
[Test]
public void When_Querying_Spatial_View_With_Bounding_Box_Rows_Are_Limited()
{
@@ -77,6 +112,12 @@ public void When_Querying_Spatial_View_With_Bounding_Box_Rows_Are_Limited()
Assert.That(hasAtLeastOneRecord, Is.True, "No records found");
}
+ /// <summary>
+ /// @test: Store a new json format document and then get spatial view with stale mode false,
+ /// the view result will contain new document
+ /// @pre: Default configuration to initialize client in app.config, create a new json file for view
+ /// @post: Test passes if view contains new json document
+ /// </summary>
[Test]
public void When_Iterating_Over_A_Non_Stale_Spatial_View_Deleted_Keys_Return_Null()
{
View
36 src/Couchbase.Tests/CouchbaseClientStoreTests.cs
@@ -12,15 +12,24 @@ namespace Couchbase.Tests
[TestFixture(Description = "MemcachedClient Store Tests")]
public class CouchbaseClientStoreTests : CouchbaseClientTestsBase
{
-
+ /// <summary>
+ /// @test: Store a randomly generated key, with store mode Add, new key is added
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if new key is added successfully
+ /// </summary>
[Test]
public void When_Storing_Item_With_New_Key_And_StoreMode_Add_Result_Is_Successful()
{
var result = Store(StoreMode.Add);
StoreAssertPass(result);
-
}
+ /// <summary>
+ /// @test: Store a randomly generated key, store again using same key with Add operation,
+ /// the result will not be successful
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if new key is added first time and second time it fails
+ /// </summary>
[Test]
public void When_Storing_Item_With_Existing_Key_And_StoreMode_Add_Result_Is_Not_Successful()
{
@@ -32,6 +41,11 @@ public void When_Storing_Item_With_Existing_Key_And_StoreMode_Add_Result_Is_Not_
StoreAssertFail(result);
}
+ /// <summary>
+ /// @test: Store a new key with store mode replace will fail as the key does not exist
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if replace fails
+ /// </summary>
[Test]
public void When_Storing_Item_With_New_Key_And_StoreMode_Replace_Result_Is_Not_Successful()
{
@@ -40,6 +54,12 @@ public void When_Storing_Item_With_New_Key_And_StoreMode_Replace_Result_Is_Not_S
}
+ /// <summary>
+ /// @test: Store a randomly generated key, with store mode Add, then change the key
+ /// with store mode replace, key should be replaced successfully
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if new key is added and later replaced successfully
+ /// </summary>
[Test]
public void When_Storing_Item_With_Existing_Key_And_StoreMode_Replace_Result_Is_Successful()
{
@@ -51,6 +71,12 @@ public void When_Storing_Item_With_Existing_Key_And_StoreMode_Replace_Result_Is_
StoreAssertPass(result);
}
+ /// <summary>
+ /// @test: Store a randomly generated key, with store mode Set,
+ /// new key should be stored correctly
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if new key is stored successfully
+ /// </summary>
[Test]
public void When_Storing_Item_With_New_Key_And_StoreMode_Set_Result_Is_Successful()
{
@@ -59,6 +85,12 @@ public void When_Storing_Item_With_New_Key_And_StoreMode_Set_Result_Is_Successfu
}
+ /// <summary>
+ /// @test: Store a randomly generated key, with store mode Add, then change the key
+ /// with store mode set, key should be set successfully
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if new key is stored successfully
+ /// </summary>
[Test]
public void When_Storing_Item_With_Existing_Key_And_StoreMode_Set_Result_Is_Successful()
{
View
10 src/Couchbase.Tests/CouchbaseClientViewNameTransformerTests.cs
@@ -11,12 +11,22 @@ namespace Couchbase.Tests
[TestFixture]
public class CouchbaseClientViewNameTransformerTests : CouchbaseClientViewTestsBase
{
+ /// <summary>
+ /// @test: Design document name is prefixed with "dev_" in development mode
+ /// @pre: Default configuration to initialize client in app.config, create a design document in server named "foo"
+ /// @post: Test passes if name changes and is prefixed with dev_ as expected
+ /// </summary>
[Test]
public void When_Setting_Design_Document_Name_Transformer_To_Dev_Views_Are_Prefixed_With_Dev()
{
testTransformedDesignDocName(new DevelopmentModeNameTransformer(), "foo", "dev_foo");
}
+ /// <summary>
+ /// @test: Design document name is not prefixed in production views
+ /// @pre: Default configuration to initialize client in app.config, create a design document in server named "foo"
+ /// @post: Test passes if name does not change and is not prefixed with any string
+ /// </summary>
[Test]
public void When_Setting_Design_Document_Name_Transformer_To_Prod_Views_Are_Not_Prefixed()
{
View
22 src/Couchbase.Tests/CouchbaseClientViewPagingTests.cs
@@ -9,7 +9,11 @@ namespace Couchbase.Tests
[TestFixture]
public class CouchbaseClientViewPagingTests : CouchbaseClientViewTestsBase
{
-
+ /// <summary>
+ /// @test: Get the view results and display all items of an index in pages
+ /// @pre: Default configuration to initialize client in app.config, configure view name 'by_name' with design name 'cities'
+ /// @post: Test passes if it retrives all items in view and page size is correct
+ /// </summary>
[Test]
public void When_Paging_Non_Generic_View_Page_Sizes_Are_Correct()
{
@@ -18,6 +22,11 @@ public void When_Paging_Non_Generic_View_Page_Sizes_Are_Correct()
testPageSizes(view);
}
+ /// <summary>
+ /// @test: Get view results with generic type, key and id are not set, page results will throw error
+ /// @pre: Default configuration to initialize client in app.config, configure view name 'by_name' with design name 'cities'
+ /// @post: Test passes if the view results throw invalid operation exception
+ /// </summary>
[Test]
[ExpectedException(typeof(InvalidOperationException))]
public void Paging_Generic_View_Throws_Exception_When_Key_And_Id_Are_Not_Set()
@@ -28,6 +37,12 @@ public void Paging_Generic_View_Throws_Exception_When_Key_And_Id_Are_Not_Set()
}
+ /// <summary>
+ /// @test: Get view results with generic type, key and if are set properly,
+ /// page results will display correct results
+ /// @pre: Default configuration to initialize client in app.config, configure view name 'by_name' with design name 'cities'
+ /// @post: Test passes if the view results show correct page sizes
+ /// </summary>
[Test]
public void When_Paging_Generic_View_Page_Sizes_Are_Correct()
{
@@ -37,6 +52,11 @@ public void When_Paging_Generic_View_Page_Sizes_Are_Correct()
}
+ /// <summary>
+ /// @test: Get view results with generic type, key and id are set, paging view count is correct
+ /// @pre: Default configuration to initialize client in app.config, configure view name 'by_name' with design name 'cities'
+ /// @post: Test passes if thecount of view results is correct
+ /// </summary>
[Test]
public void When_Paging_View_Count_Is_Greater_Than_Zero()
{
View
81 src/Couchbase.Tests/CouchbaseClientViewParameterTests.cs
@@ -13,31 +13,56 @@ public class CouchbaseClientViewParameterTests : CouchbaseClientViewTestsBase
{
#region Key tests
-
- [Test]
+
+ /// <summary>
+ /// @test: String keys serialize to json format while retrieving view results
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the value after serialization matches the expected value
+ /// </summary>
+ [Test]
public void When_Requesting_View_String_Keys_Are_Json_Serialized()
{
testJsonKeySerialization("foo", "\"foo\"");
}
-
+
+ /// <summary>
+ /// @test: While retrieving view results for array of keys, they get serialized to json
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the value after serialization matches the expected value
+ /// </summary>
[Test]
public void When_Requesting_View_Array_Keys_Are_Json_Serialized()
{
testJsonKeySerialization(new object[] { "foo", 3.14 }, "[\"foo\",3.14]");
}
+ /// <summary>
+ /// @test: Int keys serialize to json format while retrieving view results
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the value after serialization matches the expected value
+ /// </summary>
[Test]
public void When_Requesting_View_Int_Keys_Are_Json_Serialized()
{
testJsonKeySerialization(10, "10");
}
+ /// <summary>
+ /// @test: Float keys serialize to json format while retrieving view results
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the value after serialization matches the expected value
+ /// </summary>
[Test]
public void When_Requesting_View_Float_Keys_Are_Json_Serialized()
{
testJsonKeySerialization(3.14, "3.14");
}
+ /// <summary>
+ /// @test: Nested array keys serialize to json format while retrieving view results
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the value after serialization matches the expected value
+ /// </summary>
[Test]
public void When_Requesting_View_Nested_Array_Keys_Are_Json_Serialized()
{
@@ -48,30 +73,55 @@ public void When_Requesting_View_Nested_Array_Keys_Are_Json_Serialized()
#region StartKey tests
+ /// <summary>
+ /// @test: String start-keys serialize to json format while retrieving view results
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the value after serialization matches the expected value
+ /// </summary>
[Test]
public void When_Requesting_View_String_StartKeys_Are_Json_Serialized()
{
testJsonStartKeySerialization("foo", "\"foo\"");
}
+ /// <summary>
+ /// @test: String array start-keys serialize to json format while retrieving view results
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the value after serialization matches the expected value
+ /// </summary>
[Test]
public void When_Requesting_View_Array_StartKeys_Are_Json_Serialized()
{
testJsonStartKeySerialization(new object[] { "foo", 3.14 }, "[\"foo\",3.14]");
}
+ /// <summary>
+ /// @test: Int start-keys serialize to json format while retrieving view results
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the value after serialization matches the expected value
+ /// </summary>
[Test]
public void When_Requesting_View_Int_StartKeys_Are_Json_Serialized()
{
testJsonStartKeySerialization(10, "10");
}
+ /// <summary>
+ /// @test: Floar start-keys serialize to json format while retrieving view results
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the value after serialization matches the expected value
+ /// </summary>
[Test]
public void When_Requesting_View_Float_StartKeys_Are_Json_Serialized()
{
testJsonStartKeySerialization(3.14, "3.14");
}
+ /// <summary>
+ /// @test: Nested array start-keys serialize to json format while retrieving view results
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the value after serialization matches the expected value
+ /// </summary>
[Test]
public void When_Requesting_View_Nested_Array_StartKeys_Are_Json_Serialized()
{
@@ -82,30 +132,55 @@ public void When_Requesting_View_Nested_Array_StartKeys_Are_Json_Serialized()
#region EndKey tests
+ /// <summary>
+ /// @test: String end-keys serialize to json format while retrieving view results
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the value after serialization matches the expected value
+ /// </summary>
[Test]
public void When_Requesting_View_String_EndKeys_Are_Json_Serialized()
{
testJsonEndKeySerialization("foo", "\"foo\"");
}
+ /// <summary>
+ /// @test: String Array End keys serialize to json format while retrieving view results
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the value after serialization matches the expected value
+ /// </summary>
[Test]
public void When_Requesting_View_Array_EndKeys_Are_Json_Serialized()
{
testJsonEndKeySerialization(new object[] { "foo", 3.14 }, "[\"foo\",3.14]");
}
+ /// <summary>
+ /// @test: Int end keys serialize to json format while retrieving view results
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the value after serialization matches the expected value
+ /// </summary>
[Test]
public void When_Requesting_View_Int_EndKeys_Are_Json_Serialized()
{
testJsonEndKeySerialization(10, "10");
}
+ /// <summary>
+ /// @test: Float end keys serialize to json format while retrieving view results
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the value after serialization matches the expected value
+ /// </summary>
[Test]
public void When_Requesting_View_Float_EndKeys_Are_Json_Serialized()
{
testJsonStartKeySerialization(3.14, "3.14");
}
+ /// <summary>
+ /// @test: Nested array end keys serialize to json format while retrieving view results
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the value after serialization matches the expected value
+ /// </summary>
[Test]
public void When_Requesting_View_Nested_Array_EndKeys_Are_Json_Serialized()
{
View
10 src/Couchbase.Tests/CouchbaseClientViewReduceTests.cs
@@ -9,6 +9,11 @@ namespace Couchbase.Tests
[TestFixture]
public class CouchbaseClientViewReduceTests : CouchbaseClientViewTestsBase
{
+ /// <summary>
+ /// @test: Row count of view result is one when it is not grouped
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the view count is one
+ /// </summary>
[Test]
public void When_View_Is_Reduced_Without_Group_Row_Count_Is_One()
{
@@ -18,6 +23,11 @@ public void When_View_Is_Reduced_Without_Group_Row_Count_Is_One()
Assert.That(view.Count(), Is.EqualTo(1), "Row count was not 1");
}
+ /// <summary>
+ /// @test: Row count of view result is greater than one when it is grouped
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if the view count is greater than one
+ /// </summary>
[Test]
public void When_View_Is_Reduced_With_Group_Row_Count_Is_Greater_Than_One()
{
View
11 src/Couchbase.Tests/CouchbaseClientViewTests.cs
@@ -9,6 +9,12 @@ namespace Couchbase.Tests
[TestFixture]
public class CouchbaseClientViewTests : CouchbaseClientViewTestsBase
{
+ /// <summary>
+ /// @test: Retrieve view result with debug true should return debug information
+ /// of data type dictionary
+ /// @pre: Default configuration to initialize client in app.config and have view wih design document cities and view name by_name
+ /// @post: Test passes if debug info is returned correctly
+ /// </summary>
[Test]
public void When_Querying_View_With_Debug_True_Debug_Info_Dictionary_Is_Returned()
{
@@ -18,6 +24,11 @@ public void When_Querying_View_With_Debug_True_Debug_Info_Dictionary_Is_Returned
Assert.That(view.DebugInfo, Is.InstanceOf(typeof(Dictionary<string, object>)));
}
+ /// <summary>
+ /// @test: Retrieve view result with debug false should return no debug information
+ /// @pre: Default configuration to initialize client in app.config and have view wih design document cities and view name by_name
+ /// @post: Test passes if no debug info is returned
+ /// </summary>
[Test]
public void When_Querying_View_With_Debug_False_Debug_Info_Dictionary_Is_Returned()
{
View
166 src/Couchbase.Tests/CouchbaseClusterBucketAdminTests.cs
@@ -19,6 +19,11 @@ namespace Couchbase.Tests
[TestFixture]
public class CouchbaseClusterBucketAdminTests : CouchbaseClusterTestsBase
{
+ /// <summary>
+ /// @test: List buckets in cluster should return default bucket
+ /// @pre: Default configuration to initialize client in app.config to initialize client in app.config and cluster should have a default bucket
+ /// @post: Test passes if default bucket is found
+ /// </summary>
[Test]
public void When_Listing_Buckets_Default_Bucket_Is_Returned()
{
@@ -26,6 +31,12 @@ public void When_Listing_Buckets_Default_Bucket_Is_Returned()
Assert.That(buckets.FirstOrDefault(b => b.Name == "default"), Is.Not.Null, "default bucket was not found");
}
+ /// <summary>
+ /// @test: List buckets in cluster with invalid server configuration
+ /// should return argument null exception
+ /// @pre: Use incorrect configuration of server
+ /// @post: Test passes if error is thrown
+ /// </summary>
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void When_Listing_Buckets_With_Invalid_Config_Argument_Exception_Is_Thrown()
@@ -37,6 +48,11 @@ public void When_Listing_Buckets_With_Invalid_Config_Argument_Exception_Is_Throw
var buckets = server.ListBuckets();
}
+ /// <summary>
+ /// @test: Try List buckets in cluster should return default bucket
+ /// @pre: Default configuration to initialize client in app.config and cluster should have a default bucket
+ /// @post: Test passes if default bucket is found
+ /// </summary>
[Test]
public void When_Try_Listing_Buckets_Default_Bucket_Is_Returned()
{
@@ -46,6 +62,12 @@ public void When_Try_Listing_Buckets_Default_Bucket_Is_Returned()
Assert.That(result, Is.True);
}
+ /// <summary>
+ /// @test: Try List buckets in with invalid configuration should return false
+ /// and no exception is thrown
+ /// @pre: Default configuration to initialize client in app.config an use invalid configuration
+ /// @post: Test passes if default bucket is found
+ /// </summary>
[Test]
public void When_Try_Listing_Buckets_With_Invalid_Config_No_Exception_Is_Thrown_And_Return_Value_Is_False()
{
@@ -59,6 +81,11 @@ public void When_Try_Listing_Buckets_With_Invalid_Config_No_Exception_Is_Thrown_
Assert.That(result, Is.False);
}
+ /// <summary>
+ /// @test: Create a SASL bucket and then retrieve its object and then delete it
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if bucket is created, retrieved and later removed successfully
+ /// </summary>
[Test]
public void When_Getting_Bucket_That_Bucket_Is_Not_Null()
{
@@ -81,6 +108,11 @@ public void When_Getting_Bucket_That_Bucket_Is_Not_Null()
_Cluster.DeleteBucket(bucketName);
}
+ /// <summary>
+ /// @test: create invalid bucket, while retrieving bucket, web exception is thrown
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if invalid bucket throws web exception
+ /// </summary>
[ExpectedException(typeof(WebException))]
[Test]
public void When_Getting_Invalid_Bucket_Web_Exception_Is_Thrown()
@@ -104,6 +136,11 @@ public void When_Getting_Invalid_Bucket_Web_Exception_Is_Thrown()
}
+ /// <summary>
+ /// @test: create sasl bucket and try get bucket should not be null
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if bucket is created and found
+ /// </summary>
[Test]
public void When_Try_Getting_Bucket_That_Bucket_Is_Not_Null()
{
@@ -126,6 +163,11 @@ public void When_Try_Getting_Bucket_That_Bucket_Is_Not_Null()
_Cluster.DeleteBucket(bucketName);
}
+ /// <summary>
+ /// @test: Create bucket, getting bucket item count should match basic stats
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if bucket is created and the item count matches basic stats
+ /// </summary>
[Test]
public void When_Getting_Bucket_Item_Count_Count_Matches_Basic_Stats()
{
@@ -150,6 +192,11 @@ public void When_Getting_Bucket_Item_Count_Count_Matches_Basic_Stats()
_Cluster.DeleteBucket(bucketName);
}
+ /// <summary>
+ /// @test: Create bucket, getting cluster item count should match interesting stats
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if bucket is created and the item count matches interesting stats
+ /// </summary>
[Test]
public void When_Getting_Cluster_Item_Count_Count_Matches_Interesting_Stats()
{
@@ -174,6 +221,11 @@ public void When_Getting_Cluster_Item_Count_Count_Matches_Interesting_Stats()
_Cluster.DeleteBucket(bucketName);
}
+ /// <summary>
+ /// @test: Try get invalid bucket should throw an invalid exception
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if exception is thrown
+ /// </summary>
[Test]
public void When_Try_Getting_Invalid_Bucket_Web_Exception_Is_Not_Thrown()
{
@@ -207,6 +259,11 @@ public void When_Flushing_Bucket_Data_Are_Removed()
Assert.That(getResult.Value, Is.Null);
}
+ /// <summary>
+ /// @test: create bucket and verify that the bucket gets listed
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if bucket is listed correctly
+ /// </summary>
[Test]
public void When_Creating_New_Bucket_That_Bucket_Is_Listed()
{
@@ -230,6 +287,11 @@ public void When_Creating_New_Bucket_That_Bucket_Is_Listed()
}
+ /// <summary>
+ /// @test: create bucket and update it and verify that the bucket gets listed
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if updated bucket is listed correctly
+ /// </summary>
[Test]
public void When_Updating_Bucket_That_Bucket_Is_Listed()
{
@@ -266,6 +328,11 @@ public void When_Updating_Bucket_That_Bucket_Is_Listed()
}
+ /// <summary>
+ /// @test: create new memcached bucket and verify that the bucket gets listed
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if bucket is listed correctly
+ /// </summary>
[Test]
public void When_Creating_New_Memcached_Bucket_That_Bucket_Is_Listed()
{
@@ -290,6 +357,11 @@ public void When_Creating_New_Memcached_Bucket_That_Bucket_Is_Listed()
}
+ /// <summary>
+ /// @test: create new bucket with existing name and verify that the exception is thrown
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if error is thrown
+ /// </summary>
[Test]
[ExpectedException(typeof(WebException))]
public void When_Creating_New_Bucket_With_Existing_Name_Web_Exception_Is_Thrown()
@@ -304,7 +376,12 @@ public void When_Creating_New_Bucket_With_Existing_Name_Web_Exception_Is_Thrown(
});
}
- [Test]
+ /// <summary>
+ /// @test: create bucket with no authorizaton and port and verify that the error is thrown
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if error is thrown
+ /// </summary>
+ [Test]
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "ProxyPort", MatchType = MessageMatch.Contains)]
public void When_Creating_New_Bucket_With_Auth_Type_None_And_No_Port_Argument_Exception_Is_Thrown()
{
@@ -318,6 +395,11 @@ public void When_Creating_New_Bucket_With_Auth_Type_None_And_No_Port_Argument_Ex
});
}
+ /// <summary>
+ /// @test: create sasl bucket with no authorization type and verify that the error is thrown
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if error is thrown
+ /// </summary>
[Test]
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "ProxyPort", MatchType = MessageMatch.Contains)]
public void When_Creating_New_Bucket_With_Auth_Type_Sasl_And_Port_Argument_Exception_Is_Thrown()
@@ -332,7 +414,11 @@ public void When_Creating_New_Bucket_With_Auth_Type_Sasl_And_Port_Argument_Excep
});
}
-
+ /// <summary>
+ /// @test: create bucket with RAM quota less than 100 and verify that the error is thrown
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if bucket is error is thrown
+ /// </summary>
[Test]
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Quota.RAM", MatchType = MessageMatch.Contains)]
public void When_Creating_New_Bucket_With_Ram_Quota_Less_Than_100_Argument_Exception_Is_Thrown()
@@ -347,6 +433,11 @@ public void When_Creating_New_Bucket_With_Ram_Quota_Less_Than_100_Argument_Excep
});
}
+ /// <summary>
+ /// @test: create and delete bucket and verify that the bucket no longer is listed
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if bucket is not listed after deletion
+ /// </summary>
[Test]
public void When_Deleting_Bucket_Bucket_Is_No_Longer_Listed()
{
@@ -372,7 +463,12 @@ public void When_Deleting_Bucket_Bucket_Is_No_Longer_Listed()
Assert.That(bucket, Is.Null, "Deleted bucket still exists");
}
- [Test]
+ /// <summary>
+ /// @test: delete bucket that does not exist and exception is thrown
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if deleting bucket throws an error
+ /// </summary>
+ [Test]
[ExpectedException(typeof(WebException), ExpectedMessage = "404", MatchType = MessageMatch.Contains)]
public void When_Deleting_Bucket_That_Does_Not_Exist_404_Web_Exception_Is_Thrown()
{
@@ -381,6 +477,11 @@ public void When_Deleting_Bucket_That_Does_Not_Exist_404_Web_Exception_Is_Thrown
_Cluster.DeleteBucket(bucketName);
}
+ /// <summary>
+ /// @test: create new bucket, wait that it gets listed, and verify that bucket counts are set on basic stats
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if deleting bucket throws an error
+ /// </summary>
[Test]
public void When_Creating_New_Bucket_Item_Counts_Are_Set_On_Basic_Stats()
{
@@ -429,7 +530,11 @@ public void When_Creating_New_Bucket_Item_Counts_Are_Set_On_Basic_Stats()
Assert.That(bucket, Is.Null, "Deleted bucket still exists");
}
- [Test]
+ /// <summary>
+ /// @test: create bucket and then list the bucket, object graph should be populated
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if graph is populated
+ /// </summary>
public void When_Listing_Bucket_Object_Graph_Is_Populated()
{
var bucketName = "Bucket-" + DateTime.Now.Ticks;
@@ -470,6 +575,11 @@ public void When_Listing_Bucket_Object_Graph_Is_Populated()
}
#region Design Documents
+ /// <summary>
+ /// @test: create design document and verify that the operation is successful
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if operation is successful
+ /// </summary>
[Test]
public void When_Creating_Design_Document_Operation_Is_Successful()
{
@@ -485,6 +595,11 @@ public void When_Creating_Design_Document_Operation_Is_Successful()
Assert.That(result, Is.True);
}
+ /// <summary>
+ /// @test: create stream to read json file and use stream to create design document
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if operation to create design document is successful
+ /// </summary>
[Test]
public void When_Creating_Design_Document_With_Stream_Operation_Is_Successful()
{
@@ -494,6 +609,11 @@ public void When_Creating_Design_Document_With_Stream_Operation_Is_Successful()
Assert.That(result, Is.True);
}
+ /// <summary>
+ /// @test: create design document with invalid json argument and exception should occur
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if exception occurs
+ /// </summary>
[Test]
[ExpectedException(typeof(ArgumentException))]
public void When_Creating_Design_Document_With_Invalid_Json_Argument_Exception_Is_Thrown()
@@ -501,6 +621,11 @@ public void When_Creating_Design_Document_With_Invalid_Json_Argument_Exception_I
_Cluster.CreateDesignDocument("default", "cities", "foo");
}
+ /// <summary>
+ /// @test: create design document with missing argument and exception should occur
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if exception occurs
+ /// </summary>
[Test]
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "nam", MatchType = MessageMatch.Contains)]
public void When_Creating_Design_Document_With_Missing_Name_Argument_Exception_Is_Thrown()
@@ -509,6 +634,11 @@ public void When_Creating_Design_Document_With_Missing_Name_Argument_Exception_I
_Cluster.CreateDesignDocument("default", "", json);
}
+ /// <summary>
+ /// @test: create design document with missing view argument and exception should occur
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if exception occurs
+ /// </summary>
[Test]
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "nam", MatchType = MessageMatch.Contains)]
public void When_Creating_Design_Document_With_Missing_Views_Argument_Exception_Is_Thrown()
@@ -517,6 +647,11 @@ public void When_Creating_Design_Document_With_Missing_Views_Argument_Exception_
_Cluster.CreateDesignDocument("default", "", json);
}
+ /// <summary>
+ /// @test: create design document and then retrieve it, operation should succeed
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if operaton is successful
+ /// </summary>
[Test]
public void When_Retrieving_Design_Document_Operation_Is_Successful()
{
@@ -535,6 +670,11 @@ public void When_Retrieving_Design_Document_Operation_Is_Successful()
Assert.That(Regex.Replace(json, @"\s", ""), Is.StringContaining(Regex.Replace(clusterJson, @"\s", "")));
}
+ /// <summary>
+ /// @test: retrieve design document that is invalid, exception should occur
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if exception occurs
+ /// </summary>
[Test]
[ExpectedException(typeof(WebException), ExpectedMessage="404", MatchType=MessageMatch.Contains)]
public void When_Retrieving_Invalid_Design_Document_Operation_Web_Exception_Is_Thrown()
@@ -542,6 +682,11 @@ public void When_Retrieving_Invalid_Design_Document_Operation_Web_Exception_Is_T
var result = _Cluster.RetrieveDesignDocument("foo", "bar");
}
+ /// <summary>
+ /// @test: create design document and then delete it, operation should be successful
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if deletion happens successfully
+ /// </summary>
[Test]
public void When_Deleting_Design_Document_Operation_Is_Successful()
{
@@ -564,6 +709,11 @@ public void When_Deleting_Design_Document_Operation_Is_Successful()
}
+ /// <summary>
+ /// @test: delete invalid design document and exception should occur
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if exception occurs
+ /// </summary>
[Test]
[ExpectedException(typeof(WebException), ExpectedMessage = "404", MatchType = MessageMatch.Contains)]
public void When_Deleting_Invalid_Design_Document_Operation_Web_Exception_Is_Thrown()
@@ -571,7 +721,13 @@ public void When_Deleting_Invalid_Design_Document_Operation_Web_Exception_Is_Thr
var result = _Cluster.DeleteDesignDocument("foo", "bar");
}
- [Test]
+ /// <summary>
+ /// @test: create design document, retrieve and delete it using a non default bucket and
+ /// verify that the operation is successful
+ /// @pre: non default configuration to initialize client in app.config
+ /// @post: Test passes if all the operations happen successfully
+ /// </summary>
+ [Test]
public void When_Managing_Design_Document_On_Non_Default_Bucket_Operation_Is_Successful()
{
var bucketName = "Bucket-" + DateTime.Now.Ticks;
View
12 src/Couchbase.Tests/CouchbaseJsonExtensionTests.cs
@@ -12,6 +12,12 @@ namespace Couchbase.Tests
[TestFixture]
public class CouchbaseJsonExtensionTests : CouchbaseClientTestsBase
{
+ /// <summary>
+ /// @test: create a city object, store it in form of json against
+ /// a unique key, then get the value, it should be saved as type string
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if result is of type string
+ /// </summary>
[Test]
public void When_Saving_City_With_JsonStore_City_Is_Stored_As_String()
{
@@ -23,6 +29,12 @@ public void When_Saving_City_With_JsonStore_City_Is_Stored_As_String()
Assert.That(savedCity, Is.InstanceOf<string>());
}
+ /// <summary>
+ /// @test: create a city object, store it in form of json against
+ /// a unique key, then get the Json object as return value
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if result is of type json object
+ /// </summary>
[Test]
public void When_Getting_City_With_JsonGet_City_Is_Returned_As_City()
{
View
109 src/Couchbase.Tests/DefaultCouchbaseClientConfigurationTests.cs
@@ -16,6 +16,12 @@ public class DefaultConfigurationSettingsTests
{
#region HTTP Factory Tests
+ /// <summary>
+ /// @test: create couchbase client using configuration and http client is not set,
+ /// then it creates instance of hammock http client
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if result is of type hammock http client
+ /// </summary>
[Test]
public void When_Using_Code_Config_And_Http_Client_Factory_Is_Not_Set_Hammock_Factory_Is_Default()
{
@@ -29,6 +35,12 @@ public void When_Using_Code_Config_And_Http_Client_Factory_Is_Not_Set_Hammock_Fa
Assert.That(typeName, Is.StringContaining("HammockHttpClient"));
}
+ /// <summary>
+ /// @test: create couchbase client using configuration from app.config and http client is not set,
+ /// then it creates instance of hammock http client
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if result is of type hammock http client
+ /// </summary>
[Test]
public void When_Using_App_Config_And_Http_Client_Factory_Is_Not_Set_Hammock_Factory_Is_Default()
{
@@ -43,6 +55,13 @@ public void When_Using_App_Config_And_Http_Client_Factory_Is_Not_Set_Hammock_Fac
Assert.That(typeName, Is.StringContaining("HammockHttpClient"));
}
+ /// <summary>
+ /// @test: create couchbase client using configuration and http client is not set,
+ /// then it creates instance of hammock http client. perform operations like storing key value,
+ /// the operations should all succeed
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if all operations succeed
+ /// </summary>
[Test]
public void When_Using_App_Config_And_Http_Client_Factory_Is_Not_Set_Operations_Succeed()
{
@@ -61,6 +80,13 @@ public void When_Using_App_Config_And_Http_Client_Factory_Is_Not_Set_Operations_
Assert.That(value, Is.StringMatching(kv.Item2));
}
+ /// <summary>
+ /// @test: create couchbase client using configuration from code and http client is not set,
+ /// then it creates instance of hammock http client. perform operations like
+ /// get and store and they should all pass
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if all operations should happen successfully
+ /// </summary>
[Test]
public void When_Using_Code_Config_And_Http_Client_Factory_Is_Not_Set_Operations_Succeed()
{
@@ -85,6 +111,12 @@ public void When_Using_Code_Config_And_Http_Client_Factory_Is_Not_Set_Operations
#region Design Doc Name Transformer Tests
+ /// <summary>
+ /// @test: Create couchbase client using code configuration, create design document with
+ /// no transformer name, the default mode will be production
+ /// @pre: Provide configuration of client like Uri, etc
+ /// @post: Test passes if Production mode is the default mode
+ /// </summary>
[Test]
public void When_Using_Code_Config_And_Design_Document_Name_Transformer_Is_Not_Set_Production_Mode_Is_Default()
{
@@ -94,6 +126,12 @@ public void When_Using_Code_Config_And_Design_Document_Name_Transformer_Is_Not_S
Assert.That(config.DesignDocumentNameTransformer, Is.InstanceOf<ProductionModeNameTransformer>()); }
+ /// <summary>
+ /// @test: Create couchbase client using configuration from App.config, create design document with
+ /// no transformer name, the default mode will be production
+ /// @pre: Provide configuration of client in app.config
+ /// @post: Test passes if Production mode is the default mode
+ /// </summary>
[Test]
public void When_Using_App_Config_And_Design_Document_Name_Transformer_Is_Not_Set_Production_Mode_Is_Default()
{
@@ -107,6 +145,12 @@ public void When_Using_App_Config_And_Design_Document_Name_Transformer_Is_Not_Se
#endregion
#region Timeouts
+
+ /// <summary>
+ /// @test: Create couchbase client and dont set time out, default would be 20 seconds
+ /// @pre: Provide configuration of client in app.config
+ /// @post: Test passes if http request time out is 20 seconds
+ /// </summary>
[Test]
public void When_Http_Timeout_Is_Not_Set_And_Using_App_Config_Default_Is_20_Seconds()
{
@@ -115,6 +159,11 @@ public void When_Http_Timeout_Is_Not_Set_And_Using_App_Config_Default_Is_20_Seco
Assert.That(config.Servers.HttpRequestTimeout, Is.EqualTo(TimeSpan.FromSeconds(20)));
}
+ /// <summary>
+ /// @test: Create couchbase client using code configuration and dont set time out, default would be 20 seconds
+ /// @pre: Provide configuration of client in code
+ /// @post: Test passes if http request time out is 20 seconds
+ /// </summary>
[Test]
public void When_Http_Timeout_Is_Not_Set_And_Using_Code_Config_Default_Is_20_Seconds()
{
@@ -123,6 +172,12 @@ public void When_Http_Timeout_Is_Not_Set_And_Using_Code_Config_Default_Is_20_Sec
Assert.That(config.HttpRequestTimeout, Is.EqualTo(TimeSpan.FromSeconds(20)));
}
+ /// <summary>
+ /// @test: Create couchbase client, set time out to 30 seconds, server time out should be 30 seconds,
+ /// it will overwrite the default time out
+ /// @pre: Provide configuration of client in app.config
+ /// @post: Test passes if http request time out is 30 seconds
+ /// </summary>
[Test]
public void When_Http_Timeout_Is_Set_To_30_And_Using_App_Config_Value_Is_30_Seconds()
{
@@ -131,6 +186,12 @@ public void When_Http_Timeout_Is_Set_To_30_And_Using_App_Config_Value_Is_30_Seco
Assert.That(config.Servers.HttpRequestTimeout, Is.EqualTo(TimeSpan.FromSeconds(30)));
}
+ /// <summary>
+ /// @test: Create couchbase client using configuration from app.config and dont set observe time out,
+ /// default would be 1 minute
+ /// @pre: Provide configuration of client in app.config
+ /// @post: Test passes if observe request time out is 1 minute
+ /// </summary>
[Test]
public void When_Observe_Timeout_Is_Not_Set_And_Using_App_Config_Default_Is_1_Minute()
{
@@ -139,6 +200,11 @@ public void When_Observe_Timeout_Is_Not_Set_And_Using_App_Config_Default_Is_1_Mi
Assert.That(config.Servers.ObserveTimeout, Is.EqualTo(TimeSpan.FromMinutes(1)));
}
+ /// <summary>
+ /// @test: Create couchbase client using code config and dont set observe time out, default would be 1 minute
+ /// @pre: Provide configuration of client in code config
+ /// @post: Test passes if observe request time out is 1 minute
+ /// </summary>
[Test]
public void When_Observe_Timeout_Is_Not_Set_And_Using_Code_Config_Default_Is_1_Minute()
{
@@ -147,6 +213,12 @@ public void When_Observe_Timeout_Is_Not_Set_And_Using_Code_Config_Default_Is_1_M
Assert.That(config.ObserveTimeout, Is.EqualTo(TimeSpan.FromMinutes(1)));
}
+ /// <summary>
+ /// @test: Create couchbase client usng ap.config and set observe time out to 30 seconds,
+ /// the time out would be 30 seconds
+ /// @pre: Provide configuration of client in app.config
+ /// @post: Test passes if observe request time out is 30 seconds
+ /// </summary>
[Test]
public void When_Observe_Timeout_Is_Set_To_30_And_Using_App_Config_Value_Is_30_Seconds()
{
@@ -157,14 +229,26 @@ public void When_Observe_Timeout_Is_Set_To_30_And_Using_App_Config_Value_Is_30_S
#endregion
#region HttpClient
+
+ /// <summary>
+ /// @test: Default value of InitializeConnection property in HttpClient class from appconfig is true.
+ /// @pre: Provide configuration of client in app.config, dont specify InitializeConnection
+ /// @post: Test passes if HttpClient.InitializeConnection returns true
+ /// </summary>
[Test]
public void When_Initialize_Connection_Is_Not_Set_In_App_Config_Default_Is_True()
{
var config = ConfigurationManager.GetSection("min-config") as CouchbaseClientSection;
Assert.That(config, Is.Not.Null, "Config was null");
- Assert.That(config.HttpClient.InitializeConnection, Is.True);
+ Assert.That(config.HttpClient.InitializeConnection, Is.True);
}
+ /// <summary>
+ /// @test: When InitializeConnection property in HttpClient class is set in app.config,
+ /// default value is overwritten.
+ /// @pre: Provide configuration of client in app.config, set InitializeConnection to false
+ /// @post: Test passes if HttpClient.InitializeConnection returns false
+ /// </summary>
[Test]
public void When_Initialize_Connection_Is_Set_In_App_Config_Property_Changes_From_Default()
{
@@ -173,6 +257,11 @@ public void When_Initialize_Connection_Is_Set_In_App_Config_Property_Changes_Fro
Assert.That(config.HttpClient.InitializeConnection, Is.False);
}
+ /// <summary>
+ /// @test: Default value of InitializeConnection property in HttpClient class from code config is true.
+ /// @pre: Provide configuration of client in app.config, dont specify InitializeConnection
+ /// @post: Test passes if HttpClient.InitializeConnection returns true
+ /// </summary>
[Test]
public void When_Initialize_Connection_Is_Not_Set_In_Code_Default_Is_True()
{
@@ -181,7 +270,12 @@ public void When_Initialize_Connection_Is_Not_Set_In_Code_Default_Is_True()
Assert.That(config.HttpClient.InitializeConnection, Is.True);
}
- [Test]
+ /// <summary>
+ /// @test: Default value of Httpclient time out property in HttpClient class from appconfig is 00:01:15.
+ /// @pre: Provide configuration of client in app.config, dont specify timeout
+ /// @post: Test passes if HttpClient.timeout is 00:01:15
+ /// </summary>
+ [Test]
public void When_Http_Client_Timeout_Is_Not_Set_In_App_Config_Default_Is_True()
{
var config = ConfigurationManager.GetSection("min-config") as CouchbaseClientSection;
@@ -189,6 +283,12 @@ public void When_Http_Client_Timeout_Is_Not_Set_In_App_Config_Default_Is_True()
Assert.That(config.HttpClient.Timeout, Is.EqualTo(TimeSpan.Parse("00:01:15")));
}
+ /// <summary>
+ /// @test: Default value of Httpclient time out property in HttpClient class from appconfig
+ /// is overwritten if specified
+ /// @pre: Provide configuration of client in app.config, dont specify timeout
+ /// @post: Test passes if HttpClient.timeout isas per mentioned in app.config
+ /// </summary>
[Test]
public void When_Http_Client_Timeout_Is_Set_In_App_Config_Property_Changes_From_Default()
{
@@ -197,6 +297,11 @@ public void When_Http_Client_Timeout_Is_Set_In_App_Config_Property_Changes_From_
Assert.That(config.HttpClient.Timeout, Is.EqualTo(TimeSpan.Parse("00:00:45")));
}
+ /// <summary>
+ /// @test: Default value of Httpclient time out property in HttpClient class is 75 seconds
+ /// @pre: Provide default configuration of client
+ /// @post: Test passes if HttpClient.timeout is 00:01:15
+ /// </summary>
[Test]
public void When_Http_Client_Timeout_Is_Not_Set_In_Code_Default_Is_75_Seconds()
{
View
28 src/Couchbase.Tests/HeartbeatConfigTests.cs
@@ -9,9 +9,23 @@
namespace Couchbase.Tests
{
+ /*
+ * The client will periodically check the health of its connection to the cluster by performing a heartbeat check. By default,
+ * this test is done every 10 seconds against the bootstrap URI defined in the servers element.
+ * The "uri", "enabled" and "interval" attributes are all optional. The "interval" is specified in milliseconds. Setting "enabled"
+ * to false will cause other settings to be ignored and the heartbeat will not be checked.
+ * <heartbeatMonitor uri="http://127.0.0.1:8091/pools/heartbeat" interval="60000" enabled="true" />
+ */
[TestFixture]
public class HeartbeatConfigTests : CouchbaseClientTestsBase
{
+ /// <summary>
+ /// @test: Reads the configuration from App.config which enables the heartbeat and then perform
+ /// client operations
+ /// @pre: Add section named "heartbeat-config-on" in App.config file, enable heartbeat at a specific time interval
+ /// @post: Test passes if with heartbeat on, the client can successfully store key-value and then able to get value;
+ /// fails otherwise
+ /// </summary>
[Test]
public void Client_Operations_Succeed_When_Heartbeat_Is_Configured()
{
@@ -27,6 +41,13 @@ public void Client_Operations_Succeed_When_Heartbeat_Is_Configured()
}
+ /// <summary>
+ /// @test: Reads the configuration from App.config which disables the heartbeat and then perform
+ /// client operations
+ /// @pre: Add section named "heartbeat-config-off" in App.config file, disable heartbeat
+ /// @post: Test passes if with heartbeat off, the client can successfully store key-value and then able to get value;
+ /// fails otherwise
+ /// </summary>
[Test]
public void Client_Operations_Succeed_When_Heartbeat_Is_Disabled()
{
@@ -42,6 +63,13 @@ public void Client_Operations_Succeed_When_Heartbeat_Is_Disabled()
}
+ /// <summary>
+ /// @test: Reads the configuration from App.config which has no information on heartbeat and then perform
+ /// client operations
+ /// @pre: Add section named "min-config" in App.config file, add information about bucket, bucket password, username/password
+ /// and server uri.
+ /// @post: Test passes if the client can successfully store key-value and then able to get value; fails otherwise
+ /// </summary>
[Test]
public void Client_Operations_Succeed_When_Heartbeat_Is_Not_Configured()
{
View
24 src/Couchbase.Tests/HttpClientConfigTests.cs
@@ -12,6 +12,13 @@ namespace Couchbase.Tests
[TestFixture]
public class HttpClientConfigTests : CouchbaseClientViewTestsBase
{
+ /// <summary>
+ /// @test: Reads the configuration of Http client from App.config and gets the view in specified design document
+ /// @pre: Add section named "httpclient-config-initconn" in App.config file,
+ /// set the initializeConnection parameter to true
+ /// configure all the parameters required to initialize Couchbase client like Uri, bucket, etc.
+ /// @post: Test passes if successfully gets the view, fails otherwise
+ /// </summary>
[Test]
public void View_Operations_Succeed_When_Initialize_Connection_Is_True()
{
@@ -21,6 +28,13 @@ public void View_Operations_Succeed_When_Initialize_Connection_Is_True()
viewPass(view);
}
+ /// <summary>
+ /// @test: Reads the configuration of Http client from App.config and gets the view in specified design document
+ /// @pre: Add section named "httpclient-config-initconn" in App.config file,
+ /// configure all the parameters required to initialize Couchbase client like Uri, bucket, etc.
+ /// set the initializeConnection parameter to false
+ /// @post: Test passes if successfully gets the view, fails otherwise
+ /// </summary>
[Test]
public void View_Operations_Succeed_When_Initialize_Connection_Is_False()
{
@@ -32,6 +46,12 @@ public void View_Operations_Succeed_When_Initialize_Connection_Is_False()
}
+ /// <summary>
+ /// @test: when no configuration for Http client is mentioned in App.config,
+ /// the test would get the view in specified design document
+ /// @pre: no section in App.config file to initialize client
+ /// @post: Test passes if successfully gets the view, fails otherwise
+ /// </summary>
[Test]
public void View_Operations_Succeed_When_HTTP_Client_Is_Not_Configured_In_App_Config()
{
@@ -40,6 +60,10 @@ public void View_Operations_Succeed_When_HTTP_Client_Is_Not_Configured_In_App_Co
}
+ /// <summary>
+ /// Verifies all the properties of view and asserts true if it is not null, false otherwise
+ /// </summary>
+ /// <param name="view">Name of design view</param>
private void viewPass(IView<City> view)
{
foreach (var item in view)
Please sign in to comment.
Something went wrong with that request. Please try again.