Beispiel #1
0
        private Table ConvertToWrapper(string json)
        {
            CoreModel.Table internalTable =
                Core.DataFactoryManagementClient.DeserializeInternalTableJson(json);

            return(this.Operations.Converter.ToWrapperType(internalTable));
        }
        /// <summary>
        /// Serializes the given Core.Models.Table 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 SerializeInternalTableToJson(Models.Table item)
        {
            var createParams = new Models.TableCreateOrUpdateParameters()
            {
                Table = item
            };

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

            client.Tables.BeginCreateOrUpdate(resourceGroupName, dataFactoryName, createParams);
            return(handler.Json);
        }
        private Core.Models.TableCreateOrUpdateParameters ValidateAndConvert(TableCreateOrUpdateParameters parameters)
        {
            // Validate
            Ensure.IsNotNull(parameters, "parameters");
            Ensure.IsNotNull(parameters.Table, "parameters.Table");
            this.ValidateObject(parameters.Table);

            // Convert
            Core.Models.Table internalTable = this.Converter.ToCoreType(parameters.Table);

            return(new Core.Models.TableCreateOrUpdateParameters()
            {
                Table = internalTable
            });
        }
Beispiel #4
0
        private void TestTableJson(JsonSampleInfo info)
        {
            string json  = info.Json;
            Table  table = this.ConvertToWrapper(json);

            CoreModel.Table actual     = this.Operations.Converter.ToCoreType(table);
            string          actualJson = Core.DataFactoryManagementClient.SerializeInternalTableToJson(actual);

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

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

            JObject actualJObject = JObject.Parse(actualJson);

            JsonComparer.ValidatePropertyNameCasing(actualJObject, true, string.Empty, info.PropertyBagKeys);
        }