Example #1
0
        public IActionResult ExportAsCSV([FromBody] ElasticSearchRequest request)
        {
            IEnumerable <ScrapedComment> history = CommentScraper.All(request.Query, request.Sort).Data;

            byte[] serialized = CsvSerialization.Serialize(history, CsvSerialization.MapComment);
            return(File(serialized, "text/csv", "export.csv"));
        }
        public IActionResult ExportPagesAsCSV([FromBody] ElasticSearchRequest request)
        {
            IEnumerable <PageScrapeHistory> history = PageScrapeHistoryRepository.All(request.Query, request.Sort).Data;

            byte[] serialized = CsvSerialization.Serialize(history, CsvSerialization.MapPageScrape);
            return(File(serialized, "text/csv", "export.csv"));
        }
        static void LoadData(string data, Dictionary <string, string[]> storage)
        {
            CsvSerialization.DeserializeStatic(data, storage);
            if (!storage.ContainsKey(HeaderToken))
            {
                storage.Clear();
                return;
            }

            foreach (var item in storage)
            {
                for (int i = 0, iMax = item.Value.Length; i < iMax; i++)
                {
                    item.Value[i] = item.Value[i].Replace("\\n", "\n");
                }
            }

            _header = storage[HeaderToken];
            if (!string.IsNullOrEmpty(_language))
            {
                var langID = Array.IndexOf(_header, _language);
                if (_langID != -1 && langID != _langID)
                {
#if UNITY_EDITOR
                    Debug.LogWarning("Invalid languages order in source, skipping.");
#endif
                    return;
                }
                if (_langID == -1)
                {
                    _langID = langID;
                }
            }
        }
