public void QualifyTest() { var dummyDataSource = new MockDataSource(); var archive = new TelemetryArchive(); var loggerFromZero = new TelemetryLogger("test", new TelemetryLoggerConfiguration(true, true, true, true)); loggerFromZero.SetDatasource(dummyDataSource); GlobalEvents.Fire(new SessionStarted(), true); Assert.False(archive.QualifiesForStorage(loggerFromZero)); loggerFromZero.Update(0); Assert.False(archive.QualifiesForStorage(loggerFromZero)); loggerFromZero.Update(1000); Assert.False(archive.QualifiesForStorage(loggerFromZero)); loggerFromZero.Update(5000); Assert.False(archive.QualifiesForStorage(loggerFromZero)); loggerFromZero.Update(10000); Assert.True(archive.QualifiesForStorage(loggerFromZero)); loggerFromZero.Close(); var loggerFromElse = new TelemetryLogger("test", new TelemetryLoggerConfiguration(true, true, true, true)); loggerFromElse.SetDatasource(dummyDataSource); GlobalEvents.Fire(new SessionStarted(), true); Assert.False(archive.QualifiesForStorage(loggerFromElse)); loggerFromElse.Update(10000); Assert.False(archive.QualifiesForStorage(loggerFromElse)); loggerFromElse.Update(13000); Assert.False(archive.QualifiesForStorage(loggerFromElse)); loggerFromElse.Update(0); Assert.False(archive.QualifiesForStorage(loggerFromElse)); loggerFromElse.Update(20000); Assert.True(archive.QualifiesForStorage(loggerFromElse)); loggerFromElse.Update(24*3600*1000); Assert.True(archive.QualifiesForStorage(loggerFromElse)); }
public void Record() { if (Process.GetProcessesByName("rfactor").Length == 0) Assert.Ignore(); var rFactorProcess = Process.GetProcessesByName("rfactor")[0]; IntPtr alloc = Marshal.AllocHGlobal(512 * 1024 * 1024); using (var host = new Plugins()) { host.PluginDirectory = TestConstants.SimulatorsBinFolder; host.Load(); // Simulators are now loaded var testPlugin = host.Simulators.Where(x => x.Name == "Test simulator").FirstOrDefault(); testPlugin.SimulatorStart(rFactorProcess); var telSource = new Domain.Aggregates.Telemetry(testPlugin.TelemetryProvider, rFactorProcess); var telLogger = new TelemetryLogger("testSim", new TelemetryLoggerConfiguration(true, false, true, false)); telLogger.SetAnnotater(new TelemetryArchive()); telSource.SetLogger(telLogger); Thread.Sleep(15000); telLogger.Close(); telSource = null; } Marshal.FreeHGlobal(alloc); }