public async Task ItShouldReturnOK_WhenQueringForOneRecord_GivenRecordExists() { // g var objectId = Guid.NewGuid().ToString(); var aTimestamp = DateTime.Now; var json = JsonObjectFactory.CreateJsonObject(aTimestamp, objectId); var tableObj = new TemporaryObject("PK", objectId) { id = objectId }; var table = FluentCyanTestsHelper.GetAzureTable<TemporaryObject>(); table.Add(tableObj); var expected = new Response<JsonObject>(HttpStatusCode.OK, json); // w var actual = await _client.FromTable(TableName).GetByIdAsync(objectId).ConfigureAwait(false); // t Assert.That(actual.Status, Is.EqualTo(expected.Status)); Assert.That(actual.Result.Id, Is.EqualTo(expected.Result.Id)); Assert.That(actual.Result.ContainsKey("ETag")); Assert.That(actual.Result.ContainsKey("Timestamp")); }
public async Task ItShouldReturnNotFound_WhenQueringForOneRecord_GivenRecordExistAndIsMarkedAsDeleted() { // g var objectId = Guid.NewGuid().ToString(); var tableObj = new TemporaryObject("PK", objectId) { id = objectId, sys_deleted = true}; var table = FluentCyanTestsHelper.GetAzureTable<TemporaryObject>(); table.Add(tableObj); // w var actual = await _client.FromTable(TableName).GetByIdAsync(objectId).ConfigureAwait(false); // t Assert.That(actual.Status, Is.EqualTo(HttpStatusCode.NotFound)); }
public async Task ItShouldReturnOK_WhenQueringForAllRecords_GivenRecordsExists() { // g var item1 = new TemporaryObject("PK", Guid.NewGuid().ToString()) { id = "item1" }; var item2 = new TemporaryObject("PK", Guid.NewGuid().ToString()) { id = "item2" }; var table = FluentCyanTestsHelper.GetAzureTable<TemporaryObject>(); table.Add(item1); table.Add(item2); var allObjects = new[] { item1, item2 }; var expected = new Response<TemporaryObject[]>(HttpStatusCode.OK, allObjects); // w var actual = await _client.FromTable(TableName).GetAllAsync().ConfigureAwait(false); // t Assert.That(actual.Status, Is.EqualTo(expected.Status)); Assert.That(actual.Result.Count(), Is.EqualTo(expected.Result.Count())); }