示例#1
0
        public void InterceptsAction()
        {
            var kernel = new DefaultKernel <CompositionRoot>();

            kernel.Initialize();
            kernel.AddAction <CustomAction>(typeof(CustomAction).FullName);
            Assert.ThrowsException <ActionException>(()
                                                     => kernel.Proxy.Invoke <CustomAction>("")
                                                     );
        }
示例#2
0
        public void ActionReturnsValue()
        {
            var kernel = new DefaultKernel <CompositionRoot>();

            kernel.Initialize();
            kernel.AddAction <CustomAction3>(typeof(CustomAction3).FullName);

            var value = Guid.NewGuid().ToString();

            Assert.AreEqual(value, kernel.Proxy.Invoke <CustomAction3>(value));
        }
示例#3
0
        public void CanDelayActions(int minProcessingTime)
        {
            var kernel = new DefaultKernel <CompositionRoot>();

            kernel.Initialize();
            kernel.AddAction <CustomAction3>(typeof(CustomAction3).FullName);
            var configuration = kernel
                                .Get <IConfigurationProvider>("")
                                .Get(CoreConfiguration.Default);

            configuration.DelayerTime = TimeSpan.FromMilliseconds(minProcessingTime);

            var watch = Stopwatch.StartNew();
            var value = Guid.NewGuid().ToString();

            Assert.AreEqual(value, kernel.Proxy.Invoke <CustomAction3>(value));
            Assert.IsTrue(watch.ElapsedMilliseconds > minProcessingTime);
        }