mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 21:18:13 -05:00

* Revert "Add git blame entry (#2226)" This reverts commit 239286737d15cb84a893703ee5a8b33a2d67ad3d. * Revert "Turn on file scoped namespaces (#2225)" This reverts commit 34fb4cca2aa78deb84d4cbc359992a7c6bba7ea5.
48 lines
1.8 KiB
C#
48 lines
1.8 KiB
C#
using Bit.Core.Entities;
|
|
using Bit.Core.Test.AutoFixture.Attributes;
|
|
using Bit.Infrastructure.EFIntegration.Test.AutoFixture;
|
|
using Bit.Infrastructure.EFIntegration.Test.Repositories.EqualityComparers;
|
|
using Xunit;
|
|
using EfRepo = Bit.Infrastructure.EntityFramework.Repositories;
|
|
using SqlRepo = Bit.Infrastructure.Dapper.Repositories;
|
|
|
|
namespace Bit.Infrastructure.EFIntegration.Test.Repositories
|
|
{
|
|
public class DeviceRepositoryTests
|
|
{
|
|
[CiSkippedTheory, EfDeviceAutoData]
|
|
public async void CreateAsync_Works_DataMatches(Device device, User user,
|
|
DeviceCompare equalityComparer, List<EfRepo.DeviceRepository> suts,
|
|
List<EfRepo.UserRepository> efUserRepos, SqlRepo.DeviceRepository sqlDeviceRepo,
|
|
SqlRepo.UserRepository sqlUserRepo)
|
|
{
|
|
var savedDevices = new List<Device>();
|
|
foreach (var sut in suts)
|
|
{
|
|
var i = suts.IndexOf(sut);
|
|
|
|
var efUser = await efUserRepos[i].CreateAsync(user);
|
|
device.UserId = efUser.Id;
|
|
sut.ClearChangeTracking();
|
|
|
|
var postEfDevice = await sut.CreateAsync(device);
|
|
sut.ClearChangeTracking();
|
|
|
|
var savedDevice = await sut.GetByIdAsync(postEfDevice.Id);
|
|
savedDevices.Add(savedDevice);
|
|
}
|
|
|
|
var sqlUser = await sqlUserRepo.CreateAsync(user);
|
|
device.UserId = sqlUser.Id;
|
|
|
|
var sqlDevice = await sqlDeviceRepo.CreateAsync(device);
|
|
var savedSqlDevice = await sqlDeviceRepo.GetByIdAsync(sqlDevice.Id);
|
|
savedDevices.Add(savedSqlDevice);
|
|
|
|
var distinctItems = savedDevices.Distinct(equalityComparer);
|
|
Assert.True(!distinctItems.Skip(1).Any());
|
|
}
|
|
|
|
}
|
|
}
|