Ejemplo n.º 1
0
        public void RaiseEventRequiresArgument()
        {
            MockFileSystemWatcher mockWatcher = new MockFileSystemWatcher();

            using (SafeEventFileSystemWatcher tested = new SafeEventFileSystemWatcher(mockWatcher))
                DoAssert.Throws <ArgumentNullException>(() => tested.RaiseEvent(null));
        }
 public void RaseEventThrowsArgumentExceptionOnUnknownEvent()
 {
     MockFileSystemWatcher mockWatcher = new MockFileSystemWatcher();
       using (SafeEventFileSystemWatcher tested = new SafeEventFileSystemWatcher(mockWatcher))
       {
     var evt = new FileSystemEventArgs((WatcherChangeTypes)666, "", "");
     DoAssert.Throws<ArgumentException>(() => tested.RaiseEvent(evt));
       }
 }
Ejemplo n.º 3
0
        public void RaseEventThrowsArgumentExceptionOnUnknownEvent()
        {
            MockFileSystemWatcher mockWatcher = new MockFileSystemWatcher();

            using (SafeEventFileSystemWatcher tested = new SafeEventFileSystemWatcher(mockWatcher))
            {
                var evt = new FileSystemEventArgs((WatcherChangeTypes)666, "", "");
                DoAssert.Throws <ArgumentException>(() => tested.RaiseEvent(evt));
            }
        }
Ejemplo n.º 4
0
        public void ShouldLogRaisedEventsToDebug()
        {
            var     dir  = "somedir";
            var     file = "somefile";
            MockLog log;

            using (SafeEventFileSystemWatcher tested = new SafeEventFileSystemWatcher(new Mock <IFileSystemWatcher>().Object))
            {
                log = new MockLog(tested);
                var evt = new FileSystemEventArgs(WatcherChangeTypes.Created, dir, file);
                tested.RaiseEvent(evt);
            }
            Assert.IsTrue(
                log.Any(x =>
                        x.Level == MockLog.Level.Debug &&
                        x.Message.Contains(dir) &&
                        x.Message.Contains(file) &&
                        x.Message.Contains(WatcherChangeTypes.Created.ToString())));
        }
 public void RaiseEventRequiresArgument()
 {
     MockFileSystemWatcher mockWatcher = new MockFileSystemWatcher();
       using (SafeEventFileSystemWatcher tested = new SafeEventFileSystemWatcher(mockWatcher))
     DoAssert.Throws<ArgumentNullException>(() => tested.RaiseEvent(null));
 }
 public void ShouldLogRaisedEventsToDebug()
 {
     var dir = "somedir";
       var file = "somefile";
       MockLog log;
       using (SafeEventFileSystemWatcher tested = new SafeEventFileSystemWatcher(new Mock<IFileSystemWatcher>().Object))
       {
     log = new MockLog(tested);
     var evt = new FileSystemEventArgs(WatcherChangeTypes.Created, dir, file);
     tested.RaiseEvent(evt);
       }
       Assert.IsTrue(
     log.Any(x =>
       x.Level == MockLog.Level.Debug &&
       x.Message.Contains(dir) &&
       x.Message.Contains(file) &&
       x.Message.Contains(WatcherChangeTypes.Created.ToString())));
 }