コード例 #1
0
        public void Setup()
        {
            Di.Bind <IDebug>().AsSingleton(typeof(DiDebug));



            Di.Bind <GameObject>().AsConversion <IGameObject>((o) =>
            {
                var go = (IGameObject)o;
                return(go.GameObject);
            });

            Di.Bind <IGameObject>().AsConversion <GameObject>((o) =>
            {
                return(new DiGameObject()
                {
                    GameObject = (GameObject)o
                });
            });

            Di.Bind <IMaterial>().AsConversion <Material>((o) =>
            {
                return(new DiMaterial()
                {
                    Material = (Material)o
                });
            });

            Di.Bind <Material>().AsConversion <IMaterial>((o) =>
            {
                var m = (IMaterial)o;
                return(m.Material);
            });
        }
コード例 #2
0
ファイル: DiBindings.cs プロジェクト: xyicheng/UnitySOLID
 public void Setup()
 {
     Di.Bind <IBallController>()
     .AsSingleton <BallController>();
     Di.Bind <IGameController>()
     .AsSingleton <GameController>();
     Di.Bind <IMouseManagerController>()
     .AsSingleton <MouseManagerController>();
 }
コード例 #3
0
        public void StartReaction_GivenRedBallWithAnotherRedBall_WillTriggerTwice()
        {
            // Arrange
            var moqGameController = new Mock <IGameController>();
            var moqBallList       = BallHelper.CreateMoqBallList(10);

            moqBallList = moqBallList.SetPositionsInRow(distance: 1f);
            moqBallList = moqBallList.SetAllMaterialNames("red");
            moqBallList[0].SetupGet(x => x.MaterialName).Returns("blue");
            moqBallList[1].SetupGet(x => x.MaterialName).Returns("blue");
            var moqFade = new Mock <IFadeReactor>();

            moqFade.Setup(x => x.ActivateDestructionIn(It.IsAny <float>()));
            moqBallList.SetReactorCommands(fade: moqFade);
            var ballList = moqBallList.CreateBallList();

            moqGameController.SetupGet(x => x.BallCollection).Returns(ballList);
            Di.Bind <IGameController>().AsSingleton(moqGameController.Object);

            var moqGameConfig = new Mock <IGameConfig>();

            moqGameConfig.SetupGet(x => x.BallTouchRange).Returns(1.5f);
            moqGameConfig.SetupGet(x => x.CountMultiplier).Returns(1.01f);
            moqGameConfig.SetupGet(x => x.ScorePerBall).Returns(1);
            moqGameConfig.SetupGet(x => x.TimeBetweenReactions).Returns(0.02f);
            moqGameConfig.Setup(x => x.GetReactor()).Returns(ReactorTypes.Fade);
            Di.Bind <IGameConfig>().AsSingleton(moqGameConfig.Object);

            var moqScore = new Mock <IScore>();

            moqScore.SetupAllProperties();
            Di.Bind <IScore>().AsSingleton(moqScore.Object);

            var ballController = Di.Get <IBallController>();

            // Act
            ballController.StartReaction(ballList[0]);

            // Assert
            moqFade.Verify(x => x.ActivateDestructionIn(It.IsAny <float>()), Times.Exactly(2));
        }
コード例 #4
0
ファイル: ScoreView.cs プロジェクト: xyicheng/UnitySOLID
 public Score()
 {
     Di.Bind <IScore>().AsSingleton(this);
 }
コード例 #5
0
 void Start()
 {
     Di.Bind <IGameConfig>().AsSingleton(Configuration);
 }
コード例 #6
0
 public Game()
 {
     Di.Bind <IGame>().AsSingleton(this);
 }
コード例 #7
0
ファイル: DiBindings.cs プロジェクト: xyicheng/UnitySOLID
 public void Setup()
 {
     Di.Bind <ICleanup>().AsSingleton <Cleanup>();
 }