コード例 #1
0
 private static SerializationFormatData ForData(string name, params string[] mimeTypes)
 {
     SerializationFormatData result = new SerializationFormatData();
     result.name = name;
     result.mimeTypes = mimeTypes;
     return result;
 }
コード例 #2
0
        private static SerializationFormatData ForData(string name, params string[] mimeTypes)
        {
            SerializationFormatData result = new SerializationFormatData();

            result.name      = name;
            result.mimeTypes = mimeTypes;
            return(result);
        }
コード例 #3
0
        /// <summary>Gets a formatted key value for an existing resource in the specified container.</summary>
        /// <param name="containerName">Name of container.</param>
        /// <returns>A formatted key value.</returns>
        public string GetSampleKey(string containerName, SerializationFormatData format)
        {
            TestUtil.CheckArgumentNotNull(containerName, "containerName");
            TestUtil.CheckArgumentNotNull(format, "format");
            object[] keys = GetSampleKeyValues(containerName);
            if (keys == null)
            {
                return(null);
            }

            // Currently supporting all formats as if they had identical literals (XML-based).
            return(TestUtil.Join(",", keys.Select((k) => TypeData.XmlValueFromObject(k))));
        }
コード例 #4
0
 private static void CreateValues()
 {
     if (values == null)
     {
         atom      = ForData("Atom", UnitTestsUtil.AtomFormat, "text/xml", "application/xml");
         jsonlight = ForData("JsonLight", UnitTestsUtil.JsonLightMimeType);
         binary    = ForData("Binary", "application/octet-stream");
         values    = new SerializationFormatData[] {
             atom,
             jsonlight,
             binary,
             ForData("Text", "text/plain"),
         };
     }
 }
コード例 #5
0
 private static void CreateValues()
 {
     if (values == null)
     {
         atom = ForData("Atom", UnitTestsUtil.AtomFormat, "text/xml", "application/xml");
         jsonlight = ForData("JsonLight", UnitTestsUtil.JsonLightMimeType);
         binary = ForData("Binary", "application/octet-stream");
         values = new SerializationFormatData[] {
                 atom,
                 jsonlight,
                 binary,
                 ForData("Text", "text/plain"),
             };
     }
 }
コード例 #6
0
ファイル: UpdateTests.cs プロジェクト: larsenjo/odata.net
                internal Stream BuildRequestBody(
                    string method, 
                    SerializationFormatData format, 
                    ServiceModelData model, 
                    bool includeKeys, 
                    bool includeId)
                {
                    if (method == "GET" || method == "DELETE")
                    {
                        return null;
                    }
                    else if (!this.Addressable || this.SystemGenerated)
                    {
                        return new MemoryStream(Encoding.UTF8.GetBytes("foo"));
                    }

                    string text = null;
                    switch (this.Kind)
                    {
                        case AddressableElementKind.Metadata:
                        case AddressableElementKind.ServiceDocument:
                        case AddressableElementKind.EntitySet:
                            break;
                        case AddressableElementKind.Entity:
                            string containerName = model.SampleContainer;
                            string containerTypeName = model.GetContainerRootTypeName(containerName);
                            string keyName = model.GetKeyProperties(containerTypeName).Single().Name;
                            string nonKeyName = model.GetNonKeyPrimitiveProperties(containerTypeName).First().Name;
                            if (format == SerializationFormatData.Atom)
                            {
                                // null.
                                //text = "<entry " +
                                //    "xmlns:ads='http://docs.oasis-open.org/odata/ns/data' " +
                                //    "xmlns:adsm='http://docs.oasis-open.org/odata/ns/metadata' " +
                                //    "xmlns='http://www.w3.org/2005/Atom' " +
                                //    "adsm:null='true' />";

                                // valid payload.
                                text = "<entry " +
                                    "xmlns:ads='http://docs.oasis-open.org/odata/ns/data' " +
                                    "xmlns:adsm='http://docs.oasis-open.org/odata/ns/metadata' " +
                                    "xmlns='http://www.w3.org/2005/Atom'>\r\n" +
                                    ((includeId) ? String.Format(" <id>{0}</id>", this.BuildRequestUri(model)) : " <id />") +
                                    "\r\n <author><name /></author>\r\n" +
                                    " <content type='application/xml'><adsm:properties>\r\n" +
                                    String.Format("  <ads:{0}>123</ads:{0}>", nonKeyName) +
                                    ((includeKeys) ? String.Format("  <ads:{0}>9999</ads:{0}>", keyName) : "") +
                                    "\r\n </adsm:properties></content>" +
                                    "</entry>";
                            }
                            else if (format == SerializationFormatData.JsonLight)
                            {
                            }
                            break;
                        case AddressableElementKind.EntityPrimitivePropertyValue:
                        case AddressableElementKind.EntityPrimitiveOpenPropertyValue:
                        case AddressableElementKind.EntityPrimitiveOpenProperty:
                            return new MemoryStream(Encoding.UTF8.GetBytes("1"));
                        case AddressableElementKind.EntityReference:
                            return null;
                        case AddressableElementKind.EntityCollectionReference:
                            return null;
                        case AddressableElementKind.EntityComplexOpenPropertyValue:
                            return null;
                        case AddressableElementKind.EntityComplexOpenProperty:
                            return null;
                        case AddressableElementKind.EntityOpenReference:
                            return null;
                        case AddressableElementKind.EntityOpenCollectionReference:
                            return null;
                    }

                    if (text == null)
                    {
                        return null;
                    }
                    else
                    {
                        return new MemoryStream(Encoding.UTF8.GetBytes(text));
                    }
                }