Пример #1
0
        public void TestGetOptimalRatings()
        {
            var dataMock           = new Mock <IDbDataService <IData> >();
            var brksWithRatings    = MockData.GetDefaultBreaks();
            var expectedOutput     = MockData.GetBreaksWithOrderedCommercials();
            var defaultCommercials = MockData.GetDefaultCommercials();

            dataMock.Setup(p => p.GetItems <Commercial>()).Returns(Task.FromResult(defaultCommercials));
            var service = new ProcessingService(dataMock.Object);
            var result  = service.GetOptimalRatings(brksWithRatings).Result;

            for (int i = 0; i < expectedOutput.Count; i++)
            {
                Assert.Equal(expectedOutput.ElementAt(i).Id, result.ElementAt(i).Id);
                Assert.Equal(expectedOutput.ElementAt(i).Commercials.Count, result.ElementAt(i).Commercials.Count);
                for (int j = 0; j < expectedOutput.ElementAt(i).Commercials.Count; j++)
                {
                    Assert.Equal(expectedOutput.ElementAt(i).Commercials.ElementAt(j).Id, result.ElementAt(i).Commercials.ElementAt(j).Id);
                    Assert.Equal(expectedOutput.ElementAt(i).Commercials.ElementAt(j).TargetDemo, result.ElementAt(i).Commercials.ElementAt(j).TargetDemo);
                    Assert.Equal(expectedOutput.ElementAt(i).Commercials.ElementAt(j).CommercialType, result.ElementAt(i).Commercials.ElementAt(j).CommercialType);
                    Assert.Equal(expectedOutput.ElementAt(i).Commercials.ElementAt(j).TargetDemoName, result.ElementAt(i).Commercials.ElementAt(j).TargetDemoName);
                }
            }
            Assert.Equal(expectedOutput.ElementAt(1).DisallowedCommTypes.Count, result.ElementAt(1).DisallowedCommTypes.Count);
            Assert.Equal(1970, result.Sum(d => d?.Commercials?.Sum(p => p.CurrentRating.Score)));
        }
Пример #2
0
 public void LoadEncoders()
 {
     if (!string.IsNullOrEmpty(ToolsPath))
     {
         ProcessingService.GetAppVersions(ToolsPath, JavaInstallPath);
     }
 }
Пример #3
0
 public Main()
 {
     InitializeComponent();
     logger    = new Logger(logBox);
     inputData = InitializeInputData();
     InitializeCancellationToken();
     processingService = new ProcessingService(outputImageBox, logger);
 }
Пример #4
0
        public void TestGetBestBreak()
        {
            var unordered  = MockData.GetDefaultBreaks();
            var commercial = MockData.GetDefaultCommercials().ElementAt(3);
            var service    = new ProcessingService(null);
            var br         = service.GetBestBreak(unordered, commercial);

            Assert.NotNull(br);
            Assert.Equal(3, br.Id);
        }
Пример #5
0
        public ProcessingServiceTests()
        {
            //LogManager.OutputToTrace();
            _storage   = Substitute.For <IStoreUnhandledMessages>();
            _processor = Substitute.For <IProcessMessage>();
            _errors    = Substitute.For <IFailedMessagesQueue>();

            _sut = new ProcessingService(_storage, () => _processor, new BusAuditor(new InMemoryAuditStorage()), _errors);
            _sut.PollingEnabled = false;
            _sut.Start();
        }
Пример #6
0
        public void Parse_DoesntGetParsedRecords_ReturnsZero()
        {
            List <List <string> > buffer = Arg.Any <List <List <string> > >();

            _cifProcessor.ProcessBatch(default(IEnumerable <IEnumerable <string> >), default(int), default(ScheduleType)
                                       , default(BatchArgs)).ReturnsForAnyArgs(0);

            ProcessingService sut = new ProcessingService(_cifProcessor, _outputWriter, _fileSystem);

            long returnVal = sut.Process("foo", "bar", 10, "bundy", null);

            Assert.Equal(0, returnVal);
        }
