Exemple #1
0
        public static IDisposable DoWorkContiniously(IRxnManager <IRxn> rxnManage, IObservable <StartUnitTest[]> unitTestToRun, Action fireStyle)
        {
            return(unitTestToRun.Select(tests =>
            {
                var stopFiringContiniously = rxnManage.CreateSubscription <CommandResult>()
                                             .Where(c => c.InResponseTo.Equals(tests[0].Id))
                                             .Select(_ => -- iteration)
                                             .If(e => e <= 0, _ =>
                {
                    if (_notUpdating)
                    {
                        CurrentThreadScheduler.Instance.Run(() => { fireStyle(); });
                    }
                })
                                             .Until();

                fireStyle();

                return stopFiringContiniously;
            })
                   .FinallyR(() =>
            {
                "Continuous mode is stopping".LogDebug();
            })
                   .Until());
        }
Exemple #2
0
        public static string DefaultReactorName = "default"; //i want to let users configure this, so no const

        public ReactorManager(IServiceCommandFactory cmdFactory, IRxnManager <IRxn> defaultReactorInputOutputStream, Func <string, Rxns.Interfaces.IReactor <IRxn> > reactorFactory, IRxnHistoryProvider eventHistory)
        {
            _rxnManager     = defaultReactorInputOutputStream;
            _reactorFactory = reactorFactory;
            _eventHistory   = eventHistory;

            //we want raw access to the eventManager, not via IrxnProcessor/IReactTo
            _rxnManager.CreateSubscription <StopReactor>().Do(r => StopReactor(r.Name)).Until().DisposedBy(this);
            _rxnManager.CreateSubscription <StartReactor>().Do(r => StartReactor(r.Name)).Until().DisposedBy(this);

            new DisposableAction(() =>
            {
                OnWarning("Shutting down. This usually should not happen!");
                Reactors.Values.ForEach(r =>
                {
                    r.Reactor.Dispose();
                });
            }).DisposedBy(this);
        }
Exemple #3
0
        public bfgTestArenaProgressHub(bfgTestArenaProgressView testArena, IHubContext <bfgTestArenaProgressHub> context, IAppCommandService cmdService, IRxnManager <IRxn> historyBuffer)
        {
            _testArena  = testArena;
            _context    = context;
            _cmdService = cmdService;

            if (!theBfg.Args.Contains("save"))
            {
                historyBuffer.CreateSubscription <ITestDomainEvent>().Do(_testStream).Until();
            }
        }
Exemple #4
0
        public IObservable <UnitTestResult> DoWork(StartUnitTest work)
        {
            //setup the command to call back to us
            //and setup the client to run the downloaded version
            //instead of the original target existing on the machine (local fire)
            work.AppStatusUrl = $"http://{RxnApp.GetIpAddress()}:888";
            var workDll = new FileInfo(work.Dll);

            work.Dll = Path.Combine(theBfg.GetTestSuiteDir(work), workDll.Name).AsCrossPlatformPath();


            return(WhenUpdateExists(work)
                   .SelectMany(u =>
            {
                //send the command to the worker to run the test
                _appCmds.Add(work.AsQuestion(Route));

                //wait for the test response
                return _repsonseChannel.CreateSubscription <UnitTestResult>()
                .Where(c => c.InResponseTo == work.Id)
                .FirstOrDefaultAsync()
                .FinallyR(() => { _isBusy.OnNext(false); });
            }));
        }
Exemple #5
0
        /// <summary>
        /// Pairs this reactor with an rxn manager. The rxn manager is the parent in the relationship,
        /// anythign observed over its subscription is piped as input into the reactors world. The output
        ///
        /// </summary>
        /// <param name="rxnManager"></param>
        /// <param name="input"></param>
        /// <param name="output"></param>
        /// <returns></returns>
        public IDisposable Chain(IRxnManager <IRxn> rxnManager, IScheduler input = null, IScheduler output = null)
        {
            var @out = output == null ? Output : Output.ObserveOn(output);
            var @in  = rxnManager.CreateSubscription <TEvent>();

            @in = input == null ? @in : @in.ObserveOn(input);

            var inChannel  = @in.Subscribe(e => Input.OnNext(e), OnError);
            var outChannel = @out.Subscribe(rxnManager.Publish, OnError);

            _molecules.Add(rxnManager);

            OnInformation("Chained to '{0}'", rxnManager.GetType().Name);

            return(new CompositeDisposable(inChannel, outChannel, new DisposableAction(() =>
            {
                OnInformation("Unchained '{0}'", rxnManager.GetType().Name);
                _molecules.Remove(rxnManager);
            }))
                   .DisposedBy(_resources));
        }
Exemple #6
0
        public static IDisposable WatchForCompletion(IRxnManager <IRxn> rxnManage, IObservable <StartUnitTest[]> unitTestToRun, Action onComplete)
        {
            return(unitTestToRun.Select(tests =>
            {
                var stopDOingWork = rxnManage.CreateSubscription <CommandResult>()
                                    .Where(_ => unitTestToRun != null)
                                    .Where(c => c.InResponseTo.BasicallyEquals(tests[0].Id)) //todo this this, should look at all unit tests
                                    .Do(_ =>
                {
                    $"Duration: {startedAt.Elapsed}".LogDebug();

                    if (iteration <= 0)
                    {
                        onComplete?.Invoke();
                    }
                })
                                    .Until();

                return stopDOingWork;
            })
                   .Until());
        }
Exemple #7
0
 public AssertionFilter(IAppNav <Page, IRxnPageModel> appNav, IRxnManager <IRxn> eventManager)
 {
     _appNav = appNav;
     eventManager.CreateSubscription <ShakeGesture>().Do(_ => eventManager.Publish(new AssertModel(Snapshot(_appNav.Current.Model)))).Until();
 }
Exemple #8
0
 public static void WatchForTestUpdates(IRxnManager <IRxn> rxnManage)
 {
     rxnManage.CreateSubscription <UpdateSystemCommand>()
     .Do(_ => { _notUpdating = false; })
     .Until();
 }