public void ConvertProcessorElementToEndpointWithNtfsBasedProcessorConfigurator()
        {
            var element = new FileProcessorElement
            {
                Name = "a",
                DropPath = "b",
                Filter = "*",
                SuccessPath = "c",
                FailurePath = "d",
                InProgressPath = "e",
                ScavengeInterval = 100,
                RecoveryInterval = 100,
                ProcessorConfiguratorType = "EventBased"
            };

            var expected = new FileProcessorEndpoint
            {
                Name = "a",
                DropPath = "b",
                Filter = "*",
                SuccessPath = "c",
                FailurePath = "d",
                InProgressPath = "e",
                NumberOfConsumers = 1,
                ScavengeInterval = new TimeSpan(0, 0, 100),
                RecoveryInterval = new TimeSpan(0, 0, 100),
                ProcessorConfigurator = FileProcessorEndpoint.EventBasedConfiguratorType,
                AdditionalFilter = typeof(DefaultFileFilter),
                PollingRestartInterval = new TimeSpan(0, 0, 60)
            };

            var candidate = element.ToEndpoint();
            this.Check(expected, candidate);
        }
        public void ConvertProcessorElementToEndpointWithEmptyProcessorConfigurator()
        {
            var element = new FileProcessorElement
            {
                Name = "a",
                DropPath = "b",
                Filter = "*",
                SuccessPath = "c",
                FailurePath = "d",
                InProgressPath = "e",
                ScavengeInterval = 100,
                RecoveryInterval = 100,
                PollingInterval = 130
            };

            var expected = new FileProcessorEndpoint
            {
                Name = "a",
                DropPath = "b",
                Filter = "*",
                SuccessPath = "c",
                FailurePath = "d",
                InProgressPath = "e",
                NumberOfConsumers = 1,
                ScavengeInterval = new TimeSpan(0, 0, 100),
                RecoveryInterval = new TimeSpan(0, 0, 100),
                ProcessorConfigurator = "EnergyTrading.FileProcessing.Registrars.EventBasedProcessorDefaultRegistrar, EnergyTrading.Unity",
                AdditionalFilter = typeof(DefaultFileFilter),
                PollingRestartInterval = new TimeSpan(0, 0, 60),
                PollingInterval = 130000
            };

            var candidate = element.ToEndpoint();
            Check(expected, candidate);
        }
 private static string DetermineProcessorType(FileProcessorElement element)
 {
     switch (element.ProcessorConfiguratorType)
     {
         case null:
         case "EventBased":
             return FileProcessorEndpoint.EventBasedConfiguratorType;
         case "PollingBased":
             return FileProcessorEndpoint.PollingBasedConfiguratorType;
         default:
             return element.ProcessorConfiguratorType;
     }
 }
Beispiel #4
0
        private static string DetermineProcessorType(FileProcessorElement element)
        {
            switch (element.ProcessorConfiguratorType)
            {
            case null:
            case "EventBased":
                return(FileProcessorEndpoint.EventBasedConfiguratorType);

            case "PollingBased":
                return(FileProcessorEndpoint.PollingBasedConfiguratorType);

            default:
                return(element.ProcessorConfiguratorType);
            }
        }
Beispiel #5
0
        public static FileProcessorEndpoint ToEndpoint(this FileProcessorElement element)
        {
            var endpoint = new FileProcessorEndpoint
            {
                Name                   = element.Name,
                DropPath               = element.DropPath,
                InProgressPath         = element.InProgressPath,
                Filter                 = element.Filter,
                MonitorSubdirectories  = element.MonitorSubdirectories,
                ScavengeInterval       = new TimeSpan(0, 0, element.ScavengeInterval),
                RecoveryInterval       = new TimeSpan(0, 0, element.RecoveryInterval),
                PollingRestartInterval = new TimeSpan(0, 0, element.PollingInactivityRestartInterval),
                NumberOfConsumers      = element.Consumers,
                SuccessPath            = element.SuccessPath,
                FailurePath            = element.FailurePath,
                ProcessorConfigurator  = DetermineProcessorType(element),
                Handler                = element.Handler.ToType(),
                PostProcessor          = element.PostProcessor.ToType(),
                AdditionalFilter       = element.AdditionalFilter.ToType() ?? typeof(DefaultFileFilter)
            };

            return(endpoint);
        }
        public void ConvertProcessorElementWithCustomProcessor()
        {
            var element = new FileProcessorElement
            {
                Name = "a",
                DropPath = "b",
                Filter = "*",
                SuccessPath = "c",
                FailurePath = "d",
                InProgressPath = "e",
                ScavengeInterval = 100,
                RecoveryInterval = 100,
                ProcessorConfiguratorType = "EnergyTrading.UnitTest.FileProcessing.Configuration.ConfigurationExtensionsFixture+CustomFileProcessor, EnergyTrading.UnitTest",
                Handler = "EnergyTrading.UnitTest.FileProcessing.FileHandler, EnergyTrading.UnitTest"
            };

            var expected = new FileProcessorEndpoint
            {
                Name = "a",
                DropPath = "b",
                Filter = "*",
                SuccessPath = "c",
                FailurePath = "d",
                InProgressPath = "e",
                NumberOfConsumers = 1,
                ScavengeInterval = new TimeSpan(0, 0, 100),
                RecoveryInterval = new TimeSpan(0, 0, 100),
                ProcessorConfigurator = "EnergyTrading.UnitTest.FileProcessing.Configuration.ConfigurationExtensionsFixture+CustomFileProcessor, EnergyTrading.UnitTest",
                Handler = typeof(FileHandler),
                AdditionalFilter = typeof(DefaultFileFilter),
                PollingRestartInterval = new TimeSpan(0, 0, 60)
            };

            var candidate = element.ToEndpoint();
            this.Check(expected, candidate);
        }