示例#1
0
 public void Resolve_IBaseWhenIsNotRegistered_ThrowException()
 {
     // Arrange
     ioc.Setup(i => i.IsRegistered <IBase>()).Returns(false);
     // Act
     var result = Labo.Resolve <IBase>();
 }
示例#2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            new SetUp().SetUP();
            Application.Run(new CountersView(Labo.Resolve <IMessenger>(), Labo.ConstructByLongestArgs <CountersViewController>()));
        }
示例#3
0
        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());
        }
示例#4
0
        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);
        }
示例#5
0
        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;
            }
        }
示例#6
0
        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);
        }
示例#7
0
 void RegisterSingleton()
 {
     Labo.RegisterSingleton <ICountersRepository>(new CountersTemporarilyRepository());
     Labo.RegisterSingleton <IMessenger>(new MessageHub(Labo.Resolve <IPostsService>()));
 }