public void A_file_is_created() { _baseDirectory = AppDomain.CurrentDomain.BaseDirectory; _filename = "test2.dat"; _path = Path.Combine(_baseDirectory, _filename); System.IO.File.Delete(_path); _listener = new Future <FileCreated>(); _channel = new ChannelAdapter(); FiberFactory fiberFactory = () => new SynchronousFiber(); _scheduler = new TimerScheduler(fiberFactory()); _producer = new PollingFileSystemEventProducer(_baseDirectory, _channel, _scheduler, fiberFactory(), 20.Seconds()); Thread.Sleep(5.Seconds()); using (_channel.Connect(x => x.AddConsumerOf <FileCreated>().UsingConsumer(m => _listener.Complete(m)))) { System.IO.File.Create(_path); _listener.WaitUntilCompleted(25.Seconds()); } _producer.Dispose(); }
public void A_file_is_created() { _baseDirectory = AppDomain.CurrentDomain.BaseDirectory; string dir1 = Path.Combine(_baseDirectory, "dir1"); string dir2 = Path.Combine(_baseDirectory, "dir2"); if (System.IO.Directory.Exists(dir1)) { System.IO.Directory.Delete(dir1, true); } if (System.IO.Directory.Exists(dir2)) { System.IO.Directory.Delete(dir2, true); } System.IO.Directory.CreateDirectory(dir1); _createdListener = new Future <FileCreated>(); _deletedListener = new Future <FileSystemDeleted>(); _channel = new ChannelAdapter(); FiberFactory fiberFactory = () => new SynchronousFiber(); _scheduler = new TimerScheduler(fiberFactory()); _producer = new PollingFileSystemEventProducer(_baseDirectory, _channel, _scheduler, fiberFactory(), 20.Seconds()); Thread.Sleep(5.Seconds()); using (_channel.Connect(x => { x.AddConsumerOf <FileCreated>().UsingConsumer(m => _createdListener.Complete(m)); x.AddConsumerOf <FileSystemDeleted>().UsingConsumer(m => _deletedListener.Complete(m)); })) { System.IO.Directory.Move(dir1, dir2); _createdListener.WaitUntilCompleted(10.Seconds()); _deletedListener.WaitUntilCompleted(10.Seconds()); } _producer.Dispose(); }