Пример #7
0
        public void Parse_DoesntGetParsedRecords_DoesntWriteRecords()
        {
            List <List <string> > buffer = Arg.Any <List <List <string> > >();

            _cifProcessor.ProcessBatch(default(IEnumerable <IEnumerable <string> >), default(int), default(ScheduleType),
                                       default(BatchArgs)).ReturnsForAnyArgs(0);

            ProcessingService sut = new ProcessingService(_cifProcessor, _outputWriter, _fileSystem);

            sut.Process("foo", "bar", 10, "bundy", null);

            _outputWriter.DidNotReceiveWithAnyArgs()
            .Write(default(IEnumerable <IEnumerable <string> >));
        }
Пример #8
0
        static void Main(string[] args)
        {
            var taskReadConsole = Task.Factory.StartNew(() =>
            {
                while (Console.ReadLine() != "X")
                {
                }
            }, TaskCreationOptions.LongRunning);


            var mongoUrls = new List <string>()
            {
                "mongodb://192.168.100.184:27017",
                // "mongodb://localhost:5555",
            };

            var mongoDefs = mongoUrls.Select(x => new DataNodeDefinition(new Uri(x))).ToArray();

            ProcessingService service = null;

            try
            {
                service = new ProcessingService(new ComputerNameAndProcessIdUnitIdProvider(TimeSpan.FromSeconds(30)), new List <IProcessorManager>()
                {
                    new TestProcessorManager(),
                }, new ProcessingSettings
                {
                    DataNodes                     = mongoDefs,
                    PcdConnectionString           = "test",
                    JobLeaseLifeTime              = TimeSpan.FromMinutes(20),
                    DeleteProcessedRecordsTimeout = Debugger.IsAttached ? (TimeSpan?)TimeSpan.FromSeconds(12) : null,
                    ReservationRangeLimits        = new ReservationRangeLimits
                    {
                        Min = 200,
                        Max = 300
                    },
                    LoadedInMemoryBinaryPartsBatchSize = 20,
                    PacketsLifeTime = TimeSpan.FromDays(7),
                });

                service.OnCreate();
                service.OnStart();
                taskReadConsole.Wait();
            }
            finally
            {
                service?.OnStop();
            }
        }
Пример #9
0
        internal EndpointConfig[] Build(ConfigureHost host, IContainerScope container, BusAuditor auditor)
        => _points.Select(ec =>
        {
            var ep    = ec.Key;
            var nexus = new MessageHandlersNexus(container, auditor, host);
            nexus.Add(host.Handlers.Where(ep.CanHandle).ToArray());
            var relayer   = new RelayLocalEvents(host.Relayer);
            var processor = new ProcessingService(host.GetStorage <IStoreUnhandledMessages>(), () => new MessageProcessor(nexus, relayer), auditor, host.GetStorage <IFailedMessagesQueue>());
            ec.Value(processor);

            var config = new EndpointConfig(processor);
            config.Id  = new EndpointId(ep.Name, host.HostName);
            config.HandledMessagesTypes = nexus.GetMessageTypes().ToArray();
            processor.Name = config.Id;
            return(config);
        }).ToArray();
Пример #10
0
        public void Parse_GetsParsedRecords_ReturnsRecordCount()
        {
            const int RecordCount = 3;

            Stack <int> returnStack = new Stack <int>();

            returnStack.Push(0);
            returnStack.Push(RecordCount);

            _cifProcessor.ProcessBatch(default(IEnumerable <IEnumerable <string> >), default(int), default(ScheduleType)
                                       , default(BatchArgs)).ReturnsForAnyArgs(x => { return(returnStack.Pop()); });

            ProcessingService sut = new ProcessingService(_cifProcessor, _outputWriter, _fileSystem);

            long returnVal = sut.Process("foo", "bar", 10, "bundy", null);

            Assert.Equal(RecordCount, returnVal);
        }
