Fixes issue where full path is included in moment-reference objects
This commit is contained in:
parent
2ec7f26387
commit
a72866c725
|
@ -98,6 +98,7 @@ namespace OverwatchTranscript
|
|||
public class Builder
|
||||
{
|
||||
private readonly ILog log;
|
||||
private readonly string workingDir;
|
||||
private OverwatchMomentReference reference;
|
||||
private readonly ActionQueue queue = new ActionQueue();
|
||||
|
||||
|
@ -105,14 +106,14 @@ namespace OverwatchTranscript
|
|||
{
|
||||
reference = new OverwatchMomentReference
|
||||
{
|
||||
MomentsFile = Path.Combine(workingDir, Guid.NewGuid().ToString()),
|
||||
MomentsFile = Guid.NewGuid().ToString(),
|
||||
EarliestUtc = DateTime.MaxValue,
|
||||
LatestUtc = DateTime.MinValue,
|
||||
NumberOfEvents = 0,
|
||||
NumberOfMoments = 0,
|
||||
};
|
||||
this.log = log;
|
||||
|
||||
this.workingDir = workingDir;
|
||||
queue.Start();
|
||||
}
|
||||
|
||||
|
@ -125,9 +126,11 @@ namespace OverwatchTranscript
|
|||
reference.NumberOfMoments++;
|
||||
reference.NumberOfEvents += moment.Events.Length;
|
||||
|
||||
var filePath = Path.Combine(workingDir, reference.MomentsFile);
|
||||
|
||||
queue.Add(() =>
|
||||
{
|
||||
File.AppendAllLines(reference.MomentsFile, new[]
|
||||
File.AppendAllLines(filePath, new[]
|
||||
{
|
||||
JsonConvert.SerializeObject(moment)
|
||||
});
|
||||
|
|
|
@ -10,16 +10,14 @@ namespace FrameworkTests.OverwatchTranscript
|
|||
private const int NumberOfThreads = 10;
|
||||
private const int NumberOfEventsPerThread = 1000000;
|
||||
private const string TranscriptFilename = "testtranscriptlarge.owts";
|
||||
private TranscriptWriter writer = null!;
|
||||
private ITranscriptWriter writer = null!;
|
||||
|
||||
[Test]
|
||||
[Ignore("Takes about 25 minutes to run.")]
|
||||
public void MillionsOfEvents()
|
||||
{
|
||||
var workdir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
|
||||
var log = new FileLog(nameof(MillionsOfEvents));
|
||||
writer = new TranscriptWriter(log, workdir);
|
||||
writer = Transcript.NewWriter(log);
|
||||
|
||||
Stopwatch.Measure(log, "Generate", () =>
|
||||
{
|
||||
|
@ -39,7 +37,7 @@ namespace FrameworkTests.OverwatchTranscript
|
|||
|
||||
Stopwatch.Measure(log, "Read", () =>
|
||||
{
|
||||
ReadTranscript(workdir);
|
||||
ReadTranscript();
|
||||
});
|
||||
|
||||
File.Delete(TranscriptFilename);
|
||||
|
@ -68,9 +66,9 @@ namespace FrameworkTests.OverwatchTranscript
|
|||
});
|
||||
}
|
||||
|
||||
private void ReadTranscript(string workdir)
|
||||
private void ReadTranscript()
|
||||
{
|
||||
var reader = new TranscriptReader(workdir, TranscriptFilename);
|
||||
var reader = Transcript.NewReader(TranscriptFilename);
|
||||
|
||||
var expectedNumberOfEvents = NumberOfThreads * NumberOfEventsPerThread;
|
||||
Assert.That(reader.Header.NumberOfEvents, Is.EqualTo(expectedNumberOfEvents));
|
||||
|
|
|
@ -21,18 +21,16 @@ namespace FrameworkTests.OverwatchTranscript
|
|||
[Test]
|
||||
public void WriteAndRun()
|
||||
{
|
||||
var workdir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
|
||||
WriteTranscript(workdir);
|
||||
ReadTranscript(workdir);
|
||||
WriteTranscript();
|
||||
ReadTranscript();
|
||||
|
||||
File.Delete(TranscriptFilename);
|
||||
}
|
||||
|
||||
private void WriteTranscript(string workdir)
|
||||
private void WriteTranscript()
|
||||
{
|
||||
var log = new ConsoleLog();
|
||||
var writer = new TranscriptWriter(log, workdir);
|
||||
var writer = Transcript.NewWriter(log);
|
||||
|
||||
writer.AddHeader(HeaderKey, new TestHeader
|
||||
{
|
||||
|
@ -61,9 +59,9 @@ namespace FrameworkTests.OverwatchTranscript
|
|||
writer.Write(TranscriptFilename);
|
||||
}
|
||||
|
||||
private void ReadTranscript(string workdir)
|
||||
private void ReadTranscript()
|
||||
{
|
||||
var reader = new TranscriptReader(workdir, TranscriptFilename);
|
||||
var reader = Transcript.NewReader(TranscriptFilename);
|
||||
|
||||
var header = reader.GetHeader<TestHeader>(HeaderKey);
|
||||
Assert.That(header.HeaderData, Is.EqualTo(HeaderData));
|
||||
|
|
Loading…
Reference in New Issue