Example #1
0
        public Fixture(IServiceProvider services = null)
        {
            var proxifier = new Func <AbstractKey, IGrain>(
                key => (IGrain)GrainProxy.Proxify(this, key));                    //just needs dispatcher and serializer

            Exceptions   = new ExceptionSink();
            Scheduler    = new FixtureScheduler(Exceptions);
            Serializer   = new FakeSerializer(proxifier);
            Types        = new TypeMap();
            GrainFactory = new FakeGrainFactory(Types, proxifier);
            Requests     = new RequestRunner(Scheduler, Exceptions);
            Services     = new ServiceRegistry(services);
            Stores       = new StorageRegistry(Serializer);
            Providers    = new ProviderRegistry(() => new ProviderRuntimeAdaptor(GrainFactory, Services, null));

            Reminders = new ReminderRegistry(this);

            Placer = new Placer(Types.GetConcreteType);

            Activations = null;

            var activationHub = new ActivationHub(place => {
                var actSite = new ActivationSite(p => new Activation_New(this, p).Dispatcher);                             //!!!
                actSite.Init(place);
                return(actSite);
            });

            Placer = new Placer(Types.GetConcreteType);

            Dispatcher = new Dispatcher(Placer.Place, activationHub);
            Streams    = new StreamRegistry(activationHub, Exceptions, Types);
        }
        public void SetUp()
        {
            _placement = CreatePlacement();

            _dispFac = (_) => {
                //var act = Substitute.For<IActivation>();
                var disp = Substitute.For <IActivationDispatcher>();

                //act.Dispatcher.Returns(disp);

                disp.Perform(Arg.Any <Func <IGrainContext, Task <IActivation> > >(), Arg.Any <RequestMode>())
                .Returns(c => c.Arg <Func <IGrainContext, Task <IActivation> > >()(null)); //NEED CONTEXT SPECIFYING!!!

                return(disp);
                //return act;
            };

            _siteFac = Substitute.For <Func <Placement, IActivationSite> >();
            _siteFac(Arg.Any <Placement>())
            .Returns(_ => new ActivationSite(_dispFac));     //reliant on ActivationSite

            _hub = new ActivationHub(_siteFac);
        }