Esempio n. 1
0
        static void Main(string[] args)
        {
            DisplayHeader();

            IKernel kernel = new StandardKernel();
            kernel.Load(Assembly.GetExecutingAssembly());
            IFileReader fileReader = kernel.Get<IFileReader>();
            var unitOfWork = new UnitOfWork<FileWatcherContext>();

            // set up your basic configurations here
            var settings = new ConfigurationSetting
                {
                    Path = @"C:\Users\Nino\Desktop\test", // set this to the folder that you would like to monitor
                    RaiseEvent = true,
                    Extention = "*.xml" // extention of a file the needs to be monitored
                };

            // call the service
            IMainFileWatcher watcher = new MainFileWatcher(fileReader, unitOfWork);

            // pass the config
            watcher.SetConfiguration(settings);

            Console.Read();
        }
        public void ShouldThrowArgumentNullExceptionForNullInput()
        {
            ConfigurationSetting setting = null;
            var fileReader = new Mock<IFileReader>(MockBehavior.Strict);
            var uow = new Mock<IUnitOfWork>(MockBehavior.Strict);
            IMainFileWatcher fileWatcher = new MainFileWatcher(fileReader.Object, uow.Object);

            var ex = Assert.Throws<ArgumentNullException>(() => fileWatcher.SetConfiguration(setting));

            Assert.Equal(ex.GetType(), typeof(ArgumentNullException));
            Assert.Equal(ex.ParamName, "setting");
        }