public void MSASTASK_S01_TC01_CreateTaskItemRecursDaily()
{
#region Call Sync command to create a task item with Recurrence whose Type element is recurs daily.
SyncStore initializeSyncResponse = this.TASKAdapter.Sync(Common.CreateInitialSyncRequest(this.UserInformation.TasksCollectionId));
string subject = Common.GenerateResourceName(Site, "subject");
string clientId = System.Guid.NewGuid().ToString();
DateTime startTime = DateTime.Now;
DateTime utcStartTime = startTime.ToUniversalTime();
DateTime until = startTime.AddDays(10);
// Create a task Item with Type 0 and DayOfWeek
string stringRequest = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Sync xmlns=\"AirSync\"><Collections><Collection><SyncKey>" + initializeSyncResponse.SyncKey + "</SyncKey><CollectionId>" + this.UserInformation.TasksCollectionId + "</CollectionId><DeletesAsMoves>0</DeletesAsMoves><GetChanges>1</GetChanges><WindowSize>512</WindowSize><Options><BodyPreference xmlns=\"AirSyncBase\"><Type>2</Type></BodyPreference></Options><Commands><Add><ClientId>" + clientId + "</ClientId><ApplicationData><Body xmlns=\"AirSyncBase\"><Type>1</Type><Data>Content of the body.</Data></Body><UtcStartDate xmlns=\"Tasks\">" + utcStartTime.ToString("yyyy-MM-ddTHH:mm:ss.fffZ") + "</UtcStartDate><StartDate xmlns=\"Tasks\">" + startTime.ToString("yyyy-MM-ddTHH:mm:ss.fffZ") + "</StartDate><UtcDueDate xmlns=\"Tasks\">" + utcStartTime.AddHours(5).ToString("yyyy-MM-ddTHH:mm:ss.fffZ") + "</UtcDueDate><DueDate xmlns=\"Tasks\">" + startTime.AddHours(5).ToString("yyyy-MM-ddTHH:mm:ss.fffZ") + "</DueDate><ReminderSet xmlns=\"Tasks\">1</ReminderSet><ReminderTime xmlns=\"Tasks\">" + startTime.AddDays(-1).ToString("yyyy-MM-ddTHH:mm:ss.fffZ") + "</ReminderTime><Subject xmlns=\"Tasks\">" + subject + "</Subject><Importance xmlns=\"Tasks\">0</Importance><Categories xmlns=\"Tasks\"><Category xmlns=\"Tasks\">Business</Category><Category xmlns=\"Tasks\">Waiting</Category></Categories><Recurrence xmlns=\"Tasks\"><Type>0</Type><Start>" + DateTime.Now.AddHours(1).ToString("yyyy-MM-ddTHH:mm:ss.fffZ") + "</Start><Until>" + until.ToString("yyyy-MM-ddTHH:mm:ss.fffZ") + "</Until><Interval>1</Interval><DayOfWeek>2</DayOfWeek></Recurrence></ApplicationData></Add></Commands></Collection></Collections></Sync>";
SendStringResponse sendStringResponse = this.TASKAdapter.SendStringRequest(stringRequest, CommandName.Sync);
SyncStore response;
if (Common.IsRequirementEnabled(631, Site))
{
response = this.ExtractSyncStore(sendStringResponse);
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R631");
// Verify MS-ASTASK requirement: MS-ASTASK_R631
Site.CaptureRequirementIfAreEqual<int>(
6,
int.Parse(response.AddResponses[0].Status),
631,
@"[In Appendix A: Product Behavior] If the Type element value is 0 (zero), the DayOfWeek element is not a required child element of the Recurrence element. (<1> Section 2.2.2.10: When the Type element value is 0, Exchange 2007 SP1 responds with a status 6 if DayOfWeek is set in the request.)");
int dayOfWeekIndex = stringRequest.IndexOf("<DayOfWeek>");
int dayOfWeekEndIndex = stringRequest.IndexOf("</DayOfWeek>") + 11;
stringRequest = stringRequest.Remove(dayOfWeekIndex, dayOfWeekEndIndex - dayOfWeekIndex + 1);
sendStringResponse = this.TASKAdapter.SendStringRequest(stringRequest, CommandName.Sync);
}
// Extract status code from string response
response = this.ExtractSyncStore(sendStringResponse);
Site.Assert.AreEqual<int>(1, int.Parse(response.AddResponses[0].Status), "Task item should be created successfully.");
ItemsNeedToDelete.Add(subject);
#endregion
#region Call Sync command to get the task item.
SyncItem syncedTaskItem = this.GetChangeItem(this.UserInformation.TasksCollectionId, subject);
Site.Assert.IsNotNull(syncedTaskItem.Task, "The task which subject is {0} should exist in server.", subject);
#endregion
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R158");
// Verify MS-ASTASK requirement: MS-ASTASK_R158
// The DeadOccure is not set in the request and the DeadOccur in the response value is 0, this requirement can be covered.
Site.CaptureRequirementIfAreEqual<byte?>(
0,
syncedTaskItem.Task.Recurrence.DeadOccur,
158,
@"[In DeadOccur]The default value of the DeadOccur element is 0 (zero).");
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R264");
// Verify MS-ASTASK requirement: MS-ASTASK_R264
Site.CaptureRequirementIfAreEqual<byte?>(
0,
syncedTaskItem.Task.Sensitivity,
264,
@"[In Sensitivity] The default value of the Sensitivity element is 0 (zero) (normal).");
}