Ejemplo n.º 1
0
        /// <summary>
        /// Serializes the given <see cref="DataFactory" /> into JSON, by mocking a create request to
        /// exercise the client's serialization logic.
        /// </summary>
        /// <param name="item">The object to serialize.</param>
        /// <returns></returns>
        internal static string SerializeDataFactoryToJson(DataFactory item)
        {
            var createParams = new DataFactoryCreateOrUpdateParameters()
            {
                DataFactory = item
            };

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

            client.DataFactories.BeginCreateOrUpdate(resourceGroupName, createParams);
            return(handler.Json);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deserializes the given json into an Hydra OM <see cref="DataFactory" /> instance, by mocking a get request to
        /// exercise the client's deserialization logic.
        /// </summary>
        /// <param name="json">The JSON string to deserialize.</param>
        /// <returns></returns>
        internal static DataFactory DeserializeDataFactoryJson(string json)
        {
            var handler = new MockResourceProviderDelegatingHandler()
            {
                Json = json
            };

            var    client                      = GetFakeClient(handler);
            string resourceGroupName           = Guid.NewGuid().ToString("D");
            string dataFactoryName             = Guid.NewGuid().ToString("D");
            DataFactoryGetResponse getResponse = client.DataFactories.Get(resourceGroupName, dataFactoryName);

            return(getResponse.DataFactory);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Serializes the given Pipeline into JSON, by mocking a create request to
        /// exercise the client's serialization logic.
        /// </summary>
        /// <param name="item">The object to serialize.</param>
        /// <returns></returns>
        internal static string SerializeInternalPipelineToJson(Models.Pipeline item)
        {
            var createParams = new Models.PipelineCreateOrUpdateParameters()
            {
                Pipeline = item
            };

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

            client.Pipelines.BeginCreateOrUpdate(resourceGroupName, dataFactoryName, createParams);
            return(handler.Json);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Deserializes the given json into an Hydra OM Gateway instance, by mocking a get request to
        /// exercise the client's deserialization logic.
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public static Gateway DeserializeGatewayJson(string json)
        {
            var handler = new MockResourceProviderDelegatingHandler()
            {
                Json = json
            };

            var                client            = DataPipelineManagementClient.GetFakeClient(handler);
            string             resourceGroupName = Guid.NewGuid().ToString("D");
            string             dataFactoryName   = Guid.NewGuid().ToString("D");
            string             gatewayName       = Guid.NewGuid().ToString("D");
            GatewayGetResponse getResponse       = client.Gateways.Get(resourceGroupName, dataFactoryName, gatewayName);

            return(getResponse.Gateway);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Deserializes the given json into an Hydra OM Table instance, by mocking a get request to
        /// exercise the client's deserialization logic.
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public static Table DeserializeTableJson(string json)
        {
            var handler = new MockResourceProviderDelegatingHandler()
            {
                Json = json
            };

            var              client            = DataPipelineManagementClient.GetFakeClient(handler);
            string           resourceGroupName = Guid.NewGuid().ToString("D");
            string           dataFactoryName   = Guid.NewGuid().ToString("D");
            string           tableName         = Guid.NewGuid().ToString("D");
            TableGetResponse getResponse       = client.Tables.Get(resourceGroupName, dataFactoryName, tableName);

            return(getResponse.Table);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Serializes the given GatewayDefinition into JSON, by mocking a create request to
        /// exercise the client's serialization logic.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static string SerializeGatewayToJson(Gateway item)
        {
            var createParams = new GatewayCreateOrUpdateParameters()
            {
                Gateway = item
            };

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

            client.Gateways.BeginCreateOrUpdate(resourceGroupName, dataFactoryName, createParams);
            return(handler.Json);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Serializes the given <see cref="Registration.Models.ComputeType" /> into JSON, by mocking a create request to
        /// exercise the client's serialization logic.
        /// </summary>
        /// <param name="item">The object to serialize.</param>
        /// <returns></returns>
        internal static string SerializeInternalComputeTypeToJson(Registration.Models.ComputeType item)
        {
            var createParams = new Registration.Models.ComputeTypeCreateOrUpdateParameters()
            {
                ComputeType = item
            };

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

            client.ComputeTypes.CreateOrUpdate(resourceGroupName, dataFactoryName, createParams);
            return(handler.Json);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Deserializes the given json into an Hydra OM Pipeline instance, by mocking a get request to
        /// exercise the client's deserialization logic.
        /// </summary>
        /// <param name="json">The JSON string to deserialize.</param>
        /// <returns></returns>
        internal static Models.Pipeline DeserializeInternalPipelineJson(string json)
        {
            var handler = new MockResourceProviderDelegatingHandler()
            {
                Json = json
            };

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

            Models.PipelineGetResponse getResponse = client.Pipelines.Get(resourceGroupName, dataFactoryName, pipelineName);
            return(getResponse.Pipeline);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Deserializes the given json into an Hydra OM ActivityWindow instance, by mocking a get request to
        /// exercise the client's deserialization logic.
        /// </summary>
        /// <param name="json">The JSON string to deserialize.</param>
        /// <returns></returns>
        internal static ActivityWindowListResponse DeserializeActivityWindow(string json)
        {
            var handler = new MockResourceProviderDelegatingHandler()
            {
                Json = json
            };

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

            ActivityWindowListResponse listResponse = client.ActivityWindows.ListByDataFactory(listParameters);

            return(listResponse);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Deserializes the given json into an Hydra OM InternalComputeType instance, by mocking a get request to
        /// exercise the client's deserialization logic.
        /// </summary>
        /// <param name="json">The JSON string to deserialize.</param>
        /// <returns></returns>
        internal static CoreRegistrationModel.ComputeType DeserializeInternalComputeTypeJson(string json)
        {
            var handler = new MockResourceProviderDelegatingHandler()
            {
                Json = json
            };

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

            CoreRegistrationModel.ComputeTypeGetParameters getParameters = new CoreRegistrationModel.ComputeTypeGetParameters(
                CoreRegistrationModel.RegistrationScope.DataFactory,
                Guid.NewGuid().ToString("D"));

            CoreRegistrationModel.ComputeTypeGetResponse getResponse = client.ComputeTypes.Get(
                resourceGroupName,
                dataFactoryName,
                getParameters);

            return(getResponse.ComputeType);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Returns the url that the Hydra client would use to execute the given RP operation (doesn't actually
        /// call the RP.)
        /// </summary>
        /// <param name="operation"></param>
        /// <returns></returns>
        public string GetRequestUri(Action <DataPipelineManagementClient> operation)
        {
            string uri     = null;
            var    handler = new MockResourceProviderDelegatingHandler();

            handler.OnRequestAction = (request) =>
            {
                uri = request.RequestUri.OriginalString;
                throw new NotSupportedException();     // abort after capturing the URI
            };

            var fakeClient = this.WithHandler(handler);

            try
            {
                operation(fakeClient);
            }
            catch (NotSupportedException)
            {
                // Swallow the exception
            }
            return(uri);
        }
        /// <summary>
        /// Deserializes the given json into an Hydra OM InternalComputeType instance, by mocking a get request to 
        /// exercise the client's deserialization logic.
        /// </summary>
        /// <param name="json">The JSON string to deserialize.</param>
        /// <returns></returns>
        internal static CoreRegistrationModel.ComputeType DeserializeInternalComputeTypeJson(string json)
        {
            var handler = new MockResourceProviderDelegatingHandler() { Json = json };

            var client = GetFakeClient(handler);
            string resourceGroupName = Guid.NewGuid().ToString("D");
            string dataFactoryName = Guid.NewGuid().ToString("D");
            CoreRegistrationModel.ComputeTypeGetParameters getParameters = new CoreRegistrationModel.ComputeTypeGetParameters(
                CoreRegistrationModel.RegistrationScope.DataFactory,
                Guid.NewGuid().ToString("D"));

            CoreRegistrationModel.ComputeTypeGetResponse getResponse = client.ComputeTypes.Get(
                resourceGroupName,
                dataFactoryName,
                getParameters);

            return getResponse.ComputeType;
        }
        /// <summary>
        /// Deserializes the given json into an Hydra OM <see cref="DataFactory" /> instance, by mocking a get request to 
        /// exercise the client's deserialization logic.
        /// </summary>
        /// <param name="json">The JSON string to deserialize.</param>
        /// <returns></returns>
        internal static DataFactory DeserializeDataFactoryJson(string json)
        {
            var handler = new MockResourceProviderDelegatingHandler() { Json = json };

            var client = GetFakeClient(handler);
            string resourceGroupName = Guid.NewGuid().ToString("D");
            string dataFactoryName = Guid.NewGuid().ToString("D");
            DataFactoryGetResponse getResponse = client.DataFactories.Get(resourceGroupName, dataFactoryName);
            return getResponse.DataFactory;
        }
        /// <summary>
        /// Deserializes the given json into an Hydra OM Pipeline instance, by mocking a get request to 
        /// exercise the client's deserialization logic.
        /// </summary>
        /// <param name="json">The JSON string to deserialize.</param>
        /// <returns></returns>
        internal static Models.Pipeline DeserializeInternalPipelineJson(string json)
        {
            var handler = new MockResourceProviderDelegatingHandler() { Json = json };

            var client = GetFakeClient(handler);
            string resourceGroupName = Guid.NewGuid().ToString("D");
            string dataFactoryName = Guid.NewGuid().ToString("D");
            string pipelineName = Guid.NewGuid().ToString("D");
            Models.PipelineGetResponse getResponse = client.Pipelines.Get(resourceGroupName, dataFactoryName, pipelineName);
            return getResponse.Pipeline;
        }
        /// <summary>
        /// Serializes the given <see cref="Registration.Models.ComputeType" /> into JSON, by mocking a create request to 
        /// exercise the client's serialization logic.
        /// </summary>
        /// <param name="item">The object to serialize.</param>
        /// <returns></returns>
        internal static string SerializeInternalComputeTypeToJson(Registration.Models.ComputeType item)
        {
            var createParams = new Registration.Models.ComputeTypeCreateOrUpdateParameters() { ComputeType = item };

            var handler = new MockResourceProviderDelegatingHandler();
            var client = GetFakeClient(handler);
            string resourceGroupName = Guid.NewGuid().ToString("D");
            string dataFactoryName = Guid.NewGuid().ToString("D");
            client.ComputeTypes.CreateOrUpdate(resourceGroupName, dataFactoryName, createParams);
            return handler.Json;
        }
        /// <summary>
        /// Serializes the given <see cref="DataFactory" /> into JSON, by mocking a create request to 
        /// exercise the client's serialization logic.
        /// </summary>
        /// <param name="item">The object to serialize.</param>
        /// <returns></returns>
        internal static string SerializeDataFactoryToJson(DataFactory item)
        {
            var createParams = new DataFactoryCreateOrUpdateParameters() { DataFactory = item };

            var handler = new MockResourceProviderDelegatingHandler();
            var client = GetFakeClient(handler);
            string resourceGroupName = Guid.NewGuid().ToString("D");
            client.DataFactories.BeginCreateOrUpdate(resourceGroupName, createParams);
            return handler.Json;
        }
        /// <summary>
        /// Serializes the given Pipeline into JSON, by mocking a create request to 
        /// exercise the client's serialization logic.
        /// </summary>
        /// <param name="item">The object to serialize.</param>
        /// <returns></returns>
        internal static string SerializeInternalPipelineToJson(Models.Pipeline item)
        {
            var createParams = new Models.PipelineCreateOrUpdateParameters() { Pipeline = item };

            var handler = new MockResourceProviderDelegatingHandler();
            var client = GetFakeClient(handler);
            string resourceGroupName = Guid.NewGuid().ToString("D");
            string dataFactoryName = Guid.NewGuid().ToString("D");
            client.Pipelines.BeginCreateOrUpdate(resourceGroupName, dataFactoryName, createParams);
            return handler.Json;
        }
        /// <summary>
        /// Returns the url that the Hydra client would use to execute the given RP operation (doesn't actually 
        /// call the RP.)
        /// </summary>
        /// <param name="operation"></param>
        /// <returns></returns>
        public string GetRequestUri(Action<DataFactoryManagementClient> operation)
        {
            string uri = null;
            var handler = new MockResourceProviderDelegatingHandler();
            handler.OnRequestAction = (request) =>
            {
                uri = request.RequestUri.OriginalString;
                throw new NotSupportedException(); // abort after capturing the URI
            };

            var fakeClient = this.WithHandler(handler);

            try
            {
                operation(fakeClient);
            }
            catch (NotSupportedException)
            {
                // Swallow the exception
            }

            return uri;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Deserializes the given json into an Hydra OM ActivityWindow instance, by mocking a get request to 
        /// exercise the client's deserialization logic.
        /// </summary>
        /// <param name="json">The JSON string to deserialize.</param>
        /// <returns></returns>
        internal static ActivityWindowListResponse DeserializeActivityWindow(string json)
        {
            var handler = new MockResourceProviderDelegatingHandler() { Json = json };

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

            ActivityWindowListResponse listResponse = client.ActivityWindows.ListByDataFactory(listParameters);

            return listResponse;
        }