Browse Source

Insert_Should_Set_Guid_Id unit test.

pull/4634/head
maliming 6 years ago
parent
commit
4af6d60a59
  1. 4
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs
  2. 10
      framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/MongoDB/Repositories/Repository_Basic_Tests.cs

4
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs

@ -183,11 +183,11 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
{
if (entity is IEntity<Guid> entityWithGuidId)
{
TrySetGuidId(entity, entityWithGuidId);
TrySetGuidId(entityWithGuidId);
}
}
protected virtual void TrySetGuidId(TEntity entry, IEntity<Guid> entity)
protected virtual void TrySetGuidId(IEntity<Guid> entity)
{
if (entity.Id != default)
{

10
framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/MongoDB/Repositories/Repository_Basic_Tests.cs

@ -64,5 +64,15 @@ namespace Volo.Abp.MongoDB.Repositories
person.Phones.Count.ShouldBe(1);
person.Phones.Any(p => p.PersonId == person.Id && p.Number == "1234567890").ShouldBeTrue();
}
[Fact]
public async Task Insert_Should_Set_Guid_Id()
{
var person = new Person(Guid.Empty, "New Person", 35);
await PersonRepository.InsertAsync(person);
person.Id.ShouldNotBe(Guid.Empty);
}
}
}

Loading…
Cancel
Save