Exemplo n.º 1
0
        public void NoTransactionOneTake()
        {
            TestPart part = _container.GetExportedValue <TransactionPolicy <TestPart> >();

            Assert.IsNotNull(part);
            Assert.AreEqual(1, _collector.PartCount);
        }
Exemplo n.º 2
0
 public void SingleTransactionOneTake()
 {
     using (new TransactionScope())
     {
         TestPart part = _container.GetExportedValue <TransactionPolicy <TestPart> >();
     }
     Assert.AreEqual(1, _collector.PartCount);
 }
Exemplo n.º 3
0
        public void SingleThreadTwoTakes()
        {
            TestPart part  = _container.GetExportedValue <ThreadPolicy <TestPart> >();
            TestPart part2 = _container.GetExportedValue <ThreadPolicy <TestPart> >();

            Assert.AreSame(part, part2);
            Assert.AreEqual(1, _collector.PartCount);
        }
Exemplo n.º 4
0
        public void TwoThreadsTwoTakes()
        {
            TestPart part  = _container.GetExportedValue <ThreadPolicy <TestPart> >();
            TestPart part2 = null;

            Task.Run(() => part2 = _container.GetExportedValue <ThreadPolicy <TestPart> >()).Wait();
            Assert.AreNotSame(part, part2);
            Assert.AreEqual(2, _collector.PartCount);
        }
Exemplo n.º 5
0
        public void NoTransaction_TwoTakes()
        {
            TestPart part  = _container.GetExportedValue <TransactionPolicy <TestPart> >();
            TestPart part2 = _container.GetExportedValue <TransactionPolicy <TestPart> >();

            Assert.IsNotNull(part);
            Assert.IsNotNull(part2);
            Assert.AreNotSame(part, part2);
            Assert.AreEqual(2, _collector.PartCount);
        }
Exemplo n.º 6
0
        public void TwoThreadsFourTakes()
        {
            TestPart part1 = _container.GetExportedValue <ThreadPolicy <TestPart> >();
            TestPart part2 = _container.GetExportedValue <ThreadPolicy <TestPart> >();
            TestPart part3 = null;
            TestPart part4 = null;

            Task.Run(() =>
            {
                part3 = _container.GetExportedValue <ThreadPolicy <TestPart> >();
                part4 = _container.GetExportedValue <ThreadPolicy <TestPart> >();
            }).Wait();
            Assert.AreSame(part1, part2);
            Assert.AreSame(part3, part4);
            Assert.AreNotSame(part3, part2);
            Assert.AreEqual(2, _collector.PartCount);
        }
Exemplo n.º 7
0
        public void SingleThreadOneTake()
        {
            TestPart part = _container.GetExportedValue <ThreadPolicy <TestPart> >();

            Assert.AreEqual(1, _collector.PartCount);
        }