public async Task UpdateOfferAsync_WhenUsingDbOffer_ThenDbOfferIsUpdated() { // Arrange var expectedThroughput = 20000; await _cosmonautClient.CreateDatabaseAsync(new Database { Id = _scaleableDbId }, new RequestOptions { OfferThroughput = 10000 }); await _cosmonautClient.CreateCollectionAsync(_scaleableDbId, new DocumentCollection { Id = _collectionName, PartitionKey = new PartitionKeyDefinition() { Paths = new Collection <string>(new List <string> { "/id" }) } }); var offer = await _cosmonautClient.GetOfferV2ForDatabaseAsync(_scaleableDbId); // Act var newOffer = new OfferV2(offer, expectedThroughput); var updatedOffer = await _cosmonautClient.UpdateOfferAsync(newOffer); // Assert updatedOffer.StatusCode.Should().Be(HttpStatusCode.OK); var dbOffer = await _cosmonautClient.GetOfferV2ForDatabaseAsync(_scaleableDbId); dbOffer.Content.OfferThroughput.Should().Be(expectedThroughput); }
public async Task UpdateOfferAsync_WhenUsingDbOffer_ThenDbOfferIsUpdated() { // Arrange var expectedThroughput = 20000; await _cosmonautClient.CreateDatabaseAsync(new Database { Id = _scaleableDbId }, new RequestOptions { OfferThroughput = 10000 }); var offer = await _cosmonautClient.GetOfferV2ForDatabaseAsync(_scaleableDbId); // Act var newOffer = new OfferV2(offer, expectedThroughput); var updatedOffer = await _cosmonautClient.UpdateOfferAsync(newOffer); // Assert updatedOffer.StatusCode.Should().Be(HttpStatusCode.OK); var dbOffer = await _cosmonautClient.GetOfferV2ForDatabaseAsync(_scaleableDbId); dbOffer.Content.OfferThroughput.Should().Be(expectedThroughput); }
public async Task <ActionResponse> UpdateThroughput(string databaseId, string collectionId, int throughput) { var offer = await _cosmonautClient.GetOfferV2ForCollectionAsync(databaseId, collectionId); var newOffer = new OfferV2(offer, throughput); var result = await _cosmonautClient.UpdateOfferAsync(newOffer); var success = result.StatusCode == HttpStatusCode.OK; return(new ActionResponse { Success = success, Message = success ? "Success" : "Failed" }); }
public async Task UpdateOfferAsync_WhenOfferIsUpdated_ThenRUsCorrespondToTheUpdate() { // Arrange var offer = await _cosmonautClient.GetOfferV2ForCollectionAsync(_databaseId, _collectionName); // Act var newOffer = new OfferV2(offer, 600); var updated = await _cosmonautClient.UpdateOfferAsync(newOffer); var queried = await _cosmonautClient.GetOfferV2ForCollectionAsync(_databaseId, _collectionName); // Assert offer.Content.OfferThroughput.Should().Be(400); updated.StatusCode.Should().Be(HttpStatusCode.OK); queried.Content.OfferThroughput.Should().Be(600); updated.Resource.Should().BeEquivalentTo(queried); }