Example #1
0
        //***********************************************************************************************************************************************************************************************************

        /// <summary>
        /// Cleanup all recorders that are stopped. Leave the last recorder in the list.
        /// </summary>
        private void CleanupRecordersList()
        {
            List <Recorder> recordersCleanedup = Recorders.Where(r => r.RecordState != RecordStates.STOPPED || Recorders.IndexOf(r) == (Recorders.Count - 1)).ToList();

            Recorders.Clear();
            foreach (Recorder item in recordersCleanedup)
            {
                Recorders.Add(item);
            }
        }
Example #2
0
        public static void Main(string[] args)
        {
            try
            {
                var dbEngine   = "SQLite";
                var dataSource = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) +
                                 @"\McLaren Applied Technologies\ATLAS 10\SQL Race\LiveSessionCache.ssn2";
                var sqlConnString = $@"DbEngine={dbEngine};Data Source={dataSource};";

                Core.Initialize();
                var sessionManager = SessionManager.CreateSessionManager();
                sessionManager.SessionEventOccurred += SessionManager_SessionEventOccurred;

                Console.WriteLine("Initialising");

                recordingState = RecorderState.Idle;

                Recorders.Initialise(ServerListenerIpAddress, ServerListenerPortNumber);

                Console.WriteLine("Setting up Recorder Instance");

                recorder = Recorders.CreateDataServerTelemetryRecorder();
                recorder.SetSessionIdentifier("%y%m%d%H%M%S");
                recorder.OnStatusChanged += recorder_OnStatusChanged;
                recorder.SetSQLRaceConnection(Guid.NewGuid(), dbEngine, dataSource, sqlConnString, sqlConnString, false);

                Console.WriteLine("Getting Available Server List");
                recorder.RefreshServerList();
                var availableServers = recorder.GetServerList();

                foreach (var svr in availableServers)
                {
                    Console.WriteLine("ADS Found : " + svr);
                }

                if (availableServers.Count > 0)
                {
                    Console.WriteLine($"Setting ADS Connection to {RecorderDataServer}");
                    recorder.SetDataServer(RecorderDataServer);

                    MonitorRecorder();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("");
                Console.WriteLine("ERROR:");
                Console.WriteLine(e);
                Console.WriteLine("ERROR");
                Console.WriteLine("");
            }
            Console.WriteLine("Test Complete");
            Console.ReadLine();
        }
Example #3
0
        public static void SelfInitializingWithFileRecorder(
            string fileRecorderPath,
            ILibraryService realServiceWhileRecording,
            ILibraryService realServiceDuringPlayback,
            int countWhileRecording,
            int countDuringPlayback)
        {
            "Given a path that does not exist"
            .x(() => fileRecorderPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()));

            "And a real service to wrap while recording"
            .x(() =>
            {
                realServiceWhileRecording = A.Fake <ILibraryService>();

                A.CallTo(() => realServiceWhileRecording.GetCount("8"))
                .Returns(0x8);
            });

            "And a real service to wrap while playing back"
            .x(() => realServiceDuringPlayback = A.Fake <ILibraryService>());

            "When I use a self-initialized fake recording to the path to get the count for book 8"
            .x(() =>
            {
                using (var recorder = Recorders.FileRecorder(fileRecorderPath))
                {
                    var fakeService = A.Fake <ILibraryService>(options => options
                                                               .Wrapping(realServiceWhileRecording).RecordedBy(recorder));
                    countWhileRecording = fakeService.GetCount("8");
                }
            })
            .Teardown(() => File.Delete(fileRecorderPath));

            "And I use a self-initialized fake playing back from the path to get the count for book 8"
            .x(() =>
            {
                using (var recorder = Recorders.FileRecorder(fileRecorderPath))
                {
                    var playbackFakeService = A.Fake <ILibraryService>(options => options
                                                                       .Wrapping(realServiceDuringPlayback).RecordedBy(recorder));

                    countDuringPlayback = playbackFakeService.GetCount("8");
                }
            });

            "Then the recording fake returns the wrapped service's result"
            .x(() => countWhileRecording.Should().Be(8));

            "And the playback fake returns the recorded result"
            .x(() => countDuringPlayback.Should().Be(8));
        }
