Exemplo n.º 1
0
        private void buttonExtract_Click(object sender, EventArgs e)
        {
            var parameters = new ExtractionParameters
            {
                Center     = new Imaging.Point((int)numericUpDownCenterX.Value, (int)numericUpDownCenterY.Value),
                GapWidth   = (double)numericUpDownGapWidth.Value,
                TrackWidth = (double)numericUpDownTrackWidth.Value
            };

            byte[] audioBytes;

            try
            {
                if (checkBoxTrack.Checked)
                {
                    audioBytes            = Imaging.Vinyl.ExtractAudioBytes(_vinyl, parameters, Imaging.Vinyl.ExtractionOptions.SaveTrack);
                    pictureBoxPlate.Image = _vinyl.GetTrack();
                }
                else
                {
                    audioBytes = Imaging.Vinyl.ExtractAudioBytes(_vinyl, parameters, Imaging.Vinyl.ExtractionOptions.None);
                }
            }
            catch (IndexOutOfRangeException)
            {
                MessageBox.Show("Проверьте правильность всех параметров. Возможно, необходимо их слегка поправить.\n" +
                                "Так же стоит проверить корректность самого изображения.",
                                "Произошла ошибка при извлечении звука",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 2
0
        public async Task Query_SimpleExtraction_Success()
        {
            var queryParameters = new ExtractionParameters()
            {
                Timeframe = QueryRelativeTimeframe.ThisNHours(2),
            };

            string resultsJson = @"[
                {
                    ""keen"": {
                        ""created_at"": ""2012-07-30T21:21:46.566000+00:00"",
                        ""timestamp"": ""2012-07-30T21:21:46.566000+00:00"",
                        ""id"": """"
                    },
                    ""user"": {
                        ""email"": ""*****@*****.**"",
                        ""id"": ""4f4db6c7777d66ffff000000""
                    },
                    ""user_agent"": {
                        ""browser"": ""chrome"",
                        ""browser_version"": ""20.0.1132.57"",
                        ""platform"": ""macos""
                    }
                },
                {
                    ""keen"": {
                        ""created_at"": ""2012-07-30T21:40:05.386000+00:00"",
                        ""timestamp"": ""2012-07-30T21:40:05.386000+00:00"",
                        ""id"": """"
                    },
                    ""user"": {
                        ""email"": ""*****@*****.**"",
                        ""id"": ""4fa2cccccf546ffff000006""
                    },
                    ""user_agent"": {
                        ""browser"": ""chrome"",
                        ""browser_version"": ""20.0.1132.57"",
                        ""platform"": ""macos""
                    }
                }
            ]";

            var expectedResults = JArray.Parse(resultsJson);

            var expectedResponse = new
            {
                result = expectedResults
            };

            var client = CreateQueryTestKeenClient(queryParameters, expectedResponse);

            var actualResults = await client.Queries.Extract(
                queryParameters.EventCollection,
                queryParameters.Timeframe);

            Assert.That(actualResults, Is.EquivalentTo(expectedResults));
        }
        public async Task Query_SimpleExtraction_Success()
        {
            var queryParameters = new ExtractionParameters()
            {
                Timeframe = QueryRelativeTimeframe.ThisNHours(2),
            };

            string resultsJson = @"[
                {
                    ""keen"": {
                        ""created_at"": ""2012-07-30T21:21:46.566000+00:00"",
                        ""timestamp"": ""2012-07-30T21:21:46.566000+00:00"",
                        ""id"": """"
                    },
                    ""user"": {
                        ""email"": ""*****@*****.**"",
                        ""id"": ""4f4db6c7777d66ffff000000""
                    },
                    ""user_agent"": {
                        ""browser"": ""chrome"",
                        ""browser_version"": ""20.0.1132.57"",
                        ""platform"": ""macos""
                    }
                },
                {
                    ""keen"": {
                        ""created_at"": ""2012-07-30T21:40:05.386000+00:00"",
                        ""timestamp"": ""2012-07-30T21:40:05.386000+00:00"",
                        ""id"": """"
                    },
                    ""user"": {
                        ""email"": ""*****@*****.**"",
                        ""id"": ""4fa2cccccf546ffff000006""
                    },
                    ""user_agent"": {
                        ""browser"": ""chrome"",
                        ""browser_version"": ""20.0.1132.57"",
                        ""platform"": ""macos""
                    }
                }
            ]";

            var expectedResults = JArray.Parse(resultsJson);

            var expectedResponse = new
            {
                result = expectedResults
            };

            var client = CreateQueryTestKeenClient(queryParameters, expectedResponse);

            var actualResults = await client.Queries.Extract(
                queryParameters.EventCollection,
                queryParameters.Timeframe);

            Assert.AreEqual(expectedResults.Count(), actualResults.Count());
            var actualEnumerator = actualResults.GetEnumerator();

            foreach (var expected in expectedResults)
            {
                actualEnumerator.MoveNext();
                JToken actual = actualEnumerator.Current;
                // Validate the result is correct
                Assert.AreEqual(expected["user"]["email"].Value <string>(), actual["user"]["email"].Value <string>());
                Assert.AreEqual(expected["user"]["id"].Value <string>(), actual["user"]["id"].Value <string>());
                Assert.AreEqual(expected["user_agent"]["browser"].Value <string>(), actual["user_agent"]["browser"].Value <string>());
            }
        }