Permalink
Browse files

NCBC-174: Fixes to invalid or missing tests

Change-Id: I0974380cd9042550a7238512c0e7e6d383f1b183
Reviewed-on: http://review.couchbase.org/24980
Reviewed-by: Saakshi Manocha <saakshi.manocha@globallogic.com>
Tested-by: Saakshi Manocha <saakshi.manocha@globallogic.com>
  • Loading branch information...
johnzablocki authored and saakshimanocha committed Mar 4, 2013
1 parent cff3ff0 commit 3916ff982d0f305fb9e4fc359f97cb47083d4ae7
@@ -43,6 +43,22 @@ public void When_Bucket_Is_Authenticated_And_No_Credentials_Are_Provided_Excepti
foreach (var item in view) { Console.WriteLine(item); }
}
+ /// <summary>
+ /// @test: Verifies that for the bucket which is authenticated with password, it throws an error
+ /// if bad 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(InvalidOperationException))]
+ [Test]
+ public void When_Bucket_Is_Authenticated_And_Bad_Credentials_Are_Provided_Exception_Is_Thrown()
+ {
+ var client = getClient(ConfigurationManager.AppSettings["SaslBucketName"], "bad_credentials");
+ var view = client.GetView("cities", "by_name");
+ foreach (var item in view) { Console.WriteLine(item); }
+ }
+
/// <summary>
/// Connects to couchbase client with given configuration details
/// </summary>
@@ -50,6 +50,24 @@ public void When_Storing_Item_With_Invalid_Cas_Result_Is_Not_Successful()
StoreAssertFail(casResult);
}
+ /// <summary>
+ /// @test: Store a randomly generated unique key-value, use the CAS value
+ /// returned from the Store(), then use ExecuteCas() method
+ /// to replace the 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 replace a key-value pair, fails otherwise
+ /// </summary>
+ [Test]
+ public void When_Replacing_Item_With_Valid_Cas_Result_Is_Successful()
+ {
+ var key = GetUniqueKey("cas");
+ var value = GetRandomString();
+ var storeResult = Store(StoreMode.Add, key, value);
+ StoreAssertPass(storeResult);
+
+ var casResult = _Client.ExecuteCas(StoreMode.Replace, key, value, storeResult.Cas);
+ StoreAssertPass(casResult);
+ }
}
}
@@ -90,7 +90,7 @@ public void When_Generic_Getting_Existing_Item_Value_Is_Not_Null_And_Result_Is_S
/// @post: Test passes if successfully stores all keys and count is correct
/// </summary>
[Test]
- public void When_Getting_Multiple_Keys_Result_Is_Successful()
+ public void When_Getting_Multiple_Existing_Keys_Result_Is_Successful()
{
var keys = GetUniqueKeys().Distinct();
foreach (var key in keys)
@@ -107,6 +107,21 @@ public void When_Getting_Multiple_Keys_Result_Is_Successful()
}
}
+ /// <summary>
+ /// @test: Get unique set of keys but do not store them in bucket. Get the keys and verify the count
+ /// should be zero and no key should be found as a result of get operation
+ /// @pre: Default configuration to initialize client in app.config
+ /// @post: Test passes if no key is found
+ /// </summary>
+ [Test]
+ public void When_Getting_Multiple_Non_Existent_Keys_Result_Is_Not_Successful()
+ {
+ var keys = GetUniqueKeys().Distinct();
+
+ var dict = _Client.ExecuteGet(keys);
+ Assert.That(dict.Keys.Count, Is.EqualTo(0), "Keys count expected is zero as none of the keys exist, but it is {0} which is incorrect.", dict.Keys.Count);
+ }
+
/// <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
Oops, something went wrong.

0 comments on commit 3916ff9

Please sign in to comment.