コード例 #1
0
        public async Task Exception()
        {
            var connectionStrings = new List <string>();
            await Assert.ThrowsExceptionAsync <AggregateException>(() => _proxy.RunAsync(async(con) =>
            {
                connectionStrings.Add(con.ConnectionString);
                return(await Task.FromException <int>(new Exception()));
            })
                                                                   );

            Assert.AreEqual(_connectionStrings.Length, connectionStrings.Count);
            Assert.AreEqual(_connectionStrings[0], connectionStrings[0]);
            Assert.AreEqual(_connectionStrings[1], connectionStrings[1]);

            connectionStrings.Clear();
            await Assert.ThrowsExceptionAsync <AggregateException>(() => _proxy.RunAsync(async(con) =>
            {
                connectionStrings.Add(con.ConnectionString);
                return(await Task.FromException <int>(new Exception()));
            })
                                                                   );

            Assert.AreEqual(_connectionStrings.Length, connectionStrings.Count);
            Assert.AreEqual(_connectionStrings[0], connectionStrings[0]);
            Assert.AreEqual(_connectionStrings[1], connectionStrings[1]);
        }
コード例 #2
0
        public async Task GenericException()
        {
            var count = 0;
            await Assert.ThrowsExceptionAsync <AggregateException>(() => _proxy.RunAsync(async(con) =>
            {
                count++;
                return(await Task.FromException <int>(new Exception()));
            })
                                                                   );

            Assert.AreEqual(1, count);
        }