Microsoft.Protocols.TestSuites.MS_ASTASK.S01_SyncCommand.MSASTASK_S01_TC24_CreateTaskItemRecursWeeklyWithFirstDayOfWeekReturned C# (CSharp) Method

MSASTASK_S01_TC24_CreateTaskItemRecursWeeklyWithFirstDayOfWeekReturned() private method

        public void MSASTASK_S01_TC24_CreateTaskItemRecursWeeklyWithFirstDayOfWeekReturned()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The FirstDayOfWeek element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual<string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The FirstDayOfWeek element is not supported when the MS-ASProtocolVersion header is set to 14.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Call Sync command to create a task item which recurs weekly.
            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(21);

            // Create a task Item with Type 0
            SendStringResponse sendStringResponse = this.TASKAdapter.SendStringRequest("<?xml version=\"1.0\" encoding=\"utf-8\"?><Sync xmlns=\"AirSync\"><Collections><Collection><SyncKey>" + initializeSyncResponse.SyncKey + "</SyncKey><CollectionId>11</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><Recurrence xmlns=\"Tasks\"><Type>1</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>", CommandName.Sync);

            // Extract status code from string response
            SyncStore 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_R167");

            // Verify MS-ASTASK requirement: MS-ASTASK_R167
            // If FirstDayOfWeekSpecified is true, FirstDayOfWeek element is returned from server.
            Site.CaptureRequirementIfIsTrue(
                syncedTaskItem.Task.Recurrence.FirstDayOfWeekSpecified,
                167,
                @"[In FirstDayOfWeek] The server MUST return a FirstDayOfWeek element when the value of the Type element (section 2.2.2.27) is 1.");
        }
    }