2019-07-21 12:12:28 +00:00
|
|
|
|
// <copyright file="Result.cs" company="Adrian Conlon">
|
|
|
|
|
// Copyright (c) Adrian Conlon. All rights reserved.
|
|
|
|
|
// </copyright>
|
|
|
|
|
namespace Fuse
|
2019-07-20 18:17:08 +00:00
|
|
|
|
{
|
2019-07-21 08:10:45 +00:00
|
|
|
|
using System;
|
2019-07-20 18:17:08 +00:00
|
|
|
|
using System.Collections.Generic;
|
2019-07-21 08:10:45 +00:00
|
|
|
|
using System.Collections.ObjectModel;
|
2019-07-20 18:17:08 +00:00
|
|
|
|
|
2019-08-13 17:51:34 +00:00
|
|
|
|
public class Result<T>
|
|
|
|
|
where T : Fuse.IRegisterState, new()
|
2019-07-20 18:17:08 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly TestEvents events = new TestEvents();
|
2019-07-21 08:10:45 +00:00
|
|
|
|
private readonly List<MemoryDatum> memoryData = new List<MemoryDatum>();
|
2019-07-20 18:17:08 +00:00
|
|
|
|
|
|
|
|
|
public string Description { get; private set; }
|
|
|
|
|
|
2019-08-13 17:51:34 +00:00
|
|
|
|
public T RegisterState { get; } = new T();
|
2019-07-20 18:17:08 +00:00
|
|
|
|
|
2019-08-14 21:38:47 +00:00
|
|
|
|
public TestEvents Events => this.events;
|
|
|
|
|
|
2019-07-21 08:10:45 +00:00
|
|
|
|
public ReadOnlyCollection<MemoryDatum> MemoryData => this.memoryData.AsReadOnly();
|
2019-07-20 18:17:08 +00:00
|
|
|
|
|
2019-07-21 08:28:49 +00:00
|
|
|
|
public bool TryParse(Lines lines)
|
2019-07-20 18:17:08 +00:00
|
|
|
|
{
|
2019-07-21 08:10:45 +00:00
|
|
|
|
if (lines == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException(nameof(lines));
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-21 08:28:49 +00:00
|
|
|
|
while (!lines.EndOfFile && string.IsNullOrWhiteSpace(this.Description))
|
2019-07-20 18:17:08 +00:00
|
|
|
|
{
|
|
|
|
|
this.Description = lines.ReadLine();
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-21 08:28:49 +00:00
|
|
|
|
if (string.IsNullOrWhiteSpace(this.Description))
|
2019-07-20 18:17:08 +00:00
|
|
|
|
{
|
2019-07-21 08:28:49 +00:00
|
|
|
|
return false;
|
2019-07-20 18:17:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.events.Parse(lines);
|
|
|
|
|
this.RegisterState.Parse(lines);
|
|
|
|
|
|
2019-08-13 17:51:34 +00:00
|
|
|
|
bool finished;
|
2019-07-20 18:17:08 +00:00
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
var line = lines.ReadLine();
|
|
|
|
|
finished = string.IsNullOrWhiteSpace(line);
|
|
|
|
|
if (!finished)
|
|
|
|
|
{
|
|
|
|
|
var datum = new MemoryDatum();
|
|
|
|
|
datum.Parse(line);
|
2019-07-21 08:10:45 +00:00
|
|
|
|
this.memoryData.Add(datum);
|
2019-07-20 18:17:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (!finished);
|
2019-07-21 08:28:49 +00:00
|
|
|
|
|
|
|
|
|
return true;
|
2019-07-20 18:17:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|