示例#1
0
        private Dataset ConvertToWrapper(string json)
        {
            CoreModel.Dataset internalDataset =
                Core.DataFactoryManagementClient.DeserializeInternalDatasetJson(json);

            return(this.Operations.Converter.ToWrapperType(internalDataset));
        }
        /// <summary>
        /// Serializes the given Core.Models.Dataset into JSON, by mocking a create or update request to
        /// exercise the client's serialization logic.
        /// </summary>
        /// <param name="item">The object to serialize.</param>
        /// <returns></returns>
        internal static string SerializeInternalDatasetToJson(Models.Dataset item)
        {
            var createParams = new Models.DatasetCreateOrUpdateParameters()
            {
                Dataset = item
            };

            var    handler           = new MockResourceProviderDelegatingHandler();
            var    client            = GetFakeClient(handler);
            string resourceGroupName = Guid.NewGuid().ToString("D");
            string dataFactoryName   = Guid.NewGuid().ToString("D");

            client.Datasets.BeginCreateOrUpdate(resourceGroupName, dataFactoryName, createParams);
            return(handler.Json);
        }
示例#3
0
        private Core.Models.DatasetCreateOrUpdateParameters ValidateAndConvert(DatasetCreateOrUpdateParameters parameters)
        {
            // Validate
            Ensure.IsNotNull(parameters, "parameters");
            Ensure.IsNotNull(parameters.Dataset, "parameters.Dataset");
            this.ValidateObject(parameters.Dataset);

            // Convert
            Core.Models.Dataset internalDataset = this.Converter.ToCoreType(parameters.Dataset);

            return(new Core.Models.DatasetCreateOrUpdateParameters()
            {
                Dataset = internalDataset
            });
        }
示例#4
0
        private void TestDatasetJson(JsonSampleInfo info)
        {
            string  json    = info.Json;
            Dataset dataset = this.ConvertToWrapper(json);

            CoreModel.Dataset actual     = this.Operations.Converter.ToCoreType(dataset);
            string            actualJson = Core.DataFactoryManagementClient.SerializeInternalDatasetToJson(actual);

            JsonComparer.ValidateAreSame(json, actualJson, ignoreDefaultValues: true);

            if (info.Version == null ||
                !info.Version.Equals(JsonSampleType.Unregistered, StringComparison.OrdinalIgnoreCase))
            {
                Assert.IsNotType <GenericDataset>(dataset.Properties.TypeProperties);
            }

            JObject actualJObject = JObject.Parse(actualJson);

            JsonComparer.ValidatePropertyNameCasing(actualJObject, true, string.Empty, info.PropertyBagKeys);
        }
        public Dataset ADFDatasetFromJson(JObject jsonObject)
        {
            Type       dynClass;
            MethodInfo dynMethod;

            string objectType = "Dataset";

            MapConfigElements(ref jsonObject);
            MapSlices(ref jsonObject);

            dynClass  = new Core.DataFactoryManagementClient().GetType();
            dynMethod = dynClass.GetMethod("DeserializeInternal" + objectType + "Json", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
            CoreModels.Dataset internalObject = (CoreModels.Dataset)dynMethod.Invoke(this, new object[] { jsonObject.ToString() });

            dynClass = Type.GetType(dynClass.AssemblyQualifiedName.Replace("Core.DataFactoryManagementClient", "Conversion." + objectType + "Converter"));
            ConstructorInfo constructor = dynClass.GetConstructor(Type.EmptyTypes);
            object          classObject = constructor.Invoke(new object[] { });

            dynMethod = dynClass.GetMethod("ToWrapperType", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
            Dataset ret = (Dataset)dynMethod.Invoke(classObject, new object[] { internalObject });

            return(ret);
        }