Permalink
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...
1 parent f828a51 commit 9f20a63014c2234c761fce8242b651cfa1a3f245 @saakshimanocha saakshimanocha committed with John C. Zablocki Dec 6, 2012
@@ -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()
{
@@ -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();
@@ -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()
{
@@ -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()
{
@@ -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()
{
@@ -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()
{
@@ -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()
{
Oops, something went wrong.

0 comments on commit 9f20a63

Please sign in to comment.