public void TestDataSourceDoesntExist2() { var dataSource = new Mock <IFileDataSource>(); var logFile = new Mock <ILogSource>(); var emptyReason = new SourceDoesNotExist("E:\\Tailviewer\\somefile.log"); logFile.Setup(x => x.GetProperty(Properties.EmptyReason)).Returns(emptyReason); logFile.Setup(x => x.GetProperty(Properties.Size)).Returns((Size?)null); var filteredLogFile = new Mock <ILogSource>(); ILogSourceListener listener = null; filteredLogFile.Setup(x => x.AddListener(It.IsAny <ILogSourceListener>(), It.IsAny <TimeSpan>(), It.IsAny <int>())) .Callback((ILogSourceListener l, TimeSpan t, int i) => listener = l); dataSource.Setup(x => x.UnfilteredLogSource).Returns(logFile.Object); dataSource.Setup(x => x.FullFileName).Returns(@"E:\Tailviewer\somefile.log"); dataSource.Setup(x => x.FilteredLogSource).Returns(filteredLogFile.Object); dataSource.Setup(x => x.Search).Returns(new Mock <ILogSourceSearch>().Object); var dataSourceModel = CreateFileViewModel(dataSource.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Data source does not exist"); model.NoEntriesAction.Should().Be("The data source 'somefile.log' was last seen E:\\Tailviewer"); logFile.Setup(x => x.GetProperty(Properties.EmptyReason)).Returns((IEmptyReason)null); logFile.Setup(x => x.GetProperty(Properties.Size)).Returns(Size.Zero); listener.OnLogFileModified(logFile.Object, LogSourceModification.Appended(0, 0)); model.Update(); model.NoEntriesExplanation.Should().Be("Data source is empty"); model.NoEntriesAction.Should().BeNull(); }
public void TestSetToDefaultPartial() { var properties = new PropertiesBufferList(); var sourceCannotBeAccessed = new SourceDoesNotExist("wdawdwaw.txt"); properties.SetValue(Core.Properties.EmptyReason, sourceCannotBeAccessed); properties.SetValue(Core.Properties.PercentageProcessed, Percentage.Of(50, 100)); properties.SetToDefault(new [] { Core.Properties.PercentageProcessed }); properties.GetValue(Core.Properties.EmptyReason).Should().Be(sourceCannotBeAccessed, "because only the PercentageProcessed property may have been reset"); properties.GetValue(Core.Properties.PercentageProcessed).Should().Be(Core.Properties.PercentageProcessed.DefaultValue); }
public void TestSetToDefault() { var properties = new PropertiesBufferList(); var sourceCannotBeAccessed = new SourceDoesNotExist("wdawdwaw.txt"); properties.SetValue(Core.Properties.EmptyReason, sourceCannotBeAccessed); properties.SetValue(Core.Properties.PercentageProcessed, Percentage.Of(50, 100)); properties.SetToDefault(); properties.GetValue(Core.Properties.EmptyReason).Should().Be(Core.Properties.EmptyReason.DefaultValue); properties.GetValue(Core.Properties.PercentageProcessed).Should().Be(Percentage.Zero); }
public void TestSetToDefaultNull() { var properties = new PropertiesBufferList(); var sourceCannotBeAccessed = new SourceDoesNotExist("wdawdwaw.txt"); properties.SetValue(Core.Properties.EmptyReason, sourceCannotBeAccessed); properties.SetValue(Core.Properties.PercentageProcessed, Percentage.Of(50, 100)); new Action(() => properties.SetToDefault(null)).Should().Throw <ArgumentNullException>(); properties.GetValue(Core.Properties.EmptyReason).Should().Be(sourceCannotBeAccessed); properties.GetValue(Core.Properties.PercentageProcessed).Should().Be(Percentage.Of(50, 100)); }
public void TestSetValue6() { var properties = new PropertiesBufferList(); var sourceDoesNotExist = new SourceDoesNotExist("dawdaw.txt"); properties.SetValue((IReadOnlyPropertyDescriptor)Core.Properties.EmptyReason, sourceDoesNotExist); properties.GetValue(Core.Properties.EmptyReason).Should().Be(sourceDoesNotExist); var sourceCannotBeAccessed = new SourceDoesNotExist("wdawdwaw.txt"); properties.SetValue((IReadOnlyPropertyDescriptor)Core.Properties.EmptyReason, sourceCannotBeAccessed); properties.GetValue(Core.Properties.EmptyReason).Should().Be(sourceCannotBeAccessed); }
public void TestDataSourceDoesntExist1() { var dataSource = new Mock <IFileDataSource>(); var logFile = new Mock <ILogSource>(); var emptyReason = new SourceDoesNotExist("E:\\Tailviewer\\somefile.log"); logFile.Setup(x => x.GetProperty(Properties.EmptyReason)).Returns(emptyReason); var filteredLogFile = new Mock <ILogSource>(); dataSource.Setup(x => x.UnfilteredLogSource).Returns(logFile.Object); dataSource.Setup(x => x.FullFileName).Returns(@"E:\Tailviewer\somefile.log"); dataSource.Setup(x => x.FilteredLogSource).Returns(filteredLogFile.Object); dataSource.Setup(x => x.Search).Returns(new Mock <ILogSourceSearch>().Object); var dataSourceModel = CreateFileViewModel(dataSource.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Data source does not exist"); model.NoEntriesAction.Should().Be("The data source 'somefile.log' was last seen E:\\Tailviewer"); }