예제 #1
0
        public async static void TestAsyncUsingWithException()
        {
            var done   = Assert.Async();
            var parent = new Bridge1170();

            try
            {
                using (new Class1(parent))
                {
                    await Task.Delay(1);

                    throw new InvalidOperationException("Bridge1170 test");
                }
            }
            catch (InvalidOperationException e)
            {
                Assert.AreEqual("Bridge1170 test", e.Message);
            }

            Assert.True(parent.isDisposed);

            done();
        }
예제 #2
0
        public async static void TestAsyncUsing()
        {
            var done    = Assert.Async();
            var parent  = new Bridge1170();
            var parent2 = new Bridge1170();

            using (new Class1(parent))
            {
                await Task.Delay(1);

                Assert.False(parent.isDisposed);
            }
            Assert.True(parent.isDisposed);

            parent.isDisposed = false;
            using (var c1 = new Class1(parent))
            {
                await Task.Delay(1);

                Assert.False(c1.isDisposed);
                Assert.False(parent.isDisposed);
            }
            Assert.True(parent.isDisposed);

            parent.isDisposed = false;
            using (Class1 c1 = new Class1(parent), c2 = new Class1(parent2))
            {
                await Task.Delay(1);

                Assert.False(c1.isDisposed);
                Assert.False(c2.isDisposed);
            }
            Assert.True(parent.isDisposed);
            Assert.True(parent2.isDisposed);

            done();
        }
예제 #3
0
 public Class1(Bridge1170 parent)
 {
     this.parent = parent;
 }