public void TimeSectionValuesRoundTrip() { var ms = new MemoryStream(); var fio = new FileIO(ms); var fw = new FormattedWriter(fio); var wc = new WriteContext(fw); wc.Description = new TeaFileDescription(); wc.Description.ItemDescription = ItemDescription.FromAnalysis <Event <C> >(); Time.Scale = Timescale.FromEpoch(33, 77); wc.Description.Timescale = Time.Scale; ISectionFormatter f = new TimeSectionFormatter(); f.Write(wc); ms.Position = 0; var fr = new FormattedReader(fio); var rc = new ReadContext(fr); rc.Description.Should().Not.Be.Null(); rc.Description.ItemDescription = wc.Description.ItemDescription; f.Read(rc); rc.Description.Timescale.Value.Epoch.Should().Be(33); rc.Description.Timescale.Value.TicksPerDay.Should().Be(77); Executing.This(() => f.Read(rc)).Should().Throw <EndOfStreamException>(); }
public void FirstTimeFieldIsAutomaticallyEventTime() { var ms = new MemoryStream(); var fio = new FileIO(ms); var fw = new FormattedWriter(fio); var wc = new WriteContext(fw); wc.Description = new TeaFileDescription(); wc.Description.ItemDescription = ItemDescription.FromAnalysis <C2>(); wc.Description.Timescale = Time.Scale; ISectionFormatter f = new TimeSectionFormatter(); f.Write(wc); ms.Position = 0; var fr = new FormattedReader(fio); var rc = new ReadContext(fr); rc.Description.Should().Not.Be.Null(); rc.Description.ItemDescription = ItemDescription.FromAnalysis <C2>(); f.Read(rc); var fields = rc.Description.ItemDescription.Fields; fields[0].IsEventTime.Should().Be.True(); fields[1].IsEventTime.Should().Be.False(); }
public void EventTimeAttributeRoundTrip() { Time.Scale = Timescale.Net; var ms = new MemoryStream(); var fio = new FileIO(ms); var fw = new FormattedWriter(fio); var wc = new WriteContext(fw); wc.Description = new TeaFileDescription(); wc.Description.ItemDescription = ItemDescription.FromAnalysis <Event <C> >(); wc.Description.Timescale = Time.Scale; ISectionFormatter f = new TimeSectionFormatter(); f.Write(wc); ms.Position = 0; var fr = new FormattedReader(fio); var rc = new ReadContext(fr); rc.Description.Should().Not.Be.Null(); rc.Description.ItemDescription = wc.Description.ItemDescription; rc.Description.ItemDescription.Fields.ForEach(ff => ff.IsEventTime = ff.IsTime = false); // reset flags f.Read(rc); rc.Description.ItemDescription.Fields.Count(ff => ff.IsTime).Should().Be(1); rc.Description.ItemDescription.Fields.Count(ff => ff.IsEventTime).Should().Be(1); rc.Description.Timescale.Value.Epoch.Should().Be(0); rc.Description.Timescale.Value.TicksPerDay.Should().Be(TimeSpan.TicksPerDay); }
public void TimeSectionRoundTrip() { var ms = new MemoryStream(); var fio = new FileIO(ms); var fw = new FormattedWriter(fio); var wc = new WriteContext(fw); wc.Description = new TeaFileDescription(); wc.Description.ItemDescription = ItemDescription.FromAnalysis <Event <C> >(); wc.Description.Timescale = Time.Scale; ISectionFormatter f = new TimeSectionFormatter(); f.Write(wc); ms.Position = 0; ms.Length.Should().Be(24); // epoch(8) ticksperday(8) fieldcount(4) + timefieldoffset(4) = 24 var fr = new FormattedReader(fio); var rc = new ReadContext(fr); rc.Description.Should().Not.Be.Null(); rc.Description.ItemDescription = wc.Description.ItemDescription; // this makes the test a bit weaker, but we need some item description here f.Read(rc); rc.Description.Should().Not.Be.Null(); rc.Description.Timescale.HasValue.Should().Be.True(); }
public void TimeSectionFormatterEmptyDescriptionTest() { var fw = new Mock<IFormattedWriter>(MockBehavior.Strict); var wc = new WriteContext(fw.Object); ISectionFormatter f = new TimeSectionFormatter(); f.Write(wc); // due to the strict behavior of the fw mock, this test succeeds only if no method of fw was called. }
public void TimeSectionFormatterEmptyDescriptionTest() { var fw = new Mock <IFormattedWriter>(MockBehavior.Strict); var wc = new WriteContext(fw.Object); ISectionFormatter f = new TimeSectionFormatter(); f.Write(wc); // due to the strict behavior of the fw mock, this test succeeds only if no method of fw was called. }
public void TimeSectionFormatterDescriptionItemDescriptionNoTimeFields() { var fw = new Mock<IFormattedWriter>(MockBehavior.Strict); var wc = new WriteContext(fw.Object); wc.Description = new TeaFileDescription(); wc.Description.ItemDescription = new ItemDescription(DescriptionSource.File); ISectionFormatter f = new TimeSectionFormatter(); f.Write(wc); // due to the strict behavior of the fw mock, this test succeeds only if no method of fw was called. }
public void TimeSectionFormatterDescriptionItemDescriptionNoTimeFields() { var fw = new Mock <IFormattedWriter>(MockBehavior.Strict); var wc = new WriteContext(fw.Object); wc.Description = new TeaFileDescription(); wc.Description.ItemDescription = new ItemDescription(DescriptionSource.File); ISectionFormatter f = new TimeSectionFormatter(); f.Write(wc); // due to the strict behavior of the fw mock, this test succeeds only if no method of fw was called. }
public void TimeSectionRoundTripFieldIsNotInItemDescriptionError() { var ms = new MemoryStream(); var fio = new FileIO(ms); var fw = new FormattedWriter(fio); var wc = new WriteContext(fw); wc.Description = new TeaFileDescription(); wc.Description.ItemDescription = ItemDescription.FromAnalysis <Event <C> >(); wc.Description.Timescale = Time.Scale; ISectionFormatter f = new TimeSectionFormatter(); f.Write(wc); ms.Position = 0; var fr = new FormattedReader(fio); var rc = new ReadContext(fr); rc.Description.Should().Not.Be.Null(); rc.Description.ItemDescription = ItemDescription.FromAnalysis <C2>(); Executing.This(() => f.Read(rc)).Should().Throw <FileFormatException>(); }
public void TimeSectionValuesRoundTrip() { var ms = new MemoryStream(); var fio = new FileIO(ms); var fw = new FormattedWriter(fio); var wc = new WriteContext(fw); wc.Description = new TeaFileDescription(); wc.Description.ItemDescription = ItemDescription.FromAnalysis<Event<C>>(); Time.Scale = Timescale.FromEpoch(33, 77); wc.Description.Timescale = Time.Scale; ISectionFormatter f = new TimeSectionFormatter(); f.Write(wc); ms.Position = 0; var fr = new FormattedReader(fio); var rc = new ReadContext(fr); rc.Description.Should().Not.Be.Null(); rc.Description.ItemDescription = wc.Description.ItemDescription; f.Read(rc); rc.Description.Timescale.Value.Epoch.Should().Be(33); rc.Description.Timescale.Value.TicksPerDay.Should().Be(77); Executing.This(() => f.Read(rc)).Should().Throw<EndOfStreamException>(); }
public void EventTimeAttributeRoundTrip() { Time.Scale = Timescale.Net; var ms = new MemoryStream(); var fio = new FileIO(ms); var fw = new FormattedWriter(fio); var wc = new WriteContext(fw); wc.Description = new TeaFileDescription(); wc.Description.ItemDescription = ItemDescription.FromAnalysis<Event<C>>(); wc.Description.Timescale = Time.Scale; ISectionFormatter f = new TimeSectionFormatter(); f.Write(wc); ms.Position = 0; var fr = new FormattedReader(fio); var rc = new ReadContext(fr); rc.Description.Should().Not.Be.Null(); rc.Description.ItemDescription = wc.Description.ItemDescription; rc.Description.ItemDescription.Fields.ForEach(ff => ff.IsEventTime = ff.IsTime = false); // reset flags f.Read(rc); rc.Description.ItemDescription.Fields.Count(ff => ff.IsTime).Should().Be(1); rc.Description.ItemDescription.Fields.Count(ff => ff.IsEventTime).Should().Be(1); rc.Description.Timescale.Value.Epoch.Should().Be(0); rc.Description.Timescale.Value.TicksPerDay.Should().Be(TimeSpan.TicksPerDay); }
public void FirstTimeFieldIsAutomaticallyEventTime() { var ms = new MemoryStream(); var fio = new FileIO(ms); var fw = new FormattedWriter(fio); var wc = new WriteContext(fw); wc.Description = new TeaFileDescription(); wc.Description.ItemDescription = ItemDescription.FromAnalysis<C2>(); wc.Description.Timescale = Time.Scale; ISectionFormatter f = new TimeSectionFormatter(); f.Write(wc); ms.Position = 0; var fr = new FormattedReader(fio); var rc = new ReadContext(fr); rc.Description.Should().Not.Be.Null(); rc.Description.ItemDescription = ItemDescription.FromAnalysis<C2>(); f.Read(rc); var fields = rc.Description.ItemDescription.Fields; fields[0].IsEventTime.Should().Be.True(); fields[1].IsEventTime.Should().Be.False(); }
public void TimeSectionRoundTripFieldIsNotInItemDescriptionError() { var ms = new MemoryStream(); var fio = new FileIO(ms); var fw = new FormattedWriter(fio); var wc = new WriteContext(fw); wc.Description = new TeaFileDescription(); wc.Description.ItemDescription = ItemDescription.FromAnalysis<Event<C>>(); wc.Description.Timescale = Time.Scale; ISectionFormatter f = new TimeSectionFormatter(); f.Write(wc); ms.Position = 0; var fr = new FormattedReader(fio); var rc = new ReadContext(fr); rc.Description.Should().Not.Be.Null(); rc.Description.ItemDescription = ItemDescription.FromAnalysis<C2>(); Executing.This(() => f.Read(rc)).Should().Throw<FileFormatException>(); }
public void TimeSectionRoundTrip() { var ms = new MemoryStream(); var fio = new FileIO(ms); var fw = new FormattedWriter(fio); var wc = new WriteContext(fw); wc.Description = new TeaFileDescription(); wc.Description.ItemDescription = ItemDescription.FromAnalysis<Event<C>>(); wc.Description.Timescale = Time.Scale; ISectionFormatter f = new TimeSectionFormatter(); f.Write(wc); ms.Position = 0; ms.Length.Should().Be(24); // epoch(8) ticksperday(8) fieldcount(4) + timefieldoffset(4) = 24 var fr = new FormattedReader(fio); var rc = new ReadContext(fr); rc.Description.Should().Not.Be.Null(); rc.Description.ItemDescription = wc.Description.ItemDescription; // this makes the test a bit weaker, but we need some item description here f.Read(rc); rc.Description.Should().Not.Be.Null(); rc.Description.Timescale.HasValue.Should().Be.True(); }