예제 #1
0
        public void NetServiceCollection_Initialized_ServiceInitialized()
        {
            NetServiceCollection c = new NetServiceCollection();

            c.Register <TestNetService>();
            c.LockServices();
            c.InitializeServices(new NetContext());

            Assert.IsTrue(c.Get <TestNetService>().Initialized == true);
        }
예제 #2
0
        public void NetServiceCollection_GetServices_HasServices()
        {
            NetServiceCollection c = new NetServiceCollection();

            c.Register <TestNetService>();
            c.LockServices();

            Assert.IsTrue(c.ServiceList.Count() == 1);
            Assert.IsTrue(c.ServiceList.First() == c.Get <TestNetService>());
        }
예제 #3
0
        public void NetServiceCollection_RegisterService_HasService()
        {
            NetServiceCollection c = new NetServiceCollection();

            c.Register <TestNetService>();
            c.LockServices();

            var result = c.Get <TestNetService>();

            Assert.IsNotNull(result);
        }
예제 #4
0
        public void NetServiceCollection_Disposed_ServiceDisposed()
        {
            NetServiceCollection c = new NetServiceCollection();

            c.Register <TestNetService>();
            c.LockServices();
            var svc = c.Get <TestNetService>();

            c.Dispose();

            Assert.IsTrue(svc.Disposed == true);
        }
예제 #5
0
        public void NetServiceCollection_RegisterServiceWithConfigure_ServiceConfigured()
        {
            NetServiceCollection c = new NetServiceCollection();

            c.Register <TestNetService>();
            c.Configure <TestNetService>((o) => { o.Configured = true; });
            c.LockServices();

            var svc = c.Get <TestNetService>();

            Assert.IsNotNull(svc);
            Assert.IsTrue(svc.Configured);
        }
예제 #6
0
        public void NetServiceCollection_SetActivationFunc_ActivationFuncInvoked()
        {
            NetServiceCollection c = new NetServiceCollection();

            c.Register <TestNetService>();

            bool invoked = false;

            c.SetActivationFunction(typeof(TestNetService), () => {
                invoked = true;
                return(new TestNetService());
            });

            c.LockServices();
            Assert.IsTrue(invoked);
        }