Esempio n. 1
0
        public void testMapBindsIApplicationToApplicationWrapperAsASingleton()
        {
            var mockBinder  = Substitute.For <ICrossContextInjectionBinder>();
            var fakeContext = new MVCSContext();

            fakeContext.injectionBinder = mockBinder;

            var mockBinding = Substitute.For <IInjectionBinding>();

            mockBinder.Bind <IApplication>().Returns(mockBinding);
            mockBinder.Bind <IResources>().Returns(mockBinding);
            mockBinder.Bind <IGameObject>().Returns(mockBinding);

            var mockFinalBinding = Substitute.For <IInjectionBinding>();

            mockBinding.To <ApplicationWrapper>().Returns(mockFinalBinding);

            _instance.Setup(fakeContext);

            mockBinder.Received().Bind <IApplication>();
            mockBinding.Received().To <ApplicationWrapper>();

            mockBinder.Received().Bind <IResources>();
            mockBinding.Received().To <ResourcesWrapper>();

            mockBinder.Received().Bind <IGameObject>();
            mockBinding.Received().To <GameObjectWrapper>();
            mockFinalBinding.Received().ToSingleton();
        }
        public void testMapBindsIApplicationToApplicationWrapperAsASingleton()
        {
            var mockBinder = Substitute.For<ICrossContextInjectionBinder>();
            var fakeContext = new MVCSContext();
            fakeContext.injectionBinder = mockBinder;

            var mockBinding = Substitute.For<IInjectionBinding>();
            mockBinder.Bind<IApplication>().Returns( mockBinding );
            mockBinder.Bind<IResources>().Returns( mockBinding );
            mockBinder.Bind<IGameObject>().Returns( mockBinding );

            var mockFinalBinding = Substitute.For<IInjectionBinding>();
            mockBinding.To<ApplicationWrapper>().Returns(mockFinalBinding);

            _instance.Setup( fakeContext );

            mockBinder.Received().Bind<IApplication>();
            mockBinding.Received().To<ApplicationWrapper>();

            mockBinder.Received().Bind<IResources>();
            mockBinding.Received().To<ResourcesWrapper>();

            mockBinder.Received().Bind<IGameObject>();
            mockBinding.Received().To<GameObjectWrapper>();
            mockFinalBinding.Received().ToSingleton();
        }
 private void mapAllWithImplicitBinder( MVCSContext context )
 {
     string[] namespacesToBind = new string[]
     {
         "reversi.game"
     };
     context.implicitBinder.ScanForAnnotatedClasses(namespacesToBind);
 }
 private void mapAllWithImplicitBinder(MVCSContext context)
 {
     string[] namespacesToBind = new string[]
     {
         "reversi.game"
     };
     context.implicitBinder.ScanForAnnotatedClasses(namespacesToBind);
 }
 public void Execute(MVCSContext context)
 {
     foreach (Action <MVCSContext> action in _mapContextList)
     {
         action(context);
     }
     _mapContextList.Clear();
 }
        internal static void PostBindings(MVCSContext context)
        {
            var contextView = (context.contextView as GameObject);
            var camera = contextView.GetComponentInChildren<UnityEngine.Camera>();
            context.injectionBinder.Bind<UnityEngine.Camera>().ToValue(camera);

            var configs = contextView.GetComponentInChildren<GameConfigs>();
            context.injectionBinder.Bind<GameConfigs>().ToValue(configs);
        }
        internal static void PostBindings(MVCSContext context)
        {
            var contextView = (context.contextView as GameObject);
            var camera      = contextView.GetComponentInChildren <UnityEngine.Camera>();

            context.injectionBinder.Bind <UnityEngine.Camera>().ToValue(camera);

            var configs = contextView.GetComponentInChildren <GameConfigs>();

            context.injectionBinder.Bind <GameConfigs>().ToValue(configs);
        }