Пример #11
0
        public void TestOrderCommercials()
        {
            var dataMock  = new Mock <IDbDataService <IData> >();
            var unordered = MockData.GetBreaksWithUnorderedCommercials();
            var ordered   = MockData.GetBreaksWithOrderedCommercials();
            var service   = new ProcessingService(dataMock.Object);
            var result    = service.OrderCommercials(unordered);


            for (int i = 0; i < ordered.Count; i++)
            {
                Assert.Equal(ordered.ElementAt(i).Id, result.ElementAt(i).Id);
                Assert.Equal(ordered.ElementAt(i).Commercials.Count, result.ElementAt(i).Commercials.Count);
                for (int j = 0; j < ordered.ElementAt(i).Commercials.Count; j++)
                {
                    Assert.Equal(ordered.ElementAt(i).Commercials.ElementAt(j).CommercialType, result.ElementAt(i).Commercials.ElementAt(j).CommercialType);
                    Assert.Equal(ordered.ElementAt(i).Commercials.ElementAt(j).CommercialType, result.ElementAt(i).Commercials.ElementAt(j).CommercialType);
                    Assert.Equal(ordered.ElementAt(i).Commercials.ElementAt(j).CommercialType, result.ElementAt(i).Commercials.ElementAt(j).CommercialType);
                }
            }
        }
