1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-28 13:15:12 +01:00
bitwarden-server/test/Infrastructure.EFIntegration.Test/Vault/Repositories/FolderRepositoryTests.cs
Robyn MacCallum 3289a8c35e
[SG-998] Move files to Vault folders (#2724)
* Move Api files

* Move Core files

* Move Infrastructure files

* Move Sql Files

* Move Api Sync files to Vault

* Move test vault files

* Update Sql.sqlproj paths

* Update Codeowners

* Fix vault file paths in sqlproj

* Update CipherDetails.sql path in sqlproj

* Update Core models and entities namespaces

* Update namespaces Core Services and Repositories

* Missed service namespaces

* Update Api namespaces

* Update Infrastructure namespaces

* Move infrastructure queries that were missed

* Tests namespace updates

* Admin and Events namespace updates

* Remove unused usings

* Remove extra CiphersController usings

* Rename folder

* Fix CipherDetails namespace

* Sqlproj fixes

* Move stored procs into folders by table

* using order fix
2023-03-02 13:23:38 -05:00

52 lines
1.8 KiB
C#

using Bit.Core.Entities;
using Bit.Core.Test.AutoFixture.Attributes;
using Bit.Core.Vault.Entities;
using Bit.Infrastructure.EFIntegration.Test.AutoFixture;
using Bit.Infrastructure.EFIntegration.Test.Repositories.EqualityComparers;
using Xunit;
using EfRepo = Bit.Infrastructure.EntityFramework.Repositories;
using EfVaultRepo = Bit.Infrastructure.EntityFramework.Vault.Repositories;
using SqlRepo = Bit.Infrastructure.Dapper.Repositories;
using SqlVaultRepo = Bit.Infrastructure.Dapper.Vault.Repositories;
namespace Bit.Infrastructure.EFIntegration.Test.Repositories;
public class FolderRepositoryTests
{
[CiSkippedTheory, EfFolderAutoData]
public async void CreateAsync_Works_DataMatches(
Folder folder,
User user,
FolderCompare equalityComparer,
List<EfVaultRepo.FolderRepository> suts,
List<EfRepo.UserRepository> efUserRepos,
SqlVaultRepo.FolderRepository sqlFolderRepo,
SqlRepo.UserRepository sqlUserRepo)
{
var savedFolders = new List<Folder>();
foreach (var sut in suts)
{
var i = suts.IndexOf(sut);
var efUser = await efUserRepos[i].CreateAsync(user);
sut.ClearChangeTracking();
folder.UserId = efUser.Id;
var postEfFolder = await sut.CreateAsync(folder);
sut.ClearChangeTracking();
var savedFolder = await sut.GetByIdAsync(folder.Id);
savedFolders.Add(savedFolder);
}
var sqlUser = await sqlUserRepo.CreateAsync(user);
folder.UserId = sqlUser.Id;
var sqlFolder = await sqlFolderRepo.CreateAsync(folder);
savedFolders.Add(await sqlFolderRepo.GetByIdAsync(sqlFolder.Id));
var distinctItems = savedFolders.Distinct(equalityComparer);
Assert.True(!distinctItems.Skip(1).Any());
}
}