Example #4
0
 static void Main(string[] args)
 {
     //var test = new TestClass[2];
     //var aaa = new TestGroup() { Name = "awd", Count = 2, Date = DateTime.Now };
     //test[0] = new TestClass() { Name = "awawd", Count = 1, Date = DateTime.Now, Group = aaa };
     //test[1] = test[0];
     var serialise = new CsvSerialization <TestClass>();
     var objs      = serialise.Deserializr("test.csv").ToList();
     //serialise.Serialize("test.csv", test);
 }
        public void Test_InputOperations_IoTHub()
        {
            BasicDelegatingHandler handler = new BasicDelegatingHandler();

            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();

                string resourceGroupName = TestUtilities.GenerateName("StreamAnalytics");
                string resourceName      = TestUtilities.GenerateName("MyStreamingJobSubmittedBySDK");

                string serviceLocation = TestHelper.GetDefaultLocation();

                var resourceClient = TestHelper.GetResourceClient(handler);
                var client         = TestHelper.GetStreamAnalyticsManagementClient(handler);

                try
                {
                    ResourceGroup resourceGroup = new ResourceGroup()
                    {
                        Location = serviceLocation
                    };
                    resourceClient.ResourceGroups.CreateOrUpdate(resourceGroupName, resourceGroup);

                    // Construct the JobCreateProperties
                    JobCreateOrUpdateParameters jobCreateOrUpdateParameters =
                        new JobCreateOrUpdateParameters(TestHelper.GetDefaultJob(resourceName, serviceLocation));

                    // Create a streaming job
                    JobCreateOrUpdateResponse jobCreateOrUpdateResponse = client.StreamingJobs.CreateOrUpdate(resourceGroupName, jobCreateOrUpdateParameters);
                    Assert.Equal(HttpStatusCode.OK, jobCreateOrUpdateResponse.StatusCode);

                    // Get a streaming job to check
                    JobGetParameters jobGetParameters = new JobGetParameters(string.Empty);
                    JobGetResponse   jobGetResponse   = client.StreamingJobs.Get(resourceGroupName, resourceName, jobGetParameters);
                    Assert.Equal(HttpStatusCode.OK, jobGetResponse.StatusCode);
                    Assert.Equal(serviceLocation, jobGetResponse.Job.Location);
                    Assert.Equal(resourceName, jobGetResponse.Job.Name);

                    // Construct the Input
                    string          sharedAccessPolicyName = "owner";
                    InputProperties inputProperties        = new StreamInputProperties()
                    {
                        Serialization = new CsvSerialization()
                        {
                            Properties = new CsvSerializationProperties()
                            {
                                FieldDelimiter = ",",
                                Encoding       = "UTF8"
                            }
                        },
                        DataSource = new IoTHubStreamInputDataSource()
                        {
                            Properties = new IoTHubStreamInputDataSourceProperties()
                            {
                                IotHubNamespace        = TestHelper.IoTHubNamespace,
                                SharedAccessPolicyName = sharedAccessPolicyName,
                                SharedAccessPolicyKey  = TestHelper.IotHubSharedAccessPolicyKey
                            }
                        }
                    };
                    string inputName = TestUtilities.GenerateName("inputtest");
                    Input  input1    = new Input(inputName)
                    {
                        Properties = inputProperties
                    };

                    // Add an input
                    InputCreateOrUpdateParameters inputCreateOrUpdateParameters = new InputCreateOrUpdateParameters();
                    inputCreateOrUpdateParameters.Input = input1;
                    InputCreateOrUpdateResponse inputCreateOrUpdateResponse = client.Inputs.CreateOrUpdate(resourceGroupName, resourceName, inputCreateOrUpdateParameters);
                    Assert.Equal(HttpStatusCode.OK, inputCreateOrUpdateResponse.StatusCode);
                    Assert.Equal(inputName, inputCreateOrUpdateResponse.Input.Name);
                    Assert.Equal("Stream", inputCreateOrUpdateResponse.Input.Properties.Type);
                    Assert.True(inputCreateOrUpdateResponse.Input.Properties.Serialization is CsvSerialization);
                    CsvSerialization csvSerializationInResponse1 = (CsvSerialization)inputCreateOrUpdateResponse.Input.Properties.Serialization;
                    Assert.Equal(",", csvSerializationInResponse1.Properties.FieldDelimiter);
                    Assert.True(inputCreateOrUpdateResponse.Input.Properties is StreamInputProperties);
                    StreamInputProperties streamInputPropertiesInResponse = (StreamInputProperties)inputCreateOrUpdateResponse.Input.Properties;
                    Assert.True(streamInputPropertiesInResponse.DataSource is IoTHubStreamInputDataSource);
                    IoTHubStreamInputDataSource iotHubInputDataSourceInResponse1 = (IoTHubStreamInputDataSource)streamInputPropertiesInResponse.DataSource;
                    Assert.Equal(sharedAccessPolicyName, iotHubInputDataSourceInResponse1.Properties.SharedAccessPolicyName);
                    Assert.NotNull(streamInputPropertiesInResponse.Etag);

                    // Get the input
                    InputGetResponse inputGetResponse = client.Inputs.Get(resourceGroupName, resourceName, inputName);
                    Assert.Equal(HttpStatusCode.OK, inputGetResponse.StatusCode);
                    Assert.Equal(inputName, inputGetResponse.Input.Name);
                    Assert.True(inputGetResponse.Input.Properties is StreamInputProperties);
                    StreamInputProperties streamInputPropertiesInResponse2 = (StreamInputProperties)inputGetResponse.Input.Properties;
                    Assert.True(streamInputPropertiesInResponse2.DataSource is IoTHubStreamInputDataSource);
                    IoTHubStreamInputDataSource iotHubInputDataSourceInResponse2 = (IoTHubStreamInputDataSource)streamInputPropertiesInResponse2.DataSource;
                    Assert.Equal(sharedAccessPolicyName, iotHubInputDataSourceInResponse2.Properties.SharedAccessPolicyName);
                    Assert.Equal(inputCreateOrUpdateResponse.Input.Properties.Etag, inputGetResponse.Input.Properties.Etag);

                    // Test input connectivity
                    ResourceTestConnectionResponse response = client.Inputs.TestConnection(resourceGroupName, resourceName, inputName);
                    Assert.Equal(OperationStatus.Succeeded, response.Status);
                    Assert.Equal(ResourceTestStatus.TestSucceeded, response.ResourceTestStatus);

                    // Update the input
                    string newSharedPolicyName = TestUtilities.GenerateName("owner");
                    inputProperties = new StreamInputProperties()
                    {
                        Serialization = new CsvSerialization()
                        {
                            Properties = new CsvSerializationProperties()
                            {
                                FieldDelimiter = "|",
                                Encoding       = "UTF8"
                            }
                        },
                        DataSource = new IoTHubStreamInputDataSource()
                        {
                            Properties = new IoTHubStreamInputDataSourceProperties()
                            {
                                IotHubNamespace        = TestHelper.IoTHubNamespace,
                                SharedAccessPolicyName = newSharedPolicyName,
                                SharedAccessPolicyKey  = TestHelper.IotHubSharedAccessPolicyKey
                            }
                        }
                    };
                    inputProperties.Etag = inputCreateOrUpdateResponse.Input.Properties.Etag;
                    InputPatchParameters inputPatchParameters = new InputPatchParameters(inputProperties);
                    InputPatchResponse   inputPatchResponse   = client.Inputs.Patch(resourceGroupName, resourceName, inputName, inputPatchParameters);
                    Assert.Equal(HttpStatusCode.OK, inputPatchResponse.StatusCode);
                    Assert.True(inputPatchResponse.Properties.Serialization is CsvSerialization);
                    CsvSerialization csvSerializationInResponse2 = (CsvSerialization)inputPatchResponse.Properties.Serialization;
                    Assert.Equal("|", csvSerializationInResponse2.Properties.FieldDelimiter);
                    Assert.True(inputPatchResponse.Properties is StreamInputProperties);
                    StreamInputProperties streamInputPropertiesInResponse3 = (StreamInputProperties)inputPatchResponse.Properties;
                    Assert.True(streamInputPropertiesInResponse3.DataSource is IoTHubStreamInputDataSource);
                    IoTHubStreamInputDataSource iotHubInputDataSourceInResponse3 = (IoTHubStreamInputDataSource)streamInputPropertiesInResponse3.DataSource;
                    Assert.Equal(newSharedPolicyName, iotHubInputDataSourceInResponse3.Properties.SharedAccessPolicyName);
                    Assert.NotNull(inputPatchResponse.Properties.Etag);
                    Assert.NotEqual(streamInputPropertiesInResponse.Etag, inputPatchResponse.Properties.Etag);

                    // Delete the input
                    AzureOperationResponse deleteInputOperationResponse = client.Inputs.Delete(resourceGroupName, resourceName, inputName);
                    Assert.Equal(HttpStatusCode.OK, deleteInputOperationResponse.StatusCode);

                    // Check that there are 0 inputs in the job
                    jobGetParameters = new JobGetParameters("inputs");
                    jobGetResponse   = client.StreamingJobs.Get(resourceGroupName, resourceName, jobGetParameters);
                    Assert.Equal(HttpStatusCode.OK, jobGetResponse.StatusCode);
                    Assert.Equal(0, jobGetResponse.Job.Properties.Inputs.Count);
                }
                finally
                {
                    client.StreamingJobs.Delete(resourceGroupName, resourceName);
                    resourceClient.ResourceGroups.Delete(resourceGroupName);
                }
            }
        }
        public void Test_InputOperations_E2E()
        {
            BasicDelegatingHandler handler = new BasicDelegatingHandler();

            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();

                string resourceGroupName = TestUtilities.GenerateName("StreamAnalytics");
                string resourceName      = TestUtilities.GenerateName("MyStreamingJobSubmittedBySDK");

                string serviceLocation = TestHelper.GetDefaultLocation();

                var resourceClient = TestHelper.GetResourceClient(handler);
                var client         = TestHelper.GetStreamAnalyticsManagementClient(handler);

                try
                {
                    ResourceGroup resourceGroup = new ResourceGroup()
                    {
                        Location = serviceLocation
                    };
                    resourceClient.ResourceGroups.CreateOrUpdate(resourceGroupName, resourceGroup);

                    // Construct the JobCreateProperties
                    JobCreateOrUpdateParameters jobCreateOrUpdateParameters =
                        new JobCreateOrUpdateParameters(TestHelper.GetDefaultJob(resourceName, serviceLocation));

                    // Create a streaming job
                    JobCreateOrUpdateResponse jobCreateOrUpdateResponse = client.StreamingJobs.CreateOrUpdate(resourceGroupName, jobCreateOrUpdateParameters);
                    Assert.Equal(HttpStatusCode.OK, jobCreateOrUpdateResponse.StatusCode);

                    // Get a streaming job to check
                    JobGetParameters jobGetParameters = new JobGetParameters(string.Empty);
                    JobGetResponse   jobGetResponse   = client.StreamingJobs.Get(resourceGroupName, resourceName, jobGetParameters);
                    Assert.Equal(HttpStatusCode.OK, jobGetResponse.StatusCode);
                    Assert.Equal(serviceLocation, jobGetResponse.Job.Location);
                    Assert.Equal(resourceName, jobGetResponse.Job.Name);

                    // Construct the Input
                    StorageAccount storageAccount = new StorageAccount();
                    storageAccount.AccountName = TestHelper.AccountName;
                    storageAccount.AccountKey  = TestHelper.AccountKey;
                    InputProperties inputProperties = new StreamInputProperties()
                    {
                        Serialization = new CsvSerialization()
                        {
                            Properties = new CsvSerializationProperties()
                            {
                                FieldDelimiter = ",",
                                Encoding       = "UTF8"
                            }
                        },
                        DataSource = new BlobStreamInputDataSource()
                        {
                            Properties = new BlobStreamInputDataSourceProperties()
                            {
                                StorageAccounts = new[] { storageAccount },
                                Container       = "state",
                                PathPattern     = ""
                            }
                        }
                    };
                    string inputName = TestUtilities.GenerateName("inputtest");
                    Input  input1    = new Input(inputName)
                    {
                        Properties = inputProperties
                    };

                    // Add an input
                    InputCreateOrUpdateParameters inputCreateOrUpdateParameters = new InputCreateOrUpdateParameters();
                    inputCreateOrUpdateParameters.Input = input1;
                    InputCreateOrUpdateResponse inputCreateOrUpdateResponse = client.Inputs.CreateOrUpdate(resourceGroupName, resourceName, inputCreateOrUpdateParameters);
                    Assert.Equal(HttpStatusCode.OK, inputCreateOrUpdateResponse.StatusCode);
                    Assert.Equal(inputName, inputCreateOrUpdateResponse.Input.Name);
                    Assert.Equal("Stream", inputCreateOrUpdateResponse.Input.Properties.Type);
                    Assert.True(inputCreateOrUpdateResponse.Input.Properties.Serialization is CsvSerialization);
                    CsvSerialization csvSerializationInResponse1 = (CsvSerialization)inputCreateOrUpdateResponse.Input.Properties.Serialization;
                    Assert.Equal(",", csvSerializationInResponse1.Properties.FieldDelimiter);
                    Assert.NotNull(inputCreateOrUpdateResponse.Input.Properties.Etag);

                    // Get the input
                    InputGetResponse inputGetResponse = client.Inputs.Get(resourceGroupName, resourceName, inputName);
                    Assert.Equal(HttpStatusCode.OK, inputGetResponse.StatusCode);
                    Assert.Equal(inputName, inputGetResponse.Input.Name);
                    Assert.True(inputGetResponse.Input.Properties.Serialization is CsvSerialization);
                    CsvSerialization csvSerializationInResponse2 = (CsvSerialization)inputGetResponse.Input.Properties.Serialization;
                    Assert.Equal(",", csvSerializationInResponse2.Properties.FieldDelimiter);
                    Assert.Equal(inputCreateOrUpdateResponse.Input.Properties.Etag, inputGetResponse.Input.Properties.Etag);

                    // List inputs
                    InputListResponse inputListResponse = client.Inputs.ListInputInJob(resourceGroupName, resourceName, new InputListParameters());
                    Assert.Equal(HttpStatusCode.OK, inputListResponse.StatusCode);
                    Assert.Equal(1, inputListResponse.Value.Count);

                    // Check that there is 1 input in the job
                    jobGetParameters = new JobGetParameters("inputs");
                    jobGetResponse   = client.StreamingJobs.Get(resourceGroupName, resourceName, jobGetParameters);
                    Assert.Equal(HttpStatusCode.OK, jobGetResponse.StatusCode);
                    Assert.Equal(1, jobGetResponse.Job.Properties.Inputs.Count);

                    // Test input connectivity
                    ResourceTestConnectionResponse response = client.Inputs.TestConnection(resourceGroupName, resourceName, inputName);
                    Assert.Equal(OperationStatus.Succeeded, response.Status);
                    Assert.Equal(ResourceTestStatus.TestSucceeded, response.ResourceTestStatus);

                    // Update the input
                    Serialization csvSerialization = new CsvSerialization()
                    {
                        Properties = new CsvSerializationProperties()
                        {
                            FieldDelimiter = "|",
                            Encoding       = "UTF8"
                        }
                    };
                    inputProperties.Serialization = csvSerialization;
                    inputProperties.Etag          = inputCreateOrUpdateResponse.Input.Properties.Etag;
                    InputPatchParameters inputPatchParameters = new InputPatchParameters(inputProperties);
                    InputPatchResponse   inputPatchResponse   = client.Inputs.Patch(resourceGroupName, resourceName, inputName, inputPatchParameters);
                    Assert.Equal(HttpStatusCode.OK, inputPatchResponse.StatusCode);
                    Assert.True(inputPatchResponse.Properties.Serialization is CsvSerialization);
                    CsvSerialization csvSerializationInResponse3 = (CsvSerialization)inputPatchResponse.Properties.Serialization;
                    Assert.Equal("|", csvSerializationInResponse3.Properties.FieldDelimiter);
                    Assert.NotNull(inputPatchResponse.Properties.Etag);
                    Assert.NotEqual(inputCreateOrUpdateResponse.Input.Properties.Etag, inputPatchResponse.Properties.Etag);

                    // Add second input
                    string inputName2 = TestUtilities.GenerateName("inputtest");
                    Input  input2     = new Input(inputName2)
                    {
                        Properties = inputProperties
                    };
                    inputCreateOrUpdateParameters.Input = input2;
                    inputCreateOrUpdateResponse         = client.Inputs.CreateOrUpdate(resourceGroupName, resourceName, inputCreateOrUpdateParameters);

                    // List inputs
                    inputListResponse = client.Inputs.ListInputInJob(resourceGroupName, resourceName, new InputListParameters());
                    Assert.Equal(HttpStatusCode.OK, inputListResponse.StatusCode);
                    Assert.Equal(2, inputListResponse.Value.Count);

                    // Check that there are 2 inputs in the job
                    jobGetParameters = new JobGetParameters("inputs");
                    jobGetResponse   = client.StreamingJobs.Get(resourceGroupName, resourceName, jobGetParameters);
                    Assert.Equal(HttpStatusCode.OK, jobGetResponse.StatusCode);
                    Assert.Equal(2, jobGetResponse.Job.Properties.Inputs.Count);

                    // Delete the inputs
                    AzureOperationResponse deleteInputOperationResponse = client.Inputs.Delete(resourceGroupName, resourceName, inputName);
                    Assert.Equal(HttpStatusCode.OK, deleteInputOperationResponse.StatusCode);

                    deleteInputOperationResponse = client.Inputs.Delete(resourceGroupName, resourceName, inputName2);
                    Assert.Equal(HttpStatusCode.OK, deleteInputOperationResponse.StatusCode);

                    // Check that there are 0 inputs in the job
                    jobGetParameters = new JobGetParameters("inputs");
                    jobGetResponse   = client.StreamingJobs.Get(resourceGroupName, resourceName, jobGetParameters);
                    Assert.Equal(HttpStatusCode.OK, jobGetResponse.StatusCode);
                    Assert.Equal(0, jobGetResponse.Job.Properties.Inputs.Count);
                }
                finally
                {
                    client.StreamingJobs.Delete(resourceGroupName, resourceName);
                    resourceClient.ResourceGroups.Delete(resourceGroupName);
                }
            }
        }
        static string ConvertToArrayJson(string data)
        {
            var sb   = new StringBuilder(data.Length * 2);
            var list = new CsvSerialization().DeserializeAsArray(data);

            if (list.Count < 2)
            {
                throw new Exception("Invalid header data: first line should contains field names, second line - pair of wrapping chars.");
            }

            sb.Append("[");
            var it = list.GetEnumerator();

            // header.
            it.MoveNext();
            var headerValue = it.Current;

            // wrappers.
            it.MoveNext();
            var wrapperValue = it.Current;

            for (var i = 0; i < wrapperValue.Length; i++)
            {
                if (!(
                        wrapperValue[i] == string.Empty ||
                        wrapperValue[i] == "[]" ||
                        wrapperValue[i] == "{}" ||
                        string.Compare(wrapperValue[i], "IGNORE", true) == 0 ||
                        wrapperValue[i] == "\"\""))
                {
                    throw new Exception(string.Format("Invalid wrapper data for \"{0}\" field.", headerValue[i]));
                }
            }

            var    needObjectsComma = false;
            string itemValue;
            string wrapChars;

            while (it.MoveNext())
            {
                sb.AppendFormat("{0}{{", needObjectsComma ? "," : string.Empty);
                var needFieldsComma = false;
                for (var i = 0; i < headerValue.Length; i++)
                {
                    wrapChars = wrapperValue[i];
                    if (string.Compare(wrapChars, "IGNORE", true) == 0)
                    {
                        continue;
                    }
                    itemValue = wrapChars.Length > 0 ?
                                string.Format("{0}{1}{2}", wrapChars[0], it.Current[i], wrapChars[1]) : it.Current[i];
                    sb.AppendFormat("{0}\"{1}\":{2}", needFieldsComma ? "," : string.Empty, headerValue[i], itemValue);
                    needFieldsComma = true;
                }
                sb.Append("}");
                needObjectsComma = true;
            }

            sb.Append("]");
            return(sb.ToString());
        }
Example #8
0
        public void Test_InputOperations_EventHub()
        {
            BasicDelegatingHandler handler = new BasicDelegatingHandler();

            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();

                string resourceGroupName = TestUtilities.GenerateName("StreamAnalytics");
                string resourceName      = TestUtilities.GenerateName("MyStreamingJobSubmittedBySDK");

                string serviceLocation = TestHelper.GetDefaultLocation();

                var resourceClient = TestHelper.GetResourceClient(handler);
                var client         = TestHelper.GetStreamAnalyticsManagementClient(handler);

                try
                {
                    ResourceGroup resourceGroup = new ResourceGroup()
                    {
                        Location = serviceLocation
                    };
                    resourceClient.ResourceGroups.CreateOrUpdate(resourceGroupName, resourceGroup);

                    Job job = new Job();
                    job.Name     = resourceName;
                    job.Location = serviceLocation;

                    // Construct the general properties for JobProperties
                    JobProperties jobProperties = new JobProperties();
                    jobProperties.Sku = new Sku()
                    {
                        Name = "standard"
                    };
                    jobProperties.EventsOutOfOrderPolicy            = EventsOutOfOrderPolicy.Drop;
                    jobProperties.EventsOutOfOrderMaxDelayInSeconds = 0;

                    job.Properties = jobProperties;

                    // Construct the JobCreateProperties
                    JobCreateOrUpdateParameters jobCreateOrUpdateParameters = new JobCreateOrUpdateParameters();
                    jobCreateOrUpdateParameters.Job = job;

                    // Create a streaming job
                    JobCreateOrUpdateResponse jobCreateOrUpdateResponse = client.StreamingJobs.CreateOrUpdate(resourceGroupName, jobCreateOrUpdateParameters);
                    Assert.Equal(HttpStatusCode.OK, jobCreateOrUpdateResponse.StatusCode);

                    // Get a streaming job to check
                    JobGetParameters jobGetParameters = new JobGetParameters(string.Empty);
                    JobGetResponse   jobGetResponse   = client.StreamingJobs.Get(resourceGroupName, resourceName, jobGetParameters);
                    Assert.Equal(HttpStatusCode.OK, jobGetResponse.StatusCode);
                    Assert.Equal(serviceLocation, jobGetResponse.Job.Location);
                    Assert.Equal(resourceName, jobGetResponse.Job.Name);

                    // Construct the Input

                    InputProperties inputProperties = new StreamInputProperties()
                    {
                        Serialization = new CsvSerialization()
                        {
                            Properties = new CsvSerializationProperties()
                            {
                                FieldDelimiter = ",",
                                Encoding       = "UTF8"
                            }
                        },
                        DataSource = new EventHubStreamInputDataSource()
                        {
                            Properties = new EventHubStreamInputDataSourceProperties()
                            {
                                ServiceBusNamespace    = "sdktest",
                                EventHubName           = "sdkeventhub",
                                SharedAccessPolicyName = TestHelper.SharedAccessPolicyName,
                                SharedAccessPolicyKey  = TestHelper.SharedAccessPolicyKey,
                                ConsumerGroupName      = "sdkconsumergroup"
                            }
                        }
                    };
                    string inputName = TestUtilities.GenerateName("inputtest");
                    Input  input1    = new Input(inputName)
                    {
                        Properties = inputProperties
                    };

                    // Add an input
                    InputCreateOrUpdateParameters inputCreateOrUpdateParameters = new InputCreateOrUpdateParameters();
                    inputCreateOrUpdateParameters.Input = input1;
                    InputCreateOrUpdateResponse inputCreateOrUpdateResponse = client.Inputs.CreateOrUpdate(resourceGroupName, resourceName, inputCreateOrUpdateParameters);
                    Assert.Equal(HttpStatusCode.OK, inputCreateOrUpdateResponse.StatusCode);
                    Assert.Equal(inputName, inputCreateOrUpdateResponse.Input.Name);
                    Assert.Equal("Stream", inputCreateOrUpdateResponse.Input.Properties.Type);
                    Assert.True(inputCreateOrUpdateResponse.Input.Properties.Serialization is CsvSerialization);
                    CsvSerialization csvSerializationInResponse1 = (CsvSerialization)inputCreateOrUpdateResponse.Input.Properties.Serialization;
                    Assert.Equal(",", csvSerializationInResponse1.Properties.FieldDelimiter);
                    Assert.True(inputCreateOrUpdateResponse.Input.Properties is StreamInputProperties);
                    StreamInputProperties streamInputPropertiesInResponse = (StreamInputProperties)inputCreateOrUpdateResponse.Input.Properties;
                    Assert.True(streamInputPropertiesInResponse.DataSource is EventHubStreamInputDataSource);
                    EventHubStreamInputDataSource eventHubInputDataSourceInResponse1 = (EventHubStreamInputDataSource)streamInputPropertiesInResponse.DataSource;
                    Assert.Equal("sdktest", eventHubInputDataSourceInResponse1.Properties.ServiceBusNamespace);
                    Assert.NotNull(streamInputPropertiesInResponse.Etag);

                    // Test input connectivity
                    DataSourceTestConnectionResponse response = client.Inputs.TestConnection(resourceGroupName, resourceName, inputName);
                    Assert.Equal(OperationStatus.Succeeded, response.Status);
                    Assert.Equal(DataSourceTestStatus.TestSucceeded, response.DataSourceTestStatus);

                    // Update the input
                    Serialization csvSerialization = new CsvSerialization()
                    {
                        Properties = new CsvSerializationProperties()
                        {
                            FieldDelimiter = "|",
                            Encoding       = "UTF8"
                        }
                    };
                    inputProperties.Serialization = csvSerialization;
                    inputProperties.Etag          = inputCreateOrUpdateResponse.Input.Properties.Etag;
                    InputPatchParameters inputPatchParameters = new InputPatchParameters(inputProperties);
                    InputPatchResponse   inputPatchResponse   = client.Inputs.Patch(resourceGroupName, resourceName, inputName, inputPatchParameters);
                    Assert.Equal(HttpStatusCode.OK, inputPatchResponse.StatusCode);
                    Assert.True(inputPatchResponse.Properties.Serialization is CsvSerialization);
                    CsvSerialization csvSerializationInResponse2 = (CsvSerialization)inputPatchResponse.Properties.Serialization;
                    Assert.Equal("|", csvSerializationInResponse2.Properties.FieldDelimiter);
                    Assert.True(inputPatchResponse.Properties is StreamInputProperties);
                    StreamInputProperties streamInputPropertiesInResponse2 = (StreamInputProperties)inputPatchResponse.Properties;
                    Assert.True(streamInputPropertiesInResponse2.DataSource is EventHubStreamInputDataSource);
                    EventHubStreamInputDataSource eventHubInputDataSourceInResponse2 = (EventHubStreamInputDataSource)streamInputPropertiesInResponse2.DataSource;
                    Assert.Equal("sdktest", eventHubInputDataSourceInResponse2.Properties.ServiceBusNamespace);
                    Assert.NotNull(inputPatchResponse.Properties.Etag);
                    Assert.NotEqual(streamInputPropertiesInResponse.Etag, inputPatchResponse.Properties.Etag);

                    // Delete the input
                    AzureOperationResponse deleteInputOperationResponse = client.Inputs.Delete(resourceGroupName, resourceName, inputName);
                    Assert.Equal(HttpStatusCode.OK, deleteInputOperationResponse.StatusCode);

                    // Check that there are 0 inputs in the job
                    jobGetParameters = new JobGetParameters("inputs");
                    jobGetResponse   = client.StreamingJobs.Get(resourceGroupName, resourceName, jobGetParameters);
                    Assert.Equal(HttpStatusCode.OK, jobGetResponse.StatusCode);
                    Assert.Equal(0, jobGetResponse.Job.Properties.Inputs.Count);
                }
                finally
                {
                    client.StreamingJobs.Delete(resourceGroupName, resourceName);
                    resourceClient.ResourceGroups.Delete(resourceGroupName);
                }
            }
        }