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); }
public void Create_Valid(int attempts) { var options = TransactionOptions.Create(attempts); Assert.Equal(attempts, options.MaxAttempts); }
public void Create_Invalid(int attempts) { Assert.Throws <ArgumentOutOfRangeException>(() => TransactionOptions.Create(attempts)); }
public void Equality() { EqualityTester.AssertEqual(TransactionOptions.Create(10), equal: new[] { TransactionOptions.Create(10) }, unequal: new[] { TransactionOptions.Create(20) }); }