示例#1
0
        public async Task RunTransactionAsync_TooManyRetries(int?userSpecifiedAttempts)
        {
            int actualAttempts = userSpecifiedAttempts ?? TransactionOptions.Default.MaxAttempts;
            var options        = userSpecifiedAttempts == null ? null : TransactionOptions.Create(userSpecifiedAttempts.Value);

            var client    = new TransactionTestingClient(actualAttempts, CreateRpcException(StatusCode.Aborted));
            var db        = FirestoreDb.Create("proj", "db", client);
            var exception = await Assert.ThrowsAsync <RpcException>(() => db.RunTransactionAsync(CreateCountingCallback(), options));

            Assert.Equal(StatusCode.Aborted, exception.Status.StatusCode);
            // We should have made as many attempts as we were allowed, and all should have been rolled back.
            Assert.Equal(actualAttempts, client.CommitRequests.Count);
            Assert.Equal(actualAttempts, client.RollbackRequests.Count);
        }
示例#2
0
        public void Create_Valid(int attempts)
        {
            var options = TransactionOptions.Create(attempts);

            Assert.Equal(attempts, options.MaxAttempts);
        }
示例#3
0
 public void Create_Invalid(int attempts)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => TransactionOptions.Create(attempts));
 }
示例#4
0
 public void Equality()
 {
     EqualityTester.AssertEqual(TransactionOptions.Create(10),
                                equal: new[] { TransactionOptions.Create(10) },
                                unequal: new[] { TransactionOptions.Create(20) });
 }