-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
51 deletions.
There are no files selected for viewing
102 changes: 51 additions & 51 deletions
102
tests/Orion.Test/Integration/UnitOfWork/UnitOfWorkTestsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
//using System.Threading.Tasks; | ||
//using Microsoft.EntityFrameworkCore; | ||
//using Microsoft.Extensions.DependencyInjection; | ||
//using Orion.Domain.Core.Repositories.UnitOfWork; | ||
//using Orion.Test.Integration.Setup; | ||
//using Orion.Test.Shared.Faker; | ||
//using Xunit; | ||
|
||
//namespace Orion.Test.Integration.UnitOfWork; | ||
|
||
//public class UnitOfWorkTests (IntegrationTestsFixture fixture) : IntegrationTestsBootstrapper(fixture) | ||
//{ | ||
// [Fact] | ||
// public async Task CommitAsync_WithUniqueIndexViolation_ThrowsDbUpdateException() | ||
// { | ||
// // arrange | ||
// using var scope = ServiceProvider.CreateScope(); | ||
// var unitOfWork = scope.ServiceProvider.GetService<IUnitOfWork>(); | ||
// var user = UserFaker.Get(); | ||
// var user2 = UserFaker.Get(); | ||
|
||
// user2.Email = user.Email; | ||
|
||
// await unitOfWork.UserRepository.AddAsync(user); | ||
// await unitOfWork.UserRepository.AddAsync(user2); | ||
// // act & assert | ||
// await Assert.ThrowsAsync<DbUpdateException>(() => unitOfWork.CommitAsync()); | ||
// } | ||
// [Fact] | ||
// public async Task CommitAsync_WithValidInsert_SaveRegistry() | ||
// { | ||
// // arrange | ||
// using var scope = ServiceProvider.CreateScope(); | ||
// var unitOfWork = scope.ServiceProvider.GetService<IUnitOfWork>(); | ||
// var validUser = UserFaker.Get(); | ||
|
||
// // act | ||
// await unitOfWork.UserRepository.AddAsync(validUser); | ||
|
||
// Assert.Equal(0, validUser.UserId); | ||
// // act | ||
// await unitOfWork.CommitAsync(); | ||
// Assert.NotEqual(0, validUser.UserId); | ||
// } | ||
//} | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Orion.Domain.Core.Repositories.UnitOfWork; | ||
using Orion.Test.Integration.Setup; | ||
using Orion.Test.Shared.Faker; | ||
using Xunit; | ||
|
||
namespace Orion.Test.Integration.UnitOfWork; | ||
|
||
public class UnitOfWorkTests(IntegrationTestsFixture fixture) : IntegrationTestsBootstrapper(fixture) | ||
{ | ||
[Fact] | ||
public async Task CommitAsync_WithUniqueIndexViolation_ThrowsDbUpdateException() | ||
{ | ||
// arrange | ||
using var scope = ServiceProvider.CreateScope(); | ||
var unitOfWork = scope.ServiceProvider.GetService<IUnitOfWork>(); | ||
|
||
var user = UserFaker.Get(); | ||
var user2 = UserFaker.Get(); | ||
|
||
user2.Email = user.Email; | ||
|
||
await unitOfWork.UserRepository.AddAsync(user); | ||
await unitOfWork.UserRepository.AddAsync(user2); | ||
|
||
// act & assert | ||
await Assert.ThrowsAsync<DbUpdateException>(() => unitOfWork.CommitAsync()); | ||
} | ||
|
||
//[Fact] | ||
//public async Task CommitAsync_WithValidInsert_SaveRegistry() | ||
//{ | ||
// // arrange | ||
// using var scope = ServiceProvider.CreateScope(); | ||
// var unitOfWork = scope.ServiceProvider.GetService<IUnitOfWork>(); | ||
|
||
// var validUser = UserFaker.Get(); | ||
|
||
// // act | ||
// await unitOfWork.UserRepository.AddAsync(validUser); | ||
|
||
// Assert.Equal(0, validUser.UserId); | ||
|
||
// // act | ||
// await unitOfWork.CommitAsync(); | ||
|
||
// Assert.NotEqual(0, validUser.UserId); | ||
//} | ||
} |