Ejemplo n.º 1
0
        public void TestListen4()
        {
            using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object))
            {
                proxy.AddListener(_listener.Object, TimeSpan.Zero, 1000);

                new Action(() => proxy.OnLogFileModified(new Mock <ILogSource>().Object, LogSourceModification.Appended(0, 1))).Should().NotThrow();
                _modifications.Should().Equal(new[] { LogSourceModification.Reset() }, "because the OnLogFileModified shouldn't have been forwarded since it's from the wrong source");

                new Action(() => proxy.OnLogFileModified(null, LogSourceModification.Appended(0, 1))).Should().NotThrow();
                _modifications.Should().Equal(new[] { LogSourceModification.Reset() }, "because the OnLogFileModified shouldn't have been forwarded since it's from the wrong source");
            }
        }
Ejemplo n.º 2
0
        public void TestListen1()
        {
            using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object))
            {
                proxy.AddListener(_listener.Object, TimeSpan.FromSeconds(1), 1000);
                proxy.OnLogFileModified(_logFile.Object, LogSourceModification.Appended(0, 1));

                _modifications.Property(x => x.Count).ShouldEventually().Be(2);
                _modifications.Should().Equal(new[]
                {
                    LogSourceModification.Reset(),
                    LogSourceModification.Appended(0, 1)
                });
            }
        }
Ejemplo n.º 3
0
        public void TestListen1()
        {
            using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object, 1000))
            {
                proxy.AddListener(_listener.Object, TimeSpan.Zero, 1000);

                _listeners.OnRead(500);
                _listeners.OnRead(600);

                _taskScheduler.RunOnce();

                _modifications.Should().Equal(new[]
                {
                    LogSourceModification.Reset(),
                    LogSourceModification.Appended(0, 500),
                    LogSourceModification.Appended(500, 100)
                });
            }
        }