persistence/DD.Persistence.IntegrationTests/Controllers/DataSourceSystemControllerTest.cs
2024-12-18 14:20:05 +05:00

83 lines
2.2 KiB
C#

//using Microsoft.Extensions.Caching.Memory;
//using Microsoft.Extensions.DependencyInjection;
//using DD.Persistence.Client;
//using DD.Persistence.Client.Clients;
//using DD.Persistence.Client.Clients.Interfaces;
//using DD.Persistence.Database.Entity;
//using DD.Persistence.Models;
//using Xunit;
//namespace DD.Persistence.IntegrationTests.Controllers
//{
// public class DataSourceSystemControllerTest : BaseIntegrationTest
// {
// private static readonly string SystemCacheKey = $"{typeof(Database.Entity.DataSourceSystem).FullName}CacheKey";
// private readonly IDataSourceSystemClient dataSourceSystemClient;
// private readonly IMemoryCache memoryCache;
// public DataSourceSystemControllerTest(WebAppFactoryFixture factory) : base(factory)
// {
// var scope = factory.Services.CreateScope();
// var persistenceClientFactory = scope.ServiceProvider
// .GetRequiredService<PersistenceClientFactory>();
// dataSourceSystemClient = persistenceClientFactory.GetDataSourceSystemClient();
// memoryCache = scope.ServiceProvider.GetRequiredService<IMemoryCache>();
// }
// [Fact]
// public async Task Get_returns_success()
// {
// //arrange
// memoryCache.Remove(SystemCacheKey);
// dbContext.CleanupDbSet<DataSourceSystem>();
// //act
// var response = await dataSourceSystemClient.Get(CancellationToken.None);
// //assert
// Assert.NotNull(response);
// Assert.Empty(response);
// }
// [Fact]
// public async Task Get_AfterSave_returns_success()
// {
// //arrange
// await Add();
// //act
// var response = await dataSourceSystemClient.Get(CancellationToken.None);
// //assert
// Assert.NotNull(response);
// var expectedSystemCount = 1;
// var actualSystemCount = response!.Count();
// Assert.Equal(expectedSystemCount, actualSystemCount);
// }
// [Fact]
// public async Task Add_returns_success()
// {
// await Add();
// }
// private async Task Add()
// {
// //arrange
// memoryCache.Remove(SystemCacheKey);
// dbContext.CleanupDbSet<DataSourceSystem>();
// var dto = new DataSourceSystemDto()
// {
// SystemId = Guid.NewGuid(),
// Name = "Test",
// Description = "Test"
// };
// //act
// await dataSourceSystemClient.Add(dto, CancellationToken.None);
// }
// }
//}