get; } } public class UserCharacterData { private int characterId; private int level; // キャラの最大HPの取得 public int GetMaxHp(){ var masterData = MasterDataManager .Instance .GetMasterCharacterById(characterId); // マスタが持ってるHPにレベルで補正がかかる的なやつ return masterData.Hp * level; } }
class MasterDataManager : IMasterDataManager { public MasterCharacter GetMasterCharacterById(int id) {} } public class UserCharacterData { [Inject] private IMasterManager manager; private int characterId; private int level; public int GetMaxHp() { var masterData = manager .GetMasterCharacterById(characterId); return masterData.Hp * level;
master = new MasterCharacter(); var mock = new Mock<IMasterDataManager>(); mock.Setup(m => m.GetMasterCharacterById(1)) .Returns(master); Container.BindInstance(mock.Object);