public void TestOneModification5() { var logFile = new MultiLineLogFile(_taskScheduler, _source.Object, TimeSpan.Zero); _taskScheduler.RunOnce(); logFile.GetValue(LogFileProperties.LastModified).Should().NotHaveValue("because the source doesn't exist (yet)"); var timestamp = new DateTime(2017, 3, 15, 22, 40, 0); _lines.Add(new LogLine()); _source.Setup(x => x.GetValue(LogFileProperties.LastModified)).Returns(timestamp); _source.Setup(x => x.GetValues(It.IsAny <ILogFileProperties>())) .Callback((ILogFileProperties properties) => { properties.SetValue(LogFileProperties.LastModified, timestamp); }); logFile.GetValue(LogFileProperties.LastModified).Should().NotHaveValue("because the change shouldn't have been applied yet"); logFile.OnLogFileModified(_source.Object, new LogFileSection(0, 1)); logFile.GetValue(LogFileProperties.LastModified).Should().NotHaveValue("because the change shouldn't have been applied yet"); _taskScheduler.RunOnce(); logFile.GetValue(LogFileProperties.LastModified).Should().Be(timestamp, "because the change should have been applied by now"); }
public void TestOneModification6() { var logFile = new MultiLineLogFile(_taskScheduler, _source.Object, TimeSpan.Zero); _taskScheduler.RunOnce(); logFile.GetValue(LogFileProperties.Size).Should().BeNull("because the source doesn't exist (yet)"); var size = Size.FromGigabytes(42); _lines.Add(new LogLine()); _source.Setup(x => x.GetValue(LogFileProperties.Size)).Returns(size); _source.Setup(x => x.GetValues(It.IsAny <ILogFileProperties>())) .Callback((ILogFileProperties properties) => { properties.SetValue(LogFileProperties.Size, size); }); logFile.GetValue(LogFileProperties.Size).Should().BeNull("because the change shouldn't have been applied yet"); logFile.OnLogFileModified(_source.Object, new LogFileSection(0, 1)); logFile.GetValue(LogFileProperties.Size).Should().BeNull("because the change shouldn't have been applied yet"); _taskScheduler.RunOnce(); logFile.GetValue(LogFileProperties.Size).Should().Be(size, "because the change should have been applied by now"); }
public void TestOneModification3() { _source.Setup(x => x.GetValue(LogFileProperties.EmptyReason)).Returns(ErrorFlags.SourceDoesNotExist); var logFile = new MultiLineLogFile(_taskScheduler, _source.Object, TimeSpan.Zero); _taskScheduler.RunOnce(); logFile.GetValue(LogFileProperties.EmptyReason).Should().Be(ErrorFlags.SourceDoesNotExist, "because the source doesn't exist (yet)"); _lines.Add(new LogLine()); _source.Setup(x => x.GetValue(LogFileProperties.EmptyReason)).Returns(ErrorFlags.None); _source.Setup(x => x.GetValues(It.IsAny <ILogFileProperties>())) .Callback((ILogFileProperties properties) => { properties.SetValue(LogFileProperties.EmptyReason, ErrorFlags.None); }); logFile.GetValue(LogFileProperties.EmptyReason).Should().Be(ErrorFlags.SourceDoesNotExist, "because the change shouldn't have been applied yet"); logFile.OnLogFileModified(_source.Object, new LogFileSection(0, 1)); logFile.GetValue(LogFileProperties.EmptyReason).Should().Be(ErrorFlags.SourceDoesNotExist, "because the change shouldn't have been applied yet"); _taskScheduler.RunOnce(); logFile.GetValue(LogFileProperties.EmptyReason).Should().Be(ErrorFlags.None, "because the change should have been applied by now"); }