public void TestDedupeSegments()
        {
            var audioRecording = AudioRecordingFactory.Create();

            var segments = new RemoteSegmentWithData[]
            {
                new RemoteSegmentWithData(audioRecording, new Range <double>(0, 60), 1.AsArray < object > ()),
                new RemoteSegmentWithData(audioRecording, new Range <double>(0, 60), 2.AsArray < object > ()),
                new RemoteSegmentWithData(audioRecording, new Range <double>(33, 93), 3.AsArray < object > ()),
                new RemoteSegmentWithData(audioRecording, new Range <double>(100.375, 160.375), 4.AsArray < object > ()),
                new RemoteSegmentWithData(audioRecording, new Range <double>(100.375, 160.375), 5.AsArray < object > ()),
                new RemoteSegmentWithData(audioRecording, new Range <double>(900, 960), 6.AsArray < object > ()),
                new RemoteSegmentWithData(audioRecording, new Range <double>(0, 60), 7.AsArray < object > ()),
            };

            var actual = EventMetadataResolver.DedupeSegments(segments);

            var expected = new RemoteSegmentWithData[]
            {
                new RemoteSegmentWithData(audioRecording, new Range <double>(0, 60), new object[] { 1, 2, 7 }),
                new RemoteSegmentWithData(audioRecording, new Range <double>(33, 93), 3.AsArray < object > ()),
                new RemoteSegmentWithData(audioRecording, new Range <double>(100.375, 160.375), new object[] { 4, 5 }),
                new RemoteSegmentWithData(audioRecording, new Range <double>(900, 960), 6.AsArray < object > ()),
            };

            Assert.AreEqual(expected.Length, actual.Length);
            foreach (var(expectedItem, actualItem) in expected.Zip(actual, ValueTuple.Create))
            {
                Assert.AreEqual(expectedItem.Source, actualItem.Source);
                Assert.AreEqual(expectedItem.Offsets, actualItem.Offsets);
                CollectionAssert.AreEqual(expectedItem.Data.ToArray(), actualItem.Data.ToArray());
            }
        }
Exemplo n.º 2
0
        public void Initialize()
        {
            this.authenticatedApi = AuthenticatedApi.Merge(Api.Default, "dummy", "dummyToken");
            this.preparer         = new RemoteSourcePreparer(this.authenticatedApi);
            this.settings         = new AnalysisSettings();

            this.audioRecording = AudioRecordingFactory.Create();
            this.audioRecording.DurationSeconds = 240.113;
        }
        public void TestInitialize()
        {
            this.recordingA = AudioRecordingFactory.Create(123);
            this.recordingB = AudioRecordingFactory.Create(123);
            this.recordingC = AudioRecordingFactory.Create(321);
            var offsets = 0.0.To(60);

            this.actualA = new RemoteSegment(this.recordingA, offsets);
            this.actualB = new RemoteSegment(this.recordingB, offsets);
            this.actualC = new RemoteSegment(this.recordingC, offsets);
            this.actualD = new RemoteSegment(this.recordingC, 60.0.To(120.0));
        }
        public void RemoteSegmentTestNoOffsetsProvided()
        {
            var recording = AudioRecordingFactory.Create();

            var actual = new RemoteSegment(recording);

            Assert.AreEqual(recording, actual.Source);
            Assert.AreEqual(0.0.To(recording.DurationSeconds), actual.Offsets);
            Assert.AreEqual(0.0, actual.StartOffsetSeconds);
            Assert.AreEqual(recording.DurationSeconds, actual.EndOffsetSeconds);
            Assert.AreEqual(recording.DurationSeconds, actual.SourceMetadata.Duration.TotalSeconds);
            Assert.AreEqual(recording.SampleRateHertz, actual.SourceMetadata.SampleRate);
            Assert.AreEqual(recording.Uuid, actual.SourceMetadata.Identifier);
            Assert.AreEqual(recording.RecordedDate, actual.SourceMetadata.RecordedDate);
        }