Пример #12
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Enter contract data");
                Console.Write("Number: ");
                int number = int.Parse(Console.ReadLine());
                Console.Write("Date: ");
                DateTime date = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
                Console.Write("Contract Value: ");
                double totalValue = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.Write("Enter number of installments: ");
                int numberOfInstallments = int.Parse(Console.ReadLine());
                if (numberOfInstallments < 1)
                {
                    throw new DomainException("Número de parcelas deve ser maior ou igual a 1");
                }
                else
                {
                    Contract          contract          = new Contract(number, date, totalValue);
                    ProcessingService processingService = new ProcessingService(new PayPalService());

                    processingService.ProcessContract(contract, numberOfInstallments);

                    Console.WriteLine(contract);
                }
            }
            catch (DomainException e)
            {
                Console.WriteLine("Error: " + e.Message);
            }
            catch (FormatException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Пример #13
0
        public TaskBarProgressTracker()
        {
            ProcessingService processingService = Ioc.Get <ProcessingService>();
            MainViewModel     mainViewModel     = Ioc.Get <MainViewModel>();

            // Set up some observables for properties we care about.
            var isEncodingObservable = processingService
                                       .WhenAnyValue(x => x.EncodeProgress)
                                       .Select(encodeProgress => encodeProgress != null && encodeProgress.Encoding);

            var encodeProgressFractionObservable = processingService
                                                   .WhenAnyValue(x => x.EncodeProgress)
                                                   .Select(encodeProgress => encodeProgress == null ? 0 : encodeProgress.OverallProgressFraction);

            var isEncodePausedObservable       = processingService.WhenAnyValue(x => x.Paused);
            var videoSourceStateObservable     = mainViewModel.WhenAnyValue(x => x.VideoSourceState);
            var scanProgressFractionObservable = mainViewModel.WhenAnyValue(x => x.ScanProgressFraction);

            // Set up output properties
            Observable.CombineLatest(
                isEncodingObservable,
                encodeProgressFractionObservable,
                videoSourceStateObservable,
                scanProgressFractionObservable,
                (isEncoding, encodeProgressFraction, videoSourceState, scanProgressFraction) =>
            {
                if (isEncoding)
                {
                    return(encodeProgressFraction);
                }
                else if (videoSourceState == VideoSourceState.Scanning)
                {
                    return(scanProgressFraction);
                }
                else
                {
                    return(0);
                }
            }).ToProperty(this, x => x.ProgressFraction, out this.progressFraction);

            Observable.CombineLatest(
                isEncodingObservable,
                isEncodePausedObservable,
                videoSourceStateObservable,
                (isEncoding, isEncodePaused, videoSourceState) =>
            {
                if (isEncoding)
                {
                    if (isEncodePaused)
                    {
                        return(TaskbarItemProgressState.Paused);
                    }
                    else
                    {
                        return(TaskbarItemProgressState.Normal);
                    }
                }
                else if (videoSourceState == VideoSourceState.Scanning)
                {
                    return(TaskbarItemProgressState.Normal);
                }
                else
                {
                    return(TaskbarItemProgressState.None);
                }
            }).ToProperty(this, x => x.ProgressState, out this.progressState);
        }
Пример #14
0
 public ProcessingServiceTests()
 {
     this.mocker            = new AutoMocker();
     this.processingService = this.mocker.CreateInstance <ProcessingService>();
 }
Пример #15
0
 public HomeController(ProcessingService service)
 {
     processingService = service;
 }
Пример #16
0
        public EncodeDetailsWindowViewModel()
        {
            ProcessingService processingService = Ioc.Get <ProcessingService>();

            this.progressObservable = processingService.WhenAnyValue(x => x.EncodeProgress);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.OverallProgressFraction * 100)
            .ToProperty(this, x => x.OverallProgressPercent, out this.overallProgressPercent);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.TaskNumber + "/" + encodeProgress.TotalTasks)
            .ToProperty(this, x => x.TaskNumberDisplay, out this.taskNumberDisplay);

            this.GetPropertyWatcher(encodeProgress => Utilities.FormatTimeSpan(encodeProgress.OverallElapsedTime))
            .ToProperty(this, x => x.OverallElapsedTime, out this.overallElapsedTime);

            this.GetPropertyWatcher(encodeProgress => Utilities.FormatTimeSpan(encodeProgress.OverallEta))
            .ToProperty(this, x => x.OverallEta, out this.overallEta);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.FileName)
            .ToProperty(this, x => x.FileName, out this.fileName);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.FileProgressFraction * 100)
            .ToProperty(this, x => x.FileProgressPercent, out this.fileProgressPercent);

            this.GetPropertyWatcher(encodeProgress => Utilities.FormatFileSize(encodeProgress.FileSizeBytes))
            .ToProperty(this, x => x.FileSize, out this.fileSize);

            this.GetPropertyWatcher(encodeProgress => Utilities.FormatTimeSpan(encodeProgress.FileElapsedTime))
            .ToProperty(this, x => x.FileElapsedTime, out this.fileElapsedTime);

            this.GetPropertyWatcher(encodeProgress => Utilities.FormatTimeSpan(encodeProgress.FileEta))
            .ToProperty(this, x => x.FileEta, out this.fileEta);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.CurrentFps)
            .ToProperty(this, x => x.CurrentFps, out this.currentFps);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.AverageFps)
            .ToProperty(this, x => x.AverageFps, out this.averageFps);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.HasScanPass || encodeProgress.TwoPass)
            .ToProperty(this, x => x.ShowPassProgress, out this.showPassProgress);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.PassProgressFraction * 100)
            .ToProperty(this, x => x.PassProgressPercent, out this.passProgressPercent);

            this.GetPropertyWatcher(encodeProgress =>
            {
                switch (encodeProgress.CurrentPassId)
                {
                case -1:
                    return(EncodeDetailsRes.ScanPassLabel);

                case 0:
                    return(EncodeDetailsRes.EncodePassLabel);

                case 1:
                    return(EncodeDetailsRes.FirstPassLabel);

                case 2:
                    return(EncodeDetailsRes.SecondPassLabel);

                default:
                    return(null);
                }
            }).ToProperty(this, x => x.PassProgressLabel, out this.passProgressLabel);
        }
Пример #17
0
 public EndpointConfig(ProcessingService queue)
 {
     _queue = queue;
 }