Пример #1
0
        public void TypeRegistration_ResolvesToHasNoCtor()
        {
            Console.WriteLine("*********** Timer CONTAINER CREATE Start ***********");
            var timer = Stopwatch.StartNew();



            //arrange
            var container = new FlyIoCContainer();



            timer.Stop();
            Console.WriteLine(timer.ElapsedTicks);
            Console.WriteLine("*********** Timer CONTAINER CREATE Stop ***********");
            timer.Reset();
            Console.WriteLine("*********** Timer REGISTER Start ***********");
            timer.Start();



            //somehow give container interface and class
            container.Register <IStoresService, StoreService>();


            timer.Stop();
            Console.WriteLine(timer.ElapsedTicks);
            Console.WriteLine("*********** Timer REGISTER Stop ***********");

            //assert container is not null
            Assert.IsNotNull(container);

            //assert container contains 1 registered type
            Assert.IsTrue(container.CountOfRegisteredTypes() == 1);
        }
Пример #2
0
        public void ContainerCreation()
        {
            //verifying container still constructed without issues after splitting registry from container
            Console.WriteLine("*********** Timer CONTAINER CREATE Start ***********");
            var timer = Stopwatch.StartNew();



            //arrange
            var container = new FlyIoCContainer();



            timer.Stop();
            Console.WriteLine(timer.ElapsedTicks);
            Console.WriteLine("*********** Timer CONTAINER CREATE Stop ***********");

            //assert container is not null
            Assert.IsNotNull(container);
        }
Пример #3
0
        public void ResolveInstance_ResolvesToHasNoCtor()
        {
            Console.WriteLine("*********** Timer CONTAINER CREATE Start ***********");
            var timer = Stopwatch.StartNew();



            //arrange
            var container = new FlyIoCContainer();



            timer.Stop();
            Console.WriteLine(timer.ElapsedTicks);
            Console.WriteLine("*********** Timer CONTAINER CREATE Stop ***********");
            timer.Reset();
            Console.WriteLine("*********** Timer REGISTER Start ***********");
            timer.Start();



            //somehow give container interface and class
            container.Register <IStoresService, StoreService>();


            timer.Stop();
            Console.WriteLine(timer.ElapsedTicks);
            Console.WriteLine("*********** Timer REGISTER Stop ***********");
            timer.Reset();
            Console.WriteLine("*********** Timer Resolve Start ***********");
            timer.Start();



            //action
            //container resolve instance of desired class
            var storeService = container.ResolveSingleton <IStoresService>();



            timer.Stop();
            Console.WriteLine(timer.ElapsedTicks);
            Console.WriteLine("*********** Timer Resolve Stop ***********");
            var frequency = Stopwatch.Frequency;

            Console.WriteLine("  Timer frequency in ticks per second = {0}",
                              frequency);
            var nanosecPerTick = (1000L * 1000L * 1000L) / frequency;

            Console.WriteLine("  Timer is accurate within {0} nanoseconds",
                              nanosecPerTick);

            //assert

            //assert container is not null
            Assert.IsNotNull(container);

            //assert container contains 1 registered type
            Assert.IsTrue(container.CountOfRegisteredTypes() == 1);

            //assert result is not null
            Assert.IsNotNull(storeService);

            //assert result is of expected type
            Assert.IsInstanceOfType(storeService, typeof(IStoresService));
            Assert.IsInstanceOfType(storeService, typeof(StoreService));

            //assert data is accessible
            Assert.IsNotNull(storeService.GetStore(1));
            Assert.IsNotNull(storeService.GetStores());
        }