Exemplo n.º 1
0
        public async Task ThreadScopeTest()
        {
            container.AutoBinding(Profiles.PROFILE_C);

            IBindableService instance11 = null;
            IBindableService instance12 = null;

            IBindableService instance21 = null;
            IBindableService instance22 = null;

            Task t1 = Task.Run(() =>
            {
                instance11 = container.Get <IBindableService>();
                instance12 = container.Get <IBindableService>();
            });

            Task t2 = Task.Run(() =>
            {
                instance21 = container.Get <IBindableService>();
                instance22 = container.Get <IBindableService>();
            });

            await Task.WhenAll(t1, t2);

            Assert.IsNotNull(instance11);
            Assert.IsNotNull(instance12);
            Assert.IsNotNull(instance21);
            Assert.IsNotNull(instance22);
            Assert.AreSame(instance11, instance12);
            Assert.AreSame(instance21, instance22);
            Assert.AreNotSame(instance11, instance21);
            Assert.AreNotSame(instance12, instance22);
        }
Exemplo n.º 2
0
        public void AutoDisposeCallTest()
        {
            container.AutoBinding(Profiles.PROFILE_C);

            IBindableService instance = container.Get <IBindableService>();

            container.Dispose();
        }
Exemplo n.º 3
0
        public void TransientScopeTest()
        {
            container.AutoBinding(Profiles.PROFILE_A);

            IBindableService instance1 = container.Get <IBindableService>();
            IBindableService instance2 = container.Get <IBindableService>();

            Assert.AreNotSame(instance1, instance2);
        }
Exemplo n.º 4
0
        public void SingletonScopeTest()
        {
            container.AutoBinding(Profiles.PROFILE_B);

            IBindableService        instance1 = container.Get <IBindableService>();
            IBindableService        instance2 = container.Get <IBindableService>();
            BindableImplementationB instance3 = container.Get <BindableImplementationB>();
            IBindableServiceB       instance4 = container.Get <IBindableServiceB>();

            Assert.AreSame(instance1, instance2);
            Assert.AreSame(instance1, instance3);
            Assert.AreSame(instance1, instance4);
        }