Skip to content

Commit

Permalink
PR EntityTAble Client Fixes/entitytable client delete one (#64)
Browse files Browse the repository at this point in the history
* Update AzureNativeTableClient.cs

* Update EntityTableClientWritingTests.cs
  • Loading branch information
medevod authored Nov 20, 2023
1 parent ef961d6 commit 1e16fed
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Azure.Data.Tables;
using Azure.Data.Tables;
using Azure.EntityServices.Queries;
using Azure.EntityServices.Tables.Core.Abstractions;
using Azure.EntityServices.Tables.Extensions;
Expand Down Expand Up @@ -126,6 +126,10 @@ public Task SubmitOneOperation(EntityOperation entityOperation, CancellationToke
await _tableClient.UpsertEntityAsync(nativeEntity, mode: TableUpdateMode.Merge, cancellationToken: cancellationToken);
break;

case EntityOperationType.Delete:
await _tableClient.DeleteAsync();
break;

default: throw new NotSupportedException(nameof(entityOperation.EntityOperationType));
}
});
Expand All @@ -146,4 +150,4 @@ public Task SubmitTransaction(IEnumerable<EntityOperation> entityOperations, Can
), cancellationToken));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Azure.Data.Tables;
using Azure.Data.Tables;
using Azure.EntityServices.Queries;
using Azure.EntityServices.Tables;
using Azure.EntityServices.Tables.Extensions;
Expand Down Expand Up @@ -504,7 +504,6 @@ await tableEntity.UpdateManyAsync(person =>

result.Should().HaveCount(130 + 1000);
result.All(person => person.LastName.EndsWith("_updated")).Should().BeTrue();

}

[TestMethod]
Expand Down Expand Up @@ -533,7 +532,6 @@ public async Task Should_Update_Many_Indexed_Entities_With_No_Existing_Entities(
updated.Should().Be(0);
}


[TestMethod]
public async Task Should_Store_Default_DateTime_Values()
{
Expand Down Expand Up @@ -790,13 +788,36 @@ public async Task Should_Delete_Entity()
var persons = Fakers.CreateFakePerson().Generate(1);
var person = persons.First();

var entityTable = EntityTableClient.Create<PersonEntity>(TestEnvironment.ConnectionString)
.Configure(options => _defaultOptions(options), c =>
{
c.
SetPartitionKey(p => p.TenantId)
.SetRowKeyProp(p => p.PersonId);
});
await entityTable.AddAsync(person);

var isDeleted = await entityTable.DeleteAsync(person);

var deleted = await entityTable.GetByIdAsync(person.TenantId, person.PersonId);

isDeleted.Should().BeTrue();
deleted.Should().BeNull();
}

[TestMethod]
public async Task Should_Delete_Entity_WithTags()
{
var persons = Fakers.CreateFakePerson().Generate(1);
var person = persons.First();

var entityTable = EntityTableClient.Create<PersonEntity>(TestEnvironment.ConnectionString)
.Configure(options => _defaultOptions(options), c =>
{
c.
SetPartitionKey(p => p.TenantId)
.SetRowKeyProp(p => p.PersonId)
.AddTag(p => p.LastName)
.AddTag(p => p.LastName)
.AddTag(p => p.Created);
});
await entityTable.AddAsync(person);
Expand Down Expand Up @@ -935,4 +956,4 @@ public void Should_Throw_Exception_When_Adding_Invalid_Keys()
.WithMessage("Given primaryKey is null");
}
}
}
}

0 comments on commit 1e16fed

Please sign in to comment.