示例#1
0
        public void RegisterTest()
        {
            IRegisterableLake lake = new SunsetLake();
            int time = 0;

            lake.Register <int>(() => time++);

            Assert.IsTrue((lake.Get <int>() - lake.Get <int>()) == -1);
        }
示例#2
0
        public void RegisterSingletonTest()
        {
            IRegisterableLake lake = new SunsetLake();

            lake.RegisterSingleton(typeof(int), () => 1);
            lake.RegisterSingleton <string>("test string");

            Assert.IsTrue(lake.Get <int>() == 1);
            Assert.IsTrue(lake.Get <string>() == "test string");
        }
        public void MainTest()
        {
            IRegisterableLake lake = new SunsetLake();

            new ClassComponentsLoader("AutumnBox.Tests.OpenFX.Leafx", lake).Do();
            Assert.IsTrue(lake.Get <F**k>().Yes());
        }
        public void FieldTest()
        {
            SunsetLake lake = new SunsetLake();

            lake.RegisterSingleton(FieldInjectTarget.TEST_STR_ID, () => FieldInjectTarget.TEST_STR);
            lake.RegisterSingleton <FieldInjectTarget, FieldInjectTarget>();
            var target = lake.Get <FieldInjectTarget>();

            Assert.IsTrue(target.IsAllRight());
        }
示例#5
0
        public void InjectingTest()
        {
            IRegisterableLake lake     = new SunsetLake();
            const int         TEST_SUM = 50;
            const string      TEST_STR = "test str";

            lake.RegisterSingleton("sum", () => TEST_SUM);
            lake.RegisterSingleton <string>(TEST_STR);
            lake.RegisterSingleton <InjectTestClass, InjectTestClass>();
            var testClass = lake.Get <InjectTestClass>();

            Assert.IsTrue(testClass.Sum == TEST_SUM);
            Assert.IsTrue(testClass.Str == TEST_STR);
        }
示例#6
0
        public void ObjectBuildTest()
        {
            const int         sum  = 5;
            const string      str  = "test string";
            IRegisterableLake lake = new SunsetLake();

            lake.RegisterSingleton <int>(sum);
            lake.RegisterSingleton <string>(str);
            lake.RegisterSingleton <ITestInterface, TestClass>();

            ITestInterface testInterfaceImpl = lake.Get <ITestInterface>();

            Assert.IsTrue(testInterfaceImpl.Str == str);
            Assert.IsTrue(testInterfaceImpl.Sum == sum);
        }