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); }); }
public void Setup() { Di.Bind <IBallController>() .AsSingleton <BallController>(); Di.Bind <IGameController>() .AsSingleton <GameController>(); Di.Bind <IMouseManagerController>() .AsSingleton <MouseManagerController>(); }
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)); }
public Score() { Di.Bind <IScore>().AsSingleton(this); }
void Start() { Di.Bind <IGameConfig>().AsSingleton(Configuration); }
public Game() { Di.Bind <IGame>().AsSingleton(this); }
public void Setup() { Di.Bind <ICleanup>().AsSingleton <Cleanup>(); }