public void TestCase_S07_TC08_EditorsTable_UpdateEditSession_AddKeyValuePair()
{
if (!Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 9001, this.Site))
{
Site.Assume.Inconclusive("Implementation does not support the editors table.");
}
// Initialize the service
this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);
// Join the editors table using default client id
this.PrepareJoinEditorsTable(this.DefaultFileUrl, SharedTestSuiteHelper.DefaultClientID);
// Generate a key.
string firstKey = SharedTestSuiteHelper.GenerateRandomString(4);
// Create a update editor session object with the key.
byte[] content = System.Text.Encoding.Unicode.GetBytes(SharedTestSuiteHelper.GenerateRandomString(10));
EditorsTableSubRequestType update = SharedTestSuiteHelper.CreateEditorsTableSubRequestForUpdateSessionMetadata(SharedTestSuiteHelper.DefaultClientID, firstKey, content);
// Call protocol adapter operation CellStorageRequest to add the key/value pair.
CellStorageResponse cellStorageResponse = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { update });
EditorsTableSubResponseType subResponse = SharedTestSuiteHelper.ExtractSubResponse<EditorsTableSubResponseType>(cellStorageResponse, 0, 0, this.Site);
this.Site.Assert.AreEqual<ErrorCodeType>(
ErrorCodeType.Success,
SharedTestSuiteHelper.ConvertToErrorCodeType(subResponse.ErrorCode, this.Site),
"Update the editor table with the key {0} and value {1} on the file {2} should succeed.",
firstKey,
"firstTestValue",
this.DefaultFileUrl);
// Get the RefreshEditSession editors table to verify the key/value is added successfully.
EditorsTable editorsTable = this.FetchEditorTable(this.DefaultFileUrl);
Editor editor = this.FindEditorById(editorsTable, SharedTestSuiteHelper.DefaultClientID);
bool isUpdated = editor.Metadata.ContainsKey(firstKey);
this.Site.Assert.IsTrue(
isUpdated,
"The Key/Value pair should be added successfully.",
firstKey,
"firstTestValue",
this.DefaultFileUrl);
// Create another update editor session to update the key/value pair.
string secondKey = SharedTestSuiteHelper.GenerateRandomString(4);
update = SharedTestSuiteHelper.CreateEditorsTableSubRequestForUpdateSessionMetadata(SharedTestSuiteHelper.DefaultClientID, secondKey, content);
cellStorageResponse = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { update });
subResponse = SharedTestSuiteHelper.ExtractSubResponse<EditorsTableSubResponseType>(cellStorageResponse, 0, 0, this.Site);
this.Site.Assert.AreEqual<ErrorCodeType>(
ErrorCodeType.Success,
SharedTestSuiteHelper.ConvertToErrorCodeType(subResponse.ErrorCode, this.Site),
"Update the editor table with the key {0} and value {1} on the file {2} should succeed.",
secondKey,
"secondTestValue",
this.DefaultFileUrl);
// Get the RefreshEditSession editors table to verify the key/value is updated.
editorsTable = this.FetchEditorTable(this.DefaultFileUrl);
editor = this.FindEditorById(editorsTable, SharedTestSuiteHelper.DefaultClientID);
isUpdated = editor.Metadata.ContainsKey(secondKey);
this.Site.Assert.IsTrue(
isUpdated,
"Update the editor table with the key {0} and value {1} on the file {2} should succeed.",
secondKey,
"secondTestValue",
this.DefaultFileUrl);
if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
{
// Verify MS-FSSHTTP requirement: MS-FSSHTTP_R1994
Site.CaptureRequirementIfIsTrue(
isUpdated,
"MS-FSSHTTP",
1994,
@"[In Update Editor Metadata][or] The protocol server processes this request[Update Editor Metadata] to update the client-supplied key/value pair in the entry in the editors table associated with the coauthorable file corresponding to the client with the given ClientId.");
}
else
{
Site.Assert.IsTrue(
isUpdated,
@"[In Update Editor Metadata][or] The protocol server processes this request[Update Editor Metadata] to update the client-supplied key/value pair in the entry in the editors table associated with the coauthorable file corresponding to the client with the given ClientId.");
}
}