コード例 #1
0
        public void Test_Conversion_AlliasedDateTime_ToXml()
        {
            var executor  = new ExecuteFetchRequestExecutor();
            var date      = new DateTime(2011, 7, 12, 13, 12, 43, DateTimeKind.Local);
            var element   = executor.AttributeValueToFetchResult(new KeyValuePair <string, object>("alias.new_startdate", new AliasedValue(null, null, date)), null, null);
            var utcOffset = date.ToString("zz");

            Assert.NotNull(element);
            Assert.Equal(@"<alias.new_startdate date=""2011-07-12"" time=""01:12 PM"">2011-07-12T13:12:43" + utcOffset + ":00</alias.new_startdate>", element.ToString());
        }
コード例 #2
0
        public void Test_Conversion_AlliasedDateTime_ToXml()
        {
            var executor  = new ExecuteFetchRequestExecutor();
            var date      = new DateTime(2011, 7, 12, 13, 12, 43, DateTimeKind.Local);
            var element   = executor.AttributeValueToFetchResult(new KeyValuePair <string, object>("alias.new_startdate", new AliasedValue(null, null, date)), null, null);
            var utcOffset = date.ToString("zz");
            var localizedAMPMDesignator = date.ToString("tt"); //Spanish and other cultures don't have the AM/PM designator

            Assert.NotNull(element);
            Assert.Equal($"<alias.new_startdate date=\"2011-07-12\" time=\"01:12 {localizedAMPMDesignator}\">2011-07-12T13:12:43{utcOffset}:00</alias.new_startdate>", element.ToString());
        }
コード例 #3
0
        public void Test_Conversion_OptionSetValue_ToXml()
        {
            var fake = new XrmFakedContext();

            fake.ProxyTypesAssembly = typeof(Crm.Contact).Assembly;
            var executor        = new ExecuteFetchRequestExecutor();
            var formattedValues = new FormattedValueCollection();

            formattedValues.Add("new_contact", "Test");
            var element = executor.AttributeValueToFetchResult(new KeyValuePair <string, object>("new_contact", new OptionSetValue(1)), formattedValues, fake);

            Assert.NotNull(element);
            Assert.Equal(@"<new_contact name=""Test"" formattedvalue=""1"">1</new_contact>", element.ToString());
        }
コード例 #4
0
        public void Test_Conversion_EntityReference_ToXml()
        {
            var fake = new XrmFakedContext();

            fake.ProxyTypesAssembly = typeof(Crm.Contact).Assembly;
            var executor    = new ExecuteFetchRequestExecutor();
            var contactGuid = Guid.NewGuid();
            var element     = executor.AttributeValueToFetchResult(new KeyValuePair <string, object>("new_contact", new EntityReference("contact", contactGuid)
            {
                Name = "John Doe"
            }), null, fake);

            Assert.NotNull(element);
            Assert.Equal(@"<new_contact dsc=""0"" yomi=""John Doe"" name=""John Doe"" type=""2"">" + contactGuid.ToString().ToUpper() + "</new_contact>", element.ToString());
        }
コード例 #5
0
        public void Test_Conversion_OptionSetValueCollection_ToXml()
        {
            var fake = new XrmFakedContext();

            fake.ProxyTypesAssembly = typeof(Crm.Contact).Assembly;
            var executor        = new ExecuteFetchRequestExecutor();
            var formattedValues = new FormattedValueCollection();
            var element         = executor.AttributeValueToFetchResult(
                new KeyValuePair <string, object>("new_multiselectattribute", new OptionSetValueCollection()
            {
                new OptionSetValue(1), new OptionSetValue(2)
            }),
                formattedValues,
                fake);

            Assert.NotNull(element);
            Assert.Equal(@"<new_multiselectattribute name=""[-1,1,2,-1]"">[-1,1,2,-1]</new_multiselectattribute>", element.ToString());
        }