public void Resolve_IBaseWhenIsNotRegistered_ThrowException() { // Arrange ioc.Setup(i => i.IsRegistered <IBase>()).Returns(false); // Act var result = Labo.Resolve <IBase>(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); new SetUp().SetUP(); Application.Run(new CountersView(Labo.Resolve <IMessenger>(), Labo.ConstructByLongestArgs <CountersViewController>())); }
public void Resolve_IBaseWhenRegisteredIBaseWithBase_ResolveBase() { // Arrange ioc.Setup(i => i.IsRegistered(typeof(IBase))).Returns(true); ioc.Setup(i => i.GetSingleton(typeof(IBase))).Throws <IOCException>(); ioc.Setup(i => i.GetImplementType(typeof(IBase))).Returns(typeof(Base)); activator.Setup(a => a.ConstructByLongestArgs(typeof(Base))).Returns(new Base()); // Act var result = Labo.Resolve <IBase>(); // Assert Assert.AreEqual(typeof(Base), result.GetType()); }
public void Resolve_IBaseWhenRegisteredSingleton_ResolveSingletonBase() { // Arrange var single = new Base(); ioc.Setup(i => i.IsRegistered(typeof(IBase))).Returns(true); ioc.Setup(i => i.GetSingleton(typeof(IBase))).Returns(single); // Act var result = Labo.Resolve <IBase>(); // Assert Assert.AreEqual(single, result); }
static bool StartMainProcess(string baseSentenceFilePath, string keyValuePairFilePath, string destFilePath) { try { new Configuration.Setup(keyValuePairFilePath); IMainProcess mainProcess = Labo.Resolve<IMainProcess>(); var baseSentence = mainProcess.LoadBaseFile(baseSentenceFilePath); var formatKeyValuePairs = mainProcess.LoadFormatKeyValuePairs(); return mainProcess.SaveFormat(baseSentence, formatKeyValuePairs, destFilePath); } catch (Exception e) { Console.WriteLine(e.ToString()); return false; } }
void SetRepository(string keyValuePairsFilePath) { var configurtion = Labo.Resolve <IConfigurationSettings>(); IFormatKeyValuePairsRepository repository = null; if (configurtion.IsXmlMode) { repository = new FormatKeyValuePairsXmlRepository(keyValuePairsFilePath); } else { repository = new FormatKeyValuePairsRepository(keyValuePairsFilePath, Labo.Resolve <FormacchanLibrary.Services.IFormatKeyValuePairsService>(), configurtion); } Labo.RegisterSingleton <IFormatKeyValuePairsRepository>(repository); }
void RegisterSingleton() { Labo.RegisterSingleton <ICountersRepository>(new CountersTemporarilyRepository()); Labo.RegisterSingleton <IMessenger>(new MessageHub(Labo.Resolve <IPostsService>())); }