Esempio n. 1
0
        public async Task SupportsSuppressedDistributedTransactions()
        {
            var pocoA = new PocoA {
                Name = Guid.NewGuid().ToString(), Value = 1
            };
            var pocoB = new PocoB {
                Name = Guid.NewGuid().ToString(), Value = 2
            };

            var record = await _commander.ExecuteAsync(() =>
            {
                var t1 = _commander.Execute(pocoA) ? pocoA : null;
                var t2 = _commander.Execute(pocoB) ? pocoB : null;

                return(new MultiMapPocoB
                {
                    PocoA = t1,
                    PocoB = t2
                });
            });

            NotNull(record);
            NotNull(record.PocoA);
            NotNull(record.PocoB);

            Same(pocoB, record.PocoB);
        }
Esempio n. 2
0
        public async Task SupportsEnlistingInAmbientTransactions(TransactionScopeOption scopeOption)
        {
            var name  = Enum.GetName(typeof(TransactionScopeOption), scopeOption);
            var pocoA = new PocoA {
                Name = $"{name}--{Guid.NewGuid()}", Value = 1
            };
            var pocoB = new PocoB {
                Name = $"{name}--{Guid.NewGuid()}", Value = 2
            };

            var result = await _commander.ExecuteAsync(() =>
            {
                var t1 = _commander.Execute(pocoA) ? pocoA : null;
                var t2 = _commander.Execute(pocoB) ? pocoB : null;

                return(new MultiMapPocoB
                {
                    PocoA = t1,
                    PocoB = t2
                });
            }, scopeOption);

            NotNull(result);
            NotNull(result.PocoA);
            NotNull(result.PocoB);
        }
Esempio n. 3
0
        public void SupportsTransactionRollback()
        {
            var model = new PocoA {
                Name = Guid.NewGuid().ToString(), Value = int.MaxValue
            };

            var          result   = ThrowsAny <Exception>(() => _commander.Execute(model));
            const string expected = "22003: value overflows numeric format";

            Equal(expected, result.Message);

            // check if the record has been rolled back.
            // ReSharper disable once ExplicitCallerInfoArgument
            var record = _commander.Query <PocoA>(new { model.Name }, method: "SupportsTransactionRollback.Query");

            NotNull(record);
            False(record.Any());
        }
Esempio n. 4
0
        public void SupportsTransactionRollback()
        {
            var model = new PocoA {
                Name = Guid.NewGuid().ToString(), Value = int.MaxValue
            };

            var          result   = ThrowsAny <Exception>(() => _commander.Execute(model));
            const string expected =
                "Arithmetic overflow error converting expression to data type float.\r\nThe statement has been terminated.";

            Equal(expected, result.Message);

            // check if the record has been rolled back.
            // ReSharper disable once ExplicitCallerInfoArgument
            var record = _commander.Query <PocoA>(new { model.Name }, method: "SupportsTransactionRollback.Query");

            NotNull(record);
            False(record.Any());
        }
Esempio n. 5
0
        public async Task SupportsTransactionRollback()
        {
            var model = new PocoA {
                Name = Guid.NewGuid().ToString(), Value = int.MaxValue
            };

            var result = await ThrowsAnyAsync <Exception>(() => _commander.ExecuteAsync(model));

            const string expected = "DOUBLE value is out of range in 'pow(2147483647,2147483647)'";

            Equal(expected, result.Message);

            // check if the record has been rolled back.
            // ReSharper disable once ExplicitCallerInfoArgument
            var record =
                await _commander.QueryAsync <PocoA>(new { model.Name }, method : "SupportsTransactionRollback.Query");

            NotNull(record);
            False(record.Any());
        }