public VehicleActor(ActorService actorService, ActorId actorId, IActorFactory actorFactory,
                     IServiceFactory serviceFactory, IVehiclesServiceProxy vehiclesServiceProxy)
     : base(actorService, actorId, actorFactory, serviceFactory)
 {
     if (vehiclesServiceProxy == null)
     {
         this.vehiclesServiceProxy = VehiclesServiceProxy.Instance;
     }
     else
     {
         this.vehiclesServiceProxy = vehiclesServiceProxy;
     }
 }
예제 #2
0
        internal static async Task <VehicleActor.VehicleActor> CreateVehicleActorAsync(ActorId id, IActorFactory actorFactory = null,
                                                                                       IServiceFactory serviceFactory         = null, IVehiclesServiceProxy vehiclesServiceProxy = null,
                                                                                       bool invokeOnActivate = true)
        {
            if (actorFactory == null)
            {
                actorFactory = new Mock <IActorFactory>().Object;
            }
            if (serviceFactory == null)
            {
                serviceFactory = new Mock <IServiceFactory>().Object;
            }
            if (vehiclesServiceProxy == null)
            {
                vehiclesServiceProxy = new Mock <IVehiclesServiceProxy>().Object;
            }

            Func <ActorService, ActorId, ActorBase> factory =
                (service, actorId) => new VehicleActor.VehicleActor(service, id, actorFactory, serviceFactory, vehiclesServiceProxy);

            var svc = MockActorServiceFactory.CreateActorServiceForActor <VehicleActor.VehicleActor>(factory);

            var actor = svc.Activate(id);

            if (invokeOnActivate)
            {
                await actor.InvokeOnActivateAsync();
            }

            return(actor);
        }