Esempio n. 8
0
        //public void MapEventBindingsOnto(MVCSContext c) {
        //    UsingSignals = false;

        //    c.injectionBinder.Bind<IMenuModel>().To<MenuModel>().ToSingleton();

        //    c.commandBinder.Bind(ContextEvent.START).To<StartMenuCommand>().Once();
        //    c.commandBinder.Bind(MenuEvent.OpenMenu).To<OpenMenuCommand>();
        //    c.commandBinder.Bind(MenuEvent.CloseMenu).To<CloseMenuCommand>();
        //    c.commandBinder.Bind(MenuEvent.CloseTopMenu).To<CloseTopMenuCommand>();
        //    c.commandBinder.Bind(MenuEvent.Back).To<BackMenuCommand>();

        //}

        public void MapBindingsOnto(MVCSContext c)
        {
            c.injectionBinder.Bind <IMenuModel>().To <MenuModel>().ToSingleton();

            c.commandBinder.Bind(ContextEvent.START).To <StartMenuCommand>().Once();
            c.commandBinder.Bind <OpenMenuSignal>().To <OpenMenuCommand>();
            c.commandBinder.Bind <CloseMenuSignal>().To <CloseMenuCommand>();
            c.commandBinder.Bind <CloseTopMenuSignal>().To <CloseTopMenuCommand>();
            c.commandBinder.Bind <MenuBackSignal>().To <BackMenuCommand>();

            c.injectionBinder.Rebind <MenuSystemReadySignal>().ToSingleton();
        }
        internal static void MapBindings(MVCSContext context)
        {
            //Commands & Signals
            context.commandBinder.Bind <GameStartSignal>().To <GameStartCommand>();

            //Singleton signals
            //injectionBinder.Bind<PlayerMovedSignal>().ToSingleton();

            //Models
            //injectionBinder.Bind<IPlayer>().To<Player>().ToSingleton();

            //Mediation
            //mediationBinder.Bind<LevelSceneView>().To<LevelSceneMediator>();

            //Services
            //injectionBinder.Bind<ILevelGenerator>().To<SpecificLevelGenerator>();
        }
        internal static void MapBindings(MVCSContext context)
        {
            //Commands & Signals
            context.commandBinder.Bind<GameStartSignal>().To<GameStartCommand>();

            //Singleton signals
            //injectionBinder.Bind<PlayerMovedSignal>().ToSingleton();

            //Models
            //injectionBinder.Bind<IPlayer>().To<Player>().ToSingleton();

            //Mediation
            //mediationBinder.Bind<LevelSceneView>().To<LevelSceneMediator>();

            //Services
            //injectionBinder.Bind<ILevelGenerator>().To<SpecificLevelGenerator>();
        }
 private void mapCommands(MVCSContext context)
 {
     context.commandBinder.Bind <CreateGridSpacesSignal> ().To <CreateGridSpacesCommand> ();
 }
 public void Setup( MVCSContext context )
 {
     context.injectionBinder.Bind<IApplication> ().To<ApplicationWrapper>().ToSingleton ().CrossContext();
     context.injectionBinder.Bind<IResources> ().To<ResourcesWrapper>().ToSingleton ().CrossContext();
     context.injectionBinder.Bind<IGameObject> ().To<GameObjectWrapper>().ToSingleton ().CrossContext();
 }
 public void Setup(MVCSContext context)
 {
     context.injectionBinder.Bind <IApplication> ().To <ApplicationWrapper>().ToSingleton().CrossContext();
     context.injectionBinder.Bind <IResources> ().To <ResourcesWrapper>().ToSingleton().CrossContext();
     context.injectionBinder.Bind <IGameObject> ().To <GameObjectWrapper>().ToSingleton().CrossContext();
 }
 private void mapCommands( MVCSContext context )
 {
     context.commandBinder.Bind<CreateGridSpacesSignal> ().To<CreateGridSpacesCommand> ();
 }
 public static void Setup(MVCSContext context)
 {
     context.injectionBinder.Unbind <ICommandBinder> ();
     context.injectionBinder.Bind <ICommandBinder> ().To <SignalCommandBinder> ().ToSingleton();
 }