Ejemplo n.º 1
0
 private static void FileSystemCreated(TopshelfFileSystemEventArgs topshelfFileSystemEventArgs)
 {
     Console.WriteLine("*********************");
     Console.WriteLine("ChangeType = {0}", topshelfFileSystemEventArgs.ChangeType);
     Console.WriteLine("FullPath = {0}", topshelfFileSystemEventArgs.FullPath);
     Console.WriteLine("Name = {0}", topshelfFileSystemEventArgs.Name);
     Console.WriteLine("FileSystemEventType {0}", topshelfFileSystemEventArgs.FileSystemEventType);
     Console.WriteLine("*********************");
 }
        public void FileSystemRenameEventIsInvokedWithOneDirectoryTest()
        {
            //Arrange
            Mock <IDelegateMock>        onChanged  = new Mock <IDelegateMock>();
            TopshelfFileSystemEventArgs argsCalled = null;

            onChanged.Setup(mock => mock.FileSystemChanged(It.IsAny <TopshelfFileSystemEventArgs>())).Callback <TopshelfFileSystemEventArgs>(args => argsCalled = args);

            CreateFile(_testDir + "testFile.Test");

            //Act
            var exitCode = HostFactory.Run(config =>
            {
                config.UseTestHost();

                config.Service <TopshelfFileSystemWatcherTest>(s =>
                {
                    s.ConstructUsing(() => new TopshelfFileSystemWatcherTest());
                    s.WhenStarted((service, host) =>
                    {
                        RenameFile(_testDir + "testFile.Test", _testDir + "testFile2.Test");
                        return(true);
                    });
                    s.WhenStopped((service, host) => true);
                    s.WhenFileSystemRenamed(configurator => configurator.AddDirectory(dir =>
                    {
                        dir.Path                  = TestContext.CurrentContext.WorkDirectory + _testDir;
                        dir.CreateDir             = true;
                        dir.IncludeSubDirectories = true;
                        dir.NotifyFilters         = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.CreationTime;
                    }), onChanged.Object.FileSystemRenamed);
                });
            });

            //Assert
            onChanged.Verify(mock => mock.FileSystemChanged(It.IsAny <TopshelfFileSystemEventArgs>()), Times.Never);
            onChanged.Verify(mock => mock.FileSystemCreated(It.IsAny <TopshelfFileSystemEventArgs>()), Times.Never);
            onChanged.Verify(mock => mock.FileSystemDeleted(It.IsAny <TopshelfFileSystemEventArgs>()), Times.Never);
            onChanged.Verify(mock => mock.FileSystemRenamed(It.IsAny <TopshelfFileSystemEventArgs>()), Times.Exactly(1));
            onChanged.Verify(mock => mock.FileSystemInitial(It.IsAny <TopshelfFileSystemEventArgs>()), Times.Never);
            Assert.AreEqual(TopshelfExitCode.Ok, exitCode);
        }
Ejemplo n.º 3
0
        private static void FileSystemRenamedDirectory(TopshelfFileSystemEventArgs topshelfFileSystemEventArgs)
        {
            FileSystemChangeMessage m = new FileSystemChangeMessage
            {
                ChangeDate = SystemClock.Instance.GetCurrentInstant().ToDateTimeUtc().ToLocalTime(),
                ChangeType = (int)topshelfFileSystemEventArgs.ChangeType,
                EventType  = (int)topshelfFileSystemEventArgs.FileSystemEventType,
                FullPath   = topshelfFileSystemEventArgs.FullPath,
                OldPath    = topshelfFileSystemEventArgs.OldFullPath,
                Name       = topshelfFileSystemEventArgs.Name,
                OldName    = topshelfFileSystemEventArgs.OldName
            };

            _bus.Publish(m, "FileSystemChanges");

            Console.WriteLine("*************************");
            Console.WriteLine("ChangeType = {0}", topshelfFileSystemEventArgs.ChangeType);
            Console.WriteLine("FullPath = {0}", topshelfFileSystemEventArgs.FullPath);
            Console.WriteLine("Name = {0}", topshelfFileSystemEventArgs.Name);
            Console.WriteLine("FIleSystemEventType {0}", topshelfFileSystemEventArgs.FileSystemEventType);
            Console.WriteLine("*************************");
        }
Ejemplo n.º 4
0
        /**************************************************************************/

        /// <summary>
        /// Will run on every new file arriving in folder
        /// </summary>
        private static void FileArrived(TopshelfFileSystemEventArgs topshelfFileSystemEventArgs)
        {
            Logger.Info("New file arrived");
            Service.AddFilesToQueue(topshelfFileSystemEventArgs.FullPath);
            Service.RunProcess();
        }
Ejemplo n.º 5
0
 private static void FileSystemCreated(TopshelfFileSystemEventArgs topshelfFileSystemEventArgs)
 {
     Console.WriteLine("New file created! ChangeType = {0} FullPath = {1} Name = {2} FileSystemEventType {3}", topshelfFileSystemEventArgs.ChangeType, topshelfFileSystemEventArgs.FullPath, topshelfFileSystemEventArgs.Name, topshelfFileSystemEventArgs.FileSystemEventType);
 }
Ejemplo n.º 6
0
 private static void FileSystemCreated(TopshelfFileSystemEventArgs topshelfFileSystemEventArgs)
 {
     Console.WriteLine("New file created! ChangeType = {0} FullPath = {1} Name = {2} FileSystemEventType {3}", topshelfFileSystemEventArgs.ChangeType, topshelfFileSystemEventArgs.FullPath, topshelfFileSystemEventArgs.Name, topshelfFileSystemEventArgs.FileSystemEventType);
 }