Example #4
0
        public static void SelfInitializingWithFileRecorder(
            string fileRecorderPath,
            ILibraryService realServiceWhileRecording,
            ILibraryService realServiceDuringPlayback,
            int countWhileRecording,
            int countDuringPlayback)
        {
            "establish"
            .x(() =>
            {
                fileRecorderPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

                realServiceWhileRecording = A.Fake <ILibraryService>();
                realServiceDuringPlayback = A.Fake <ILibraryService>();

                A.CallTo(() => realServiceWhileRecording.GetCount("9780345813923")).Returns(8);
            });

            "when self initializing a fake with a file recorder"
            .x(() =>
            {
                try
                {
                    using (var recorder = Recorders.FileRecorder(fileRecorderPath))
                    {
                        var fakeService = A.Fake <ILibraryService>(options => options
                                                                   .Wrapping(realServiceWhileRecording).RecordedBy(recorder));
                        countWhileRecording = fakeService.GetCount("9780345813923");
                    }

                    using (var recorder = Recorders.FileRecorder(fileRecorderPath))
                    {
                        var playbackFakeService = A.Fake <ILibraryService>(options => options
                                                                           .Wrapping(realServiceDuringPlayback).RecordedBy(recorder));

                        countDuringPlayback = playbackFakeService.GetCount("9780345813923");
                    }
                }
                finally
                {
                    File.Delete(fileRecorderPath);
                }
            })
            .Teardown(() => File.Delete(fileRecorderPath));

            "it should return the expected result while recording"
            .x(() => countWhileRecording.Should().Be(8));

            "it should return the recorded result during playback"
            .x(() => countDuringPlayback.Should().Be(8));
        }
        public void FileRecorder_tests()
        {
            using (var recorder = Recorders.FileRecorder(@"C:\Users\Patrik\Documents\recorded_calls.dat"))
            {
                var realReader = new WebReader();
                var fakeReader = A.Fake <WebReader>(x => x.Wrapping(realReader).RecordedBy(recorder));

                for (int i = 0; i < 30; i++)
                {
                    fakeReader.Download(new Uri("http://www.sembo.se/"));
                }

                Console.WriteLine(fakeReader.Download(new Uri("http://www.sembo.se/")));
            }
        }
Example #6
0
        public void FileRecorder_should_return_recording_manager_with_file_storage()
        {
            // Arrange
            var storage = new FileStorage(string.Empty, A.Fake <IFileSystem>());

            this.StubResolve <FileStorage.Factory>(x => x == "c:\\file.dat" ? storage : null);

            var recordingManager = A.Fake <RecordingManager>();

            this.StubResolve <RecordingManager.Factory>(x => x.Equals(storage) ? recordingManager : null);

            // Act
            var recorder = Recorders.FileRecorder("c:\\file.dat");

            // Assert
            recorder.Should().BeSameAs(recordingManager);
        }
Example #7
0
        public SessionDefinition Clone()
        {
            var clone = (SessionDefinition)this.MemberwiseClone();

            clone.Recorders = Recorders?.Select(r => r.Clone()).ToList() ?? new List <SessionRecorderDefinition>();
            clone.Devices   = Devices?.Select(d => d.Clone()).ToList();
            clone.Welcome   = Welcome?.Clone() as WelcomeActionSettings;

            clone.PreSessionSteps = PreSessionSteps?.Select(s => s.Clone()).ToList()
                                    ?? new List <SessionStep>();

            clone.SessionSteps = SessionSteps?.Select(s => s.Clone()).ToList()
                                 ?? new List <SessionStep>();

            clone.PostSessionSteps = PostSessionSteps?.Select(s => s.Clone()).ToList()
                                     ?? new List <SessionStep>();

            return(clone);
        }
Example #8
0
        //***********************************************************************************************************************************************************************************************************

        private void StartRecord()
        {
            PlayerApp.ListenForEvents = false;

            bool isPlaying = PlayerApp.CurrentPlaybackStatus.IsPlaying;

            OnPropertyChanged("AreRecorderSettingsChanged");

            CurrentRecorder?.StopRecord();

            if (!isPlaying || !IsRecorderArmed)     //Only start a new record if music is playing and the recorder is armed
            {
                PlayerApp.ListenForEvents = true;
                return;
            }

            //if (Recorders.Count > 0 && Recorders.Select(r => r.TrackInfo.TrackID).Contains(PlayerApp.CurrentTrack.TrackID))
            //{
            //    PlayerApp.ListenForEvents = true;
            //    return;
            //}

            Recorder tmpRecorder = new SpotifyRecorderImplementierung((RecorderSettings)RecSettings.Clone(), PlayerApp.CurrentTrack, _logHandle);

            tmpRecorder.OnRecorderPostStepsFinished += TmpRecorder_OnRecorderPostStepsFinished;
            Recorders.Add(tmpRecorder);

            if (PlayerApp.CurrentTrack != null && !PlayerApp.CurrentPlaybackStatus.IsAd)
            {
                tmpRecorder?.StartRecord();
            }

            CleanupRecordersList();

            PlayerApp.ListenForEvents = true;
        }