Microsoft.Protocols.TestSuites.MS_LISTSWS.S03_OperationOnListItem.MSLISTSWS_S03_TC76_UpdateListItemsWithKnowledge_DateInUtc C# (CSharp) Method

MSLISTSWS_S03_TC76_UpdateListItemsWithKnowledge_DateInUtc() private method

        public void MSLISTSWS_S03_TC76_UpdateListItemsWithKnowledge_DateInUtc()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(25151, this.Site), @"Test is executed only when R25151Enabled is set to true.");

            // Create a list.
            string listId = TestSuiteHelper.CreateList();

            // Get the configure value.
            string validFieldName = Common.GetConfigurationPropertyValue("ListFieldText", this.Site);

            // Construct three items: the second one is invalid, the first and the last one are valid.
            List<Dictionary<string, string>> items = new List<Dictionary<string, string>>(3);
            List<MethodCmdEnum> cmds = new List<MethodCmdEnum>();

            // Construct one insert item.
            Dictionary<string, string> item1 = new Dictionary<string, string>();
            item1.Add(validFieldName, TestSuiteHelper.GenerateRandomString(5));
            items.Add(item1);
            cmds.Add(MethodCmdEnum.New);

            // Construct the UpdateListItemsUpdates instance.
            UpdateListItemsUpdates updates = TestSuiteHelper.CreateUpdateListItems(cmds, items, OnErrorEnum.Return);

            // Set "Batch" element with "DateInUtc" attribute as TRUE, then call UpdateListItems method.
            updates.Batch.DateInUtc = "TRUE";
            UpdateListItemsResponseUpdateListItemsResult result = this.listswsAdapter.UpdateListItems(
                                                                                listId,
                                                                                updates);

            // There must be one result element.
            Site.Assert.AreEqual<int>(
                                    1,
                                    result.Results.Length,
                                    "There are at least one result corresponding with the one New method");
            DataTable data = AdapterHelper.ExtractData(result.Results[0].Any);
            string createdDateTime = data.Rows[0]["ows_Created"].ToString();
            bool isUtcFormat = createdDateTime.IndexOf('T') > 0;
            Site.CaptureRequirementIfIsTrue(
                isUtcFormat,
                2345,
                "[In UpdateListItemsWithKnowledge][In Bench element][In DateInUtc attribute] If set "
                + "DaeInUtc to TRUE, then dates passed up and returned are in UTC format.");

            // Set "Batch" element with "DateInUtc" attribute as FALSE, then call UpdateListItems method.
            updates.Batch.DateInUtc = "FALSE";
            result = this.listswsAdapter.UpdateListItems(
                                                        listId,
                                                        updates);

            // There must be one result element.
            Site.Assert.AreEqual<int>(
                                    1,
                                    result.Results.Length,
                                    "There are at least one result corresponding with the one New method");
            data = AdapterHelper.ExtractData(result.Results[0].Any);
            createdDateTime = data.Rows[0]["ows_Created"].ToString();
            bool isNotUtcFormat = createdDateTime.IndexOf('T') < 0;
            Site.CaptureRequirementIfIsTrue(
                isNotUtcFormat,
                2365,
                "[In UpdateListItemsWithKnowledge][In Bench element][In DateInUtc attribute] If set "
                    + "DaeInUtc to FALSE, then dates passed up and returned are not in UTC format.");

            // Set "Batch" element with "DateInUtc" attribute as null, then call UpdateListItems method.
            updates.Batch.DateInUtc = null;
            result = this.listswsAdapter.UpdateListItems(
                                                        listId,
                                                        updates);

            // There must be one result element.
            Site.Assert.AreEqual<int>(
                                    1,
                                    result.Results.Length,
                                    "There are at least one result corresponding with the one New method");
            data = AdapterHelper.ExtractData(result.Results[0].Any);
            createdDateTime = data.Rows[0]["ows_Created"].ToString();
            isNotUtcFormat = createdDateTime.IndexOf('T') < 0;
            Site.CaptureRequirementIfIsTrue(
                isNotUtcFormat,
                2346,
                "[In UpdateListItemsWithKnowledge][In Bench element][In DateInUtc attribute]"
                    + "[Specifies whether dates passed up and returned are in UTC format. ]This defaults to FALSE");
        }
S03_OperationOnListItem