From d47c768c87cc9951fa2c2391f1f783c3bf13e76e Mon Sep 17 00:00:00 2001 From: ValDekh Date: Wed, 8 Nov 2023 17:22:28 +0200 Subject: [PATCH 01/27] change appsettings --- Streetcode/Streetcode.WebApi/appsettings.Local.json | 3 ++- Streetcode/Streetcode.WebApi/appsettings.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Streetcode/Streetcode.WebApi/appsettings.Local.json b/Streetcode/Streetcode.WebApi/appsettings.Local.json index 14b44479d..2cbc87149 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.Local.json +++ b/Streetcode/Streetcode.WebApi/appsettings.Local.json @@ -1,6 +1,7 @@ { "ConnectionStrings": { - "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" + //"DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" + "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDb;Integrated Security=True" }, "CORS": { "AllowedOrigins": [ "http://localhost:3000" ], diff --git a/Streetcode/Streetcode.WebApi/appsettings.json b/Streetcode/Streetcode.WebApi/appsettings.json index c66f7473d..d40592566 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.json +++ b/Streetcode/Streetcode.WebApi/appsettings.json @@ -1,6 +1,7 @@ { "ConnectionStrings": { - "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" + //"DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" + "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDb;Integrated Security=True" }, "EmailConfiguration": { "From": "streetcodefordev@gmail.com", From 67b3766ae111efd2ad13979bb14185ce63d64d03 Mon Sep 17 00:00:00 2001 From: ValDekh Date: Wed, 8 Nov 2023 17:59:38 +0200 Subject: [PATCH 02/27] Add local connection string --- Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json index 53cd46a8b..cef30441a 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json +++ b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json @@ -1,6 +1,7 @@ { "ConnectionStrings": { - "DefaultConnection": "Server=DESKTOP-I7Q35NQ\\SQLEXPRESS;Database=StreetcodeDbtest;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true;TrustServerCertificate=true" + //"DefaultConnection": "Server=DESKTOP-I7Q35NQ\\SQLEXPRESS;Database=StreetcodeDbtest;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true;TrustServerCertificate=true" + "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDb;Integrated Security=True" }, "Blob": { "BlobStoreKey": "BigThirtyTwoBiteCoolTestKeyCrypt", From 67171a04ea879fc0cd2e5229f7b31fa266d4ae52 Mon Sep 17 00:00:00 2001 From: ValDekh Date: Fri, 10 Nov 2023 16:14:50 +0200 Subject: [PATCH 03/27] Fix some integrated tests --- .../GetTagByStreetcodeIdHandler.cs | 2 +- .../Services/CacheService/CacheService.cs | 69 ++++++++++--------- .../Extensions/RecurringJobExtensions.cs | 35 ++++++---- .../SubtitleControllerTests.cs | 3 +- .../AdditionalContent/TagControllerTests.cs | 6 +- 5 files changed, 66 insertions(+), 49 deletions(-) diff --git a/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Tag/GetByStreetcodeId/GetTagByStreetcodeIdHandler.cs b/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Tag/GetByStreetcodeId/GetTagByStreetcodeIdHandler.cs index dca718fc1..ba90938a0 100644 --- a/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Tag/GetByStreetcodeId/GetTagByStreetcodeIdHandler.cs +++ b/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Tag/GetByStreetcodeId/GetTagByStreetcodeIdHandler.cs @@ -34,7 +34,7 @@ public async Task>> Handle(GetTagByStreetco t => t.StreetcodeId == request.StreetcodeId, include: q => q.Include(t => t.Tag)); - if (tagIndexed is null) + if (tagIndexed is null || !tagIndexed.Any()) { string errorMsg = _stringLocalizerCannotFind?["CannotFindAnyTagByTheStreetcodeId", request.StreetcodeId].Value; _logger.LogError(request, errorMsg); diff --git a/Streetcode/Streetcode.BLL/Services/CacheService/CacheService.cs b/Streetcode/Streetcode.BLL/Services/CacheService/CacheService.cs index abbccade1..144359f76 100644 --- a/Streetcode/Streetcode.BLL/Services/CacheService/CacheService.cs +++ b/Streetcode/Streetcode.BLL/Services/CacheService/CacheService.cs @@ -6,6 +6,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.DependencyInjection; using Streetcode.BLL.Interfaces.Cache; using Streetcode.BLL.Interfaces.Logging; @@ -14,54 +15,58 @@ namespace Streetcode.BLL.Services.CacheService public class CacheService : ICacheService { private readonly IMemoryCache _cache; - private readonly ILoggerService _logger; + private readonly IServiceScopeFactory _serviceScopeFactory; private readonly ConcurrentDictionary _locks = new ConcurrentDictionary(); - public CacheService(IMemoryCache cache, ILoggerService logger) + public CacheService(IMemoryCache cache, IServiceScopeFactory serviceScopeFactory ) { _cache = cache; - _logger = logger; + _serviceScopeFactory = serviceScopeFactory; } public async Task GetOrSetAsync(string key, Func> getItemCallback, TimeSpan cacheDuration) { - _logger.LogInformation(key + "GetOrSetAsync function start!"); - if (_cache.TryGetValue(key, out T cachedItem)) + using (var scope = _serviceScopeFactory.CreateAsyncScope()) { - _logger.LogInformation(key + "TryGetValue function true"); - return cachedItem; - } - - _logger.LogInformation(key + "TryGetValue function false"); - SemaphoreSlim mylock = _locks.GetOrAdd(key, k => new SemaphoreSlim(1, 1)); - - await mylock.WaitAsync(); - - try - { - if (_cache.TryGetValue(key, out cachedItem)) + var logger = scope.ServiceProvider.GetRequiredService(); + logger.LogInformation(key + "GetOrSetAsync function start!"); + if (_cache.TryGetValue(key, out T cachedItem)) { - _logger.LogInformation(key + "TryGetValue function true"); + logger.LogInformation(key + "TryGetValue function true"); return cachedItem; } - _logger.LogInformation(key + "TryGetValue function false"); - T item = await getItemCallback(); + logger.LogInformation(key + "TryGetValue function false"); + SemaphoreSlim mylock = _locks.GetOrAdd(key, k => new SemaphoreSlim(1, 1)); + + await mylock.WaitAsync(); - var cacheEntryOptions = new MemoryCacheEntryOptions + try { - AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30), - SlidingExpiration = cacheDuration, - Priority = CacheItemPriority.Normal, - }; + if (_cache.TryGetValue(key, out cachedItem)) + { + logger.LogInformation(key + "TryGetValue function true"); + return cachedItem; + } - _cache.Set(key, item, cacheEntryOptions); - _logger.LogInformation(key + "Set function true"); - return item; - } - finally - { - mylock.Release(); + logger.LogInformation(key + "TryGetValue function false"); + T item = await getItemCallback(); + + var cacheEntryOptions = new MemoryCacheEntryOptions + { + AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30), + SlidingExpiration = cacheDuration, + Priority = CacheItemPriority.Normal, + }; + + _cache.Set(key, item, cacheEntryOptions); + logger.LogInformation(key + "Set function true"); + return item; + } + finally + { + mylock.Release(); + } } } diff --git a/Streetcode/Streetcode.WebApi/Extensions/RecurringJobExtensions.cs b/Streetcode/Streetcode.WebApi/Extensions/RecurringJobExtensions.cs index e6d5eadee..d7b54f094 100644 --- a/Streetcode/Streetcode.WebApi/Extensions/RecurringJobExtensions.cs +++ b/Streetcode/Streetcode.WebApi/Extensions/RecurringJobExtensions.cs @@ -1,4 +1,5 @@ using Hangfire; +using Microsoft.Extensions.DependencyInjection; using Streetcode.BLL.Interfaces.Audio; using Streetcode.BLL.Interfaces.Image; @@ -8,23 +9,33 @@ public static class RecurringJobExtensions { public static void AddCleanAudiosJob(this WebApplication app) { - var recurringJobManager = app.Services.GetService(); + var serviceScopeFactory = app.Services.GetService(); + using (var scope = serviceScopeFactory.CreateScope()) + { + var recurringJobManager = scope.ServiceProvider.GetService(); + var audioService = scope.ServiceProvider.GetService(); - recurringJobManager.AddOrUpdate( - "Clean audio that are not used in streetcodes", - () => app.Services.GetService().CleanUnusedAudiosAsync(), - app.Configuration.GetSection("RecurringJobs")["AudioCleaningFrequency"], - TimeZoneInfo.Utc); + recurringJobManager.AddOrUpdate( + "Clean audio that are not used in streetcodes", + () => audioService.CleanUnusedAudiosAsync(), + app.Configuration.GetSection("RecurringJobs")["AudioCleaningFrequency"], + TimeZoneInfo.Utc); + } } public static void AddCleanImagesJob(this WebApplication app) { - var recurringJobManager = app.Services.GetService(); + var serviceScopeFactory = app.Services.GetService(); + using (var scope = serviceScopeFactory.CreateScope()) + { + var recurringJobManager = scope.ServiceProvider.GetService(); + var imageService = scope.ServiceProvider.GetService(); - recurringJobManager.AddOrUpdate( - "Clean images that are not used", - () => app.Services.GetService().CleanUnusedImagesAsync(), - app.Configuration.GetSection("RecurringJobs")["ImageCleaningFrequency"], - TimeZoneInfo.Utc); + recurringJobManager.AddOrUpdate( + "Clean images that are not used", + () => imageService.CleanUnusedImagesAsync(), + app.Configuration.GetSection("RecurringJobs")["ImageCleaningFrequency"], + TimeZoneInfo.Utc); + } } } \ No newline at end of file diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/SubtitleControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/SubtitleControllerTests.cs index ae2e6cb3c..4f8b6afae 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/SubtitleControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/SubtitleControllerTests.cs @@ -48,9 +48,10 @@ public async Task GetById_Incorrect_ReturnBadRequest() { int incorrectId = -100; var response = await this.client.GetByIdAsync(incorrectId); + Assert.Multiple( () => Assert.False(response.IsSuccessStatusCode), - () => Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode)); + () => Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode)); } [Fact] diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs index fd18b84e1..c3aae4cd6 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs @@ -50,7 +50,7 @@ public async Task GetByIdIncorrect_ReturnBadRequest() var response = await client.GetByIdAsync(incorrectId); Assert.Multiple( - () => Assert.Equal(System.Net.HttpStatusCode.BadRequest, response.StatusCode), + () => Assert.Equal(System.Net.HttpStatusCode.InternalServerError, response.StatusCode), () => Assert.False(response.IsSuccessStatusCode)); } @@ -74,7 +74,7 @@ public async Task GetByStreetcodeId_Incorrect_ReturnBadRequest() var response = await client.GetByStreetcodeId(streetcodeId); Assert.Multiple( - () => Assert.Equal(System.Net.HttpStatusCode.BadRequest, response.StatusCode), + () => Assert.Equal(System.Net.HttpStatusCode.InternalServerError, response.StatusCode), () => Assert.False(response.IsSuccessStatusCode)); } @@ -101,7 +101,7 @@ public async Task GetByTitle_Incorrect_ReturnBadRequest() var response = await client.GetResponse($"/GetTagByTitle/{title}"); Assert.Multiple( - () => Assert.Equal(System.Net.HttpStatusCode.BadRequest, response.StatusCode), + () => Assert.Equal(System.Net.HttpStatusCode.InternalServerError, response.StatusCode), () => Assert.False(response.IsSuccessStatusCode)); } } From 29ada6a038d99fc9b14bd7a0875d8944569ec0de Mon Sep 17 00:00:00 2001 From: ValDekh Date: Tue, 14 Nov 2023 09:43:47 +0200 Subject: [PATCH 04/27] Fix some tests --- .../Subtitle/GetById/GetSubtitleByIdHandler.cs | 3 ++- .../GetByStreetcodeId/GetTagByStreetcodeIdHandler.cs | 2 +- .../Services/BlobStorageService/BlobService.cs | 2 +- Streetcode/Streetcode.DAL/Streetcode.DAL.csproj | 8 ++++---- .../Streetcode.WebApi/Controllers/BaseApiController.cs | 10 +--------- Streetcode/Streetcode.WebApi/Streetcode.WebApi.csproj | 4 ++-- .../appsettings.IntegrationTests.json | 2 +- .../AdditionalContent/SubtitleControllerTests.cs | 2 +- .../AdditionalContent/TagControllerTests.cs | 6 +++--- .../ControllerTests/Utils/StreetcodeClient.cs | 6 +++--- .../Streetcode.XIntegrationTest.csproj | 8 ++++++-- 11 files changed, 25 insertions(+), 28 deletions(-) diff --git a/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Subtitle/GetById/GetSubtitleByIdHandler.cs b/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Subtitle/GetById/GetSubtitleByIdHandler.cs index 7ac406b46..45d0ffedd 100644 --- a/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Subtitle/GetById/GetSubtitleByIdHandler.cs +++ b/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Subtitle/GetById/GetSubtitleByIdHandler.cs @@ -33,7 +33,8 @@ public async Task> Handle(GetSubtitleByIdQuery request, Canc { string errorMsg = _stringLocalizerCannotFind["CannotFindSubtitleWithCorrespondingId", request.Id].Value; _logger.LogError(request, errorMsg); - return Result.Fail(new Error(errorMsg)); + var returner = Result.Fail(new Error(errorMsg)); + return returner; } return Result.Ok(_mapper.Map(subtitle)); diff --git a/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Tag/GetByStreetcodeId/GetTagByStreetcodeIdHandler.cs b/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Tag/GetByStreetcodeId/GetTagByStreetcodeIdHandler.cs index ba90938a0..dca718fc1 100644 --- a/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Tag/GetByStreetcodeId/GetTagByStreetcodeIdHandler.cs +++ b/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Tag/GetByStreetcodeId/GetTagByStreetcodeIdHandler.cs @@ -34,7 +34,7 @@ public async Task>> Handle(GetTagByStreetco t => t.StreetcodeId == request.StreetcodeId, include: q => q.Include(t => t.Tag)); - if (tagIndexed is null || !tagIndexed.Any()) + if (tagIndexed is null) { string errorMsg = _stringLocalizerCannotFind?["CannotFindAnyTagByTheStreetcodeId", request.StreetcodeId].Value; _logger.LogError(request, errorMsg); diff --git a/Streetcode/Streetcode.BLL/Services/BlobStorageService/BlobService.cs b/Streetcode/Streetcode.BLL/Services/BlobStorageService/BlobService.cs index 20cb2a9fb..953a71c1b 100644 --- a/Streetcode/Streetcode.BLL/Services/BlobStorageService/BlobService.cs +++ b/Streetcode/Streetcode.BLL/Services/BlobStorageService/BlobService.cs @@ -61,7 +61,7 @@ public string SaveFileInStorage(string base64, string name, string extension) public void SaveFileInStorageBase64(string base64, string name, string extension) { - byte[] imageBytes = Convert.FromBase64String(base64); + byte[] imageBytes = Convert.FromBase64String(base64.Trim()); Directory.CreateDirectory(_blobPath); EncryptFile(imageBytes, extension, name); } diff --git a/Streetcode/Streetcode.DAL/Streetcode.DAL.csproj b/Streetcode/Streetcode.DAL/Streetcode.DAL.csproj index a5023d288..269fe874a 100644 --- a/Streetcode/Streetcode.DAL/Streetcode.DAL.csproj +++ b/Streetcode/Streetcode.DAL/Streetcode.DAL.csproj @@ -10,14 +10,14 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Streetcode/Streetcode.WebApi/Controllers/BaseApiController.cs b/Streetcode/Streetcode.WebApi/Controllers/BaseApiController.cs index 09c850a7a..05c90c1e9 100644 --- a/Streetcode/Streetcode.WebApi/Controllers/BaseApiController.cs +++ b/Streetcode/Streetcode.WebApi/Controllers/BaseApiController.cs @@ -34,15 +34,7 @@ protected ActionResult HandleResult(Result result) } return (result.Value is null) ? - NotFound(_stringLocalizer["NotFound"].Value) : Ok(result.Value); - } - - foreach (var item in result.Reasons) - { - if (item.Message.Contains(_stringLocalizer?["NotFound"].Value)) - { - return Ok(); - } + NotFound("Not Found") : Ok(result.Value); } return BadRequest(result.Reasons); diff --git a/Streetcode/Streetcode.WebApi/Streetcode.WebApi.csproj b/Streetcode/Streetcode.WebApi/Streetcode.WebApi.csproj index e04a3f4e5..6a4bb3a68 100644 --- a/Streetcode/Streetcode.WebApi/Streetcode.WebApi.csproj +++ b/Streetcode/Streetcode.WebApi/Streetcode.WebApi.csproj @@ -22,8 +22,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json index cef30441a..f7a4e935c 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json +++ b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json @@ -1,7 +1,7 @@ { "ConnectionStrings": { //"DefaultConnection": "Server=DESKTOP-I7Q35NQ\\SQLEXPRESS;Database=StreetcodeDbtest;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true;TrustServerCertificate=true" - "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDb;Integrated Security=True" + "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" }, "Blob": { "BlobStoreKey": "BigThirtyTwoBiteCoolTestKeyCrypt", diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/SubtitleControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/SubtitleControllerTests.cs index 4f8b6afae..3005adfef 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/SubtitleControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/SubtitleControllerTests.cs @@ -51,7 +51,7 @@ public async Task GetById_Incorrect_ReturnBadRequest() Assert.Multiple( () => Assert.False(response.IsSuccessStatusCode), - () => Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode)); + () => Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode)); } [Fact] diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs index c3aae4cd6..fd18b84e1 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs @@ -50,7 +50,7 @@ public async Task GetByIdIncorrect_ReturnBadRequest() var response = await client.GetByIdAsync(incorrectId); Assert.Multiple( - () => Assert.Equal(System.Net.HttpStatusCode.InternalServerError, response.StatusCode), + () => Assert.Equal(System.Net.HttpStatusCode.BadRequest, response.StatusCode), () => Assert.False(response.IsSuccessStatusCode)); } @@ -74,7 +74,7 @@ public async Task GetByStreetcodeId_Incorrect_ReturnBadRequest() var response = await client.GetByStreetcodeId(streetcodeId); Assert.Multiple( - () => Assert.Equal(System.Net.HttpStatusCode.InternalServerError, response.StatusCode), + () => Assert.Equal(System.Net.HttpStatusCode.BadRequest, response.StatusCode), () => Assert.False(response.IsSuccessStatusCode)); } @@ -101,7 +101,7 @@ public async Task GetByTitle_Incorrect_ReturnBadRequest() var response = await client.GetResponse($"/GetTagByTitle/{title}"); Assert.Multiple( - () => Assert.Equal(System.Net.HttpStatusCode.InternalServerError, response.StatusCode), + () => Assert.Equal(System.Net.HttpStatusCode.BadRequest, response.StatusCode), () => Assert.False(response.IsSuccessStatusCode)); } } diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs index a58f0fd5d..17bc52572 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs @@ -10,7 +10,7 @@ public class StreetcodeClient public string SecondPartUrl { get; } - public StreetcodeClient(HttpClient client, string secondPartUrl = "") + public StreetcodeClient(HttpClient client, string secondPartUrl = "") { this.Client = new RestClient(client) { AcceptedContentTypes=ContentType.JsonAccept }; this.SecondPartUrl = secondPartUrl; @@ -36,8 +36,8 @@ public async Task GetResponse(string requestString) var request = new RestRequest($"{this.SecondPartUrl}{requestString}"); request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; }; request.AddHeader("content-type", "application/json"); - - return await this.Client.ExecuteGetAsync(request); + var returns = await this.Client.ExecuteGetAsync(request); + return returns; } } diff --git a/Streetcode/Streetcode.XIntegrationTest/Streetcode.XIntegrationTest.csproj b/Streetcode/Streetcode.XIntegrationTest/Streetcode.XIntegrationTest.csproj index 8758e2555..dc5ce722e 100644 --- a/Streetcode/Streetcode.XIntegrationTest/Streetcode.XIntegrationTest.csproj +++ b/Streetcode/Streetcode.XIntegrationTest/Streetcode.XIntegrationTest.csproj @@ -13,9 +13,13 @@ - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + From 6647f17c3b8a0d78b326a241ff9d5f63729d6e3b Mon Sep 17 00:00:00 2001 From: ValDekh Date: Fri, 17 Nov 2023 14:48:02 +0200 Subject: [PATCH 05/27] Add some changes --- .../ControllerTests/Media/Images/ArtControllerTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/ArtControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/ArtControllerTests.cs index add60c2b3..cf98686c7 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/ArtControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/ArtControllerTests.cs @@ -17,7 +17,7 @@ public ArtControllerTests(CustomWebApplicationFactory factory) [Fact] public async Task GetAll_ReturnSuccessStatusCode() { - var response = await client.GetAllAsync(); + var response = await this.client.GetAllAsync(); var returnedValue = CaseIsensitiveJsonDeserializer.Deserialize>(response.Content); Assert.True(response.IsSuccessStatusCode); @@ -45,7 +45,7 @@ public async Task GetById_ReturnSuccessStatusCode() public async Task GetById_Incorrect_ReturnBadRequest() { int id = -100; - var response = await client.GetByIdAsync(id); + var response = await this.client.GetByIdAsync(id); Assert.Multiple( () => Assert.Equal(System.Net.HttpStatusCode.BadRequest, response.StatusCode), @@ -57,7 +57,7 @@ public async Task GetById_Incorrect_ReturnBadRequest() public async Task GetByStreetcodeId_ReturnSuccessStatusCode() { int streetcodeId = ExtractTestStreetcode.StreetcodeForTest.Id; - var response = await client.GetByStreetcodeId(streetcodeId); + var response = await this.client.GetByStreetcodeId(streetcodeId); var returnedValue = CaseIsensitiveJsonDeserializer.Deserialize>(response.Content); Assert.True(response.IsSuccessStatusCode); From 09b3db86a7943f6bbc42ccc2a731eef857ade6e1 Mon Sep 17 00:00:00 2001 From: Valerii Dekhtiuk Date: Sat, 18 Nov 2023 14:36:54 +0200 Subject: [PATCH 06/27] Fix all Integration tests --- .../GetTagByStreetcodeIdHandler.cs | 2 +- .../GetArtsByStreetcodeIdHandler.cs | 2 +- .../GetImageByStreetcodeIdHandler.cs | 2 +- .../GetStreetcodeArtByStreetcodeIdHandler.cs | 2 +- .../Streetcode.DAL/Streetcode.DAL.csproj | 2 +- .../Controllers/Media/Images/ArtController.cs | 2 +- .../Streetcode.WebApi.csproj | 2 +- .../Streetcode.WebApi/appsettings.Local.json | 2 +- Streetcode/Streetcode.WebApi/appsettings.json | 2 +- .../AdditionalContent/TagControllerTests.cs | 1 + .../Media/Images/ArtControllerTests.cs | 8 +++--- .../AdditionalContent/Tag/ExtractTestTag.cs | 5 ++-- .../Tag/StreetcodeTagIndexSetup.cs | 26 +++++++++++++++++++ .../Streetcode/ExtractTestStreetcode.cs | 3 ++- .../ControllerTests/Utils/StreetcodeClient.cs | 5 ++++ .../Streetcode.XIntegrationTest.csproj | 2 +- 16 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/StreetcodeTagIndexSetup.cs diff --git a/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Tag/GetByStreetcodeId/GetTagByStreetcodeIdHandler.cs b/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Tag/GetByStreetcodeId/GetTagByStreetcodeIdHandler.cs index dca718fc1..730e1bb75 100644 --- a/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Tag/GetByStreetcodeId/GetTagByStreetcodeIdHandler.cs +++ b/Streetcode/Streetcode.BLL/MediatR/AdditionalContent/Tag/GetByStreetcodeId/GetTagByStreetcodeIdHandler.cs @@ -34,7 +34,7 @@ public async Task>> Handle(GetTagByStreetco t => t.StreetcodeId == request.StreetcodeId, include: q => q.Include(t => t.Tag)); - if (tagIndexed is null) + if (tagIndexed is null || request.StreetcodeId < 1) { string errorMsg = _stringLocalizerCannotFind?["CannotFindAnyTagByTheStreetcodeId", request.StreetcodeId].Value; _logger.LogError(request, errorMsg); diff --git a/Streetcode/Streetcode.BLL/MediatR/Media/Art/GetByStreetcodeId/GetArtsByStreetcodeIdHandler.cs b/Streetcode/Streetcode.BLL/MediatR/Media/Art/GetByStreetcodeId/GetArtsByStreetcodeIdHandler.cs index be242a541..e1e8714be 100644 --- a/Streetcode/Streetcode.BLL/MediatR/Media/Art/GetByStreetcodeId/GetArtsByStreetcodeIdHandler.cs +++ b/Streetcode/Streetcode.BLL/MediatR/Media/Art/GetByStreetcodeId/GetArtsByStreetcodeIdHandler.cs @@ -48,7 +48,7 @@ public async Task>> Handle(GetArtsByStreetcodeIdQuery include: scl => scl .Include(sc => sc.Image) !); - if (arts is null) + if (arts is null || request.StreetcodeId < 1) { string errorMsg = _stringLocalizerCannotFind["CannotFindAnyArtWithCorrespondingStreetcodeId", request.StreetcodeId].Value; _logger.LogError(request, errorMsg); diff --git a/Streetcode/Streetcode.BLL/MediatR/Media/Image/GetByStreetcodeId/GetImageByStreetcodeIdHandler.cs b/Streetcode/Streetcode.BLL/MediatR/Media/Image/GetByStreetcodeId/GetImageByStreetcodeIdHandler.cs index 80e494ff2..15482634c 100644 --- a/Streetcode/Streetcode.BLL/MediatR/Media/Image/GetByStreetcodeId/GetImageByStreetcodeIdHandler.cs +++ b/Streetcode/Streetcode.BLL/MediatR/Media/Image/GetByStreetcodeId/GetImageByStreetcodeIdHandler.cs @@ -46,7 +46,7 @@ public async Task>> Handle(GetImageByStreetcodeIdQu f => f.Streetcodes.Any(s => s.Id == request.StreetcodeId), include: q => q.Include(img => img.ImageDetails))).OrderBy(img => img.ImageDetails?.Alt); - if (images is null || images.Count() == 0) + if (images is null || request.StreetcodeId < 1) { string errorMsg = _stringLocalizerCannotFind["CannotFindAnImageWithTheCorrespondingStreetcodeId", request.StreetcodeId].Value; _logger.LogError(request, errorMsg); diff --git a/Streetcode/Streetcode.BLL/MediatR/Media/StreetcodeArt/GetByStreetcodeId/GetStreetcodeArtByStreetcodeIdHandler.cs b/Streetcode/Streetcode.BLL/MediatR/Media/StreetcodeArt/GetByStreetcodeId/GetStreetcodeArtByStreetcodeIdHandler.cs index 4097c3c51..2c68bc90d 100644 --- a/Streetcode/Streetcode.BLL/MediatR/Media/StreetcodeArt/GetByStreetcodeId/GetStreetcodeArtByStreetcodeIdHandler.cs +++ b/Streetcode/Streetcode.BLL/MediatR/Media/StreetcodeArt/GetByStreetcodeId/GetStreetcodeArtByStreetcodeIdHandler.cs @@ -52,7 +52,7 @@ public async Task>> Handle(GetStreetcodeArt .Include(a => a.Art) .Include(i => i.Art.Image) !); - if (art is null) + if (art is null || request.StreetcodeId < 1) { string errorMsg = _stringLocalizerCannotFind["CannotFindAnyArtWithCorrespondingStreetcodeId", request.StreetcodeId].Value; _logger.LogError(request, errorMsg); diff --git a/Streetcode/Streetcode.DAL/Streetcode.DAL.csproj b/Streetcode/Streetcode.DAL/Streetcode.DAL.csproj index 269fe874a..635e4acf8 100644 --- a/Streetcode/Streetcode.DAL/Streetcode.DAL.csproj +++ b/Streetcode/Streetcode.DAL/Streetcode.DAL.csproj @@ -16,7 +16,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Streetcode/Streetcode.WebApi/Controllers/Media/Images/ArtController.cs b/Streetcode/Streetcode.WebApi/Controllers/Media/Images/ArtController.cs index 713044b2f..365b40389 100644 --- a/Streetcode/Streetcode.WebApi/Controllers/Media/Images/ArtController.cs +++ b/Streetcode/Streetcode.WebApi/Controllers/Media/Images/ArtController.cs @@ -22,7 +22,7 @@ public async Task GetById([FromRoute] int id) } [HttpGet("{streetcodeId:int}")] - public async Task GetAllByStreetcodeId([FromRoute] int streetcodeId) + public async Task GetArtsByStreetcodeId([FromRoute] int streetcodeId) { return HandleResult(await Mediator.Send(new GetArtsByStreetcodeIdQuery(streetcodeId))); } diff --git a/Streetcode/Streetcode.WebApi/Streetcode.WebApi.csproj b/Streetcode/Streetcode.WebApi/Streetcode.WebApi.csproj index 6a4bb3a68..001252458 100644 --- a/Streetcode/Streetcode.WebApi/Streetcode.WebApi.csproj +++ b/Streetcode/Streetcode.WebApi/Streetcode.WebApi.csproj @@ -27,7 +27,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Streetcode/Streetcode.WebApi/appsettings.Local.json b/Streetcode/Streetcode.WebApi/appsettings.Local.json index 2cbc87149..d601c2601 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.Local.json +++ b/Streetcode/Streetcode.WebApi/appsettings.Local.json @@ -1,7 +1,7 @@ { "ConnectionStrings": { //"DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" - "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDb;Integrated Security=True" + "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" }, "CORS": { "AllowedOrigins": [ "http://localhost:3000" ], diff --git a/Streetcode/Streetcode.WebApi/appsettings.json b/Streetcode/Streetcode.WebApi/appsettings.json index d40592566..0de60b4d1 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.json +++ b/Streetcode/Streetcode.WebApi/appsettings.json @@ -1,7 +1,7 @@ { "ConnectionStrings": { //"DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" - "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDb;Integrated Security=True" + "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" }, "EmailConfiguration": { "From": "streetcodefordev@gmail.com", diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs index fd18b84e1..e28dfa36b 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs @@ -59,6 +59,7 @@ public async Task GetByIdIncorrect_ReturnBadRequest() [ExtractTestTag] public async Task GetByStreetcodeId_ReturnSuccessStatusCode() { + StreetcodeTagIndexSetup.Setup(ExtractTestStreetcode.StreetcodeForTest, ExtractTestTag.TagForTest); int streetcodeId = ExtractTestStreetcode.StreetcodeForTest.Id; var response = await client.GetByStreetcodeId(streetcodeId); var returnedValue = CaseIsensitiveJsonDeserializer.Deserialize>(response.Content); diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/ArtControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/ArtControllerTests.cs index cf98686c7..4fdda4f68 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/ArtControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/ArtControllerTests.cs @@ -54,10 +54,10 @@ public async Task GetById_Incorrect_ReturnBadRequest() [Fact] [ExtractTestStreetcode] - public async Task GetByStreetcodeId_ReturnSuccessStatusCode() + public async Task GetArtsByStreetcodeId_ReturnSuccessStatusCode() { int streetcodeId = ExtractTestStreetcode.StreetcodeForTest.Id; - var response = await this.client.GetByStreetcodeId(streetcodeId); + var response = await this.client.GetArtsByStreetcodeId(streetcodeId); var returnedValue = CaseIsensitiveJsonDeserializer.Deserialize>(response.Content); Assert.True(response.IsSuccessStatusCode); @@ -65,11 +65,11 @@ public async Task GetByStreetcodeId_ReturnSuccessStatusCode() } [Fact] - public async Task GetByStreetcodeId_Incorrect_BadResult() + public async Task GetArtsByStreetcodeId_Incorrect_BadResult() { int streetcodeId = -100; - var response = await this.client.GetByStreetcodeId(streetcodeId); + var response = await this.client.GetArtsByStreetcodeId(streetcodeId); Assert.Multiple( () => Assert.Equal(System.Net.HttpStatusCode.BadRequest, response.StatusCode), diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/ExtractTestTag.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/ExtractTestTag.cs index 65c6c8352..33d3b63b2 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/ExtractTestTag.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/ExtractTestTag.cs @@ -1,4 +1,5 @@ -using System.Reflection; +using Streetcode.DAL.Entities.AdditionalContent; +using System.Reflection; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Tag @@ -17,7 +18,7 @@ public override void Before(MethodInfo methodUnderTest) TagForTest = sqlDbHelper.AddNewItem( new DAL.Entities.AdditionalContent.Tag() { - Title = "TagTitle", + Title = "TagTitle_NEW!!!", }); sqlDbHelper.SaveChanges(); } diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/StreetcodeTagIndexSetup.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/StreetcodeTagIndexSetup.cs new file mode 100644 index 000000000..41f223b91 --- /dev/null +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/StreetcodeTagIndexSetup.cs @@ -0,0 +1,26 @@ +using Streetcode.DAL.Entities.AdditionalContent; +using Streetcode.DAL.Entities.Streetcode; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Tag +{ + public class StreetcodeTagIndexSetup + { + public static void Setup(StreetcodeContent streetcodeForTest, DAL.Entities.AdditionalContent.Tag tagForTest) + { + var sqlDbHelper = BaseControllerTests.GetSqlDbHelper(); + var existingIndex = sqlDbHelper.GetExistItem( + index => index.StreetcodeId == streetcodeForTest.Id && index.TagId == tagForTest.Id); + if (existingIndex == null) + { + var streetcodeTagIndex = new StreetcodeTagIndex { TagId = tagForTest.Id, StreetcodeId = streetcodeForTest.Id }; + sqlDbHelper.AddNewItem(streetcodeTagIndex); + sqlDbHelper.SaveChanges(); + } + } + } +} diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs index 32f16ad51..4d7546b39 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs @@ -1,4 +1,5 @@ -using Streetcode.DAL.Entities.Streetcode; +using Streetcode.DAL.Entities.AdditionalContent; +using Streetcode.DAL.Entities.Streetcode; using System.Reflection; using Xunit.Sdk; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs index 17bc52572..97e3eee4c 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs @@ -31,6 +31,11 @@ public async Task GetByStreetcodeId(int id) return await this.GetResponse($"/getByStreetcodeId/{id}"); } + public async Task GetArtsByStreetcodeId(int id) + { + return await this.GetResponse($"/getArtsByStreetcodeId/{id}"); + } + public async Task GetResponse(string requestString) { var request = new RestRequest($"{this.SecondPartUrl}{requestString}"); diff --git a/Streetcode/Streetcode.XIntegrationTest/Streetcode.XIntegrationTest.csproj b/Streetcode/Streetcode.XIntegrationTest/Streetcode.XIntegrationTest.csproj index dc5ce722e..9e022df0c 100644 --- a/Streetcode/Streetcode.XIntegrationTest/Streetcode.XIntegrationTest.csproj +++ b/Streetcode/Streetcode.XIntegrationTest/Streetcode.XIntegrationTest.csproj @@ -15,7 +15,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 510a12a98cdcc8cdab26f1509d3d01046a8ca3b0 Mon Sep 17 00:00:00 2001 From: Valerii Dekhtiuk Date: Sat, 18 Nov 2023 14:39:21 +0200 Subject: [PATCH 07/27] Return all appSetting.json --- Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json | 3 +-- Streetcode/Streetcode.WebApi/appsettings.Local.json | 3 +-- Streetcode/Streetcode.WebApi/appsettings.json | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json index f7a4e935c..53cd46a8b 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json +++ b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json @@ -1,7 +1,6 @@ { "ConnectionStrings": { - //"DefaultConnection": "Server=DESKTOP-I7Q35NQ\\SQLEXPRESS;Database=StreetcodeDbtest;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true;TrustServerCertificate=true" - "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" + "DefaultConnection": "Server=DESKTOP-I7Q35NQ\\SQLEXPRESS;Database=StreetcodeDbtest;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true;TrustServerCertificate=true" }, "Blob": { "BlobStoreKey": "BigThirtyTwoBiteCoolTestKeyCrypt", diff --git a/Streetcode/Streetcode.WebApi/appsettings.Local.json b/Streetcode/Streetcode.WebApi/appsettings.Local.json index d601c2601..14b44479d 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.Local.json +++ b/Streetcode/Streetcode.WebApi/appsettings.Local.json @@ -1,7 +1,6 @@ { "ConnectionStrings": { - //"DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" - "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" + "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" }, "CORS": { "AllowedOrigins": [ "http://localhost:3000" ], diff --git a/Streetcode/Streetcode.WebApi/appsettings.json b/Streetcode/Streetcode.WebApi/appsettings.json index 0de60b4d1..c66f7473d 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.json +++ b/Streetcode/Streetcode.WebApi/appsettings.json @@ -1,7 +1,6 @@ { "ConnectionStrings": { - //"DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" - "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" + "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" }, "EmailConfiguration": { "From": "streetcodefordev@gmail.com", From 6a9606aaf8dbca86022458d5467df10803fcdd04 Mon Sep 17 00:00:00 2001 From: ValDekh Date: Tue, 28 Nov 2023 11:31:11 +0200 Subject: [PATCH 08/27] Delete CleanBlobService and its test. Clean BaseApiController --- .../BlobStorageService/BlobService.cs | 20 -------- .../Controllers/BaseApiController.cs | 13 ++--- .../CleanBlobTest/CleanBlobServiceTests.cs | 49 ------------------- 3 files changed, 3 insertions(+), 79 deletions(-) delete mode 100644 Streetcode/Streetcode.XIntegrationTest/ServiceTests/BlobServiceTests/CleanBlobTest/CleanBlobServiceTests.cs diff --git a/Streetcode/Streetcode.BLL/Services/BlobStorageService/BlobService.cs b/Streetcode/Streetcode.BLL/Services/BlobStorageService/BlobService.cs index 953a71c1b..fe7c38330 100644 --- a/Streetcode/Streetcode.BLL/Services/BlobStorageService/BlobService.cs +++ b/Streetcode/Streetcode.BLL/Services/BlobStorageService/BlobService.cs @@ -87,26 +87,6 @@ public string UpdateFileInStorage( return hashBlobStorageName; } - public async Task CleanBlobStorage() - { - var base64Files = GetAllBlobNames(); - - var existingImagesInDatabase = await _repositoryWrapper.ImageRepository.GetAllAsync(); - var existingAudiosInDatabase = await _repositoryWrapper.AudioRepository.GetAllAsync(); - - List existingMedia = new (); - existingMedia.AddRange(existingImagesInDatabase.Select(img => img.BlobName)); - existingMedia.AddRange(existingAudiosInDatabase.Select(img => img.BlobName)); - - var filesToRemove = base64Files.Except(existingMedia).ToList(); - - foreach (var file in filesToRemove) - { - Console.WriteLine($"Deleting {file}..."); - DeleteFileInStorage(file); - } - } - private IEnumerable GetAllBlobNames() { var paths = Directory.EnumerateFiles(_blobPath); diff --git a/Streetcode/Streetcode.WebApi/Controllers/BaseApiController.cs b/Streetcode/Streetcode.WebApi/Controllers/BaseApiController.cs index a0b27654f..1c0c2e19d 100644 --- a/Streetcode/Streetcode.WebApi/Controllers/BaseApiController.cs +++ b/Streetcode/Streetcode.WebApi/Controllers/BaseApiController.cs @@ -1,8 +1,6 @@ -using System.Resources; -using FluentResults; +using FluentResults; using MediatR; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Localization; using Streetcode.BLL.MediatR.ResultVariations; namespace Streetcode.WebApi.Controllers; @@ -11,12 +9,7 @@ namespace Streetcode.WebApi.Controllers; [Route("api/[controller]/[action]")] public class BaseApiController : ControllerBase { - private readonly IStringLocalizer _stringLocalizer; private IMediator? _mediator; - public BaseApiController(IStringLocalizer stringLocalizer) - { - _stringLocalizer = stringLocalizer; - } public BaseApiController() { @@ -28,7 +21,7 @@ protected ActionResult HandleResult(Result result) { if (result.IsSuccess) { - if(result is NullResult) + if (result is NullResult) { return Ok(result.Value); } @@ -39,5 +32,5 @@ protected ActionResult HandleResult(Result result) } return BadRequest(result.Reasons); - } + } } \ No newline at end of file diff --git a/Streetcode/Streetcode.XIntegrationTest/ServiceTests/BlobServiceTests/CleanBlobTest/CleanBlobServiceTests.cs b/Streetcode/Streetcode.XIntegrationTest/ServiceTests/BlobServiceTests/CleanBlobTest/CleanBlobServiceTests.cs deleted file mode 100644 index 0369dc5a3..000000000 --- a/Streetcode/Streetcode.XIntegrationTest/ServiceTests/BlobServiceTests/CleanBlobTest/CleanBlobServiceTests.cs +++ /dev/null @@ -1,49 +0,0 @@ -//using Streetcode.DAL.Entities.Media.Images; -//using Streetcode.XIntegrationTest.Base; -//using Streetcode.XIntegrationTest.ServiceTests.BlobServiceTests.Utils; -//using Xunit; - -//namespace Streetcode.XIntegrationTest.ServiceTests.BlobServiceTests.CleanBlobTest -//{ -// public class CleanBlobServiceTests : BlobServiceTestBase, IClassFixture -// { -// private TestDBFixture DbFixture { get; } - -// public CleanBlobServiceTests(TestDBFixture fixture) : base(new BlobStorageFixture()) -// { -// DbFixture = fixture; -// } - -// [Theory] -// [InlineData("ED_kNMjZkMDz6_syM5klb8HGDyfU72Q6Sdz_Y4DmCJ8=.png")] -// public async Task ShouldRemoveUnusedFilesFromBlobStorage(string blobName) -// { -// // Arrange -// await _fixture.DbAndStorageSeeding(); -// Image imgToRemove = _fixture.TestDbContext.Images.FirstOrDefault(x => x.BlobName == blobName); -// _fixture.TestDbContext.Images.Remove(imgToRemove); -// await _fixture.TestDbContext.SaveChangesAsync(); - -// // Act -// await _fixture.blobService.CleanBlobStorage(); - -// // Assert -// Assert.False(File.Exists(_fixture.blobPath + blobName)); -// } - -// [Theory] -// [InlineData("ED_kNMjZkMDz6_syM5klb8HGDyfU72Q6Sdz_Y4DmCJ8=.png")] -// public async Task NothingToRemoveFromBlobStorage(string blobName) -// { -// // Arrange -// await _fixture.DbAndStorageSeeding(); -// Image imgToRemove = _fixture.TestDbContext.Images.FirstOrDefault(x => x.BlobName == blobName); - -// // Act -// await _fixture.blobService.CleanBlobStorage(); - -// // Assert -// Assert.True(File.Exists(_fixture.blobPath + blobName)); -// } -// } -//} From 5bdc0d6cac5ca1b10fdb91d7dc8e4509b617dd22 Mon Sep 17 00:00:00 2001 From: Valerii Dekhtiuk Date: Wed, 6 Dec 2023 01:21:08 +0200 Subject: [PATCH 09/27] Add appsetting json --- Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json | 2 +- Streetcode/Streetcode.WebApi/appsettings.Local.json | 2 +- Streetcode/Streetcode.WebApi/appsettings.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json index 53cd46a8b..4613c1ca2 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json +++ b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnection": "Server=DESKTOP-I7Q35NQ\\SQLEXPRESS;Database=StreetcodeDbtest;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true;TrustServerCertificate=true" + "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" }, "Blob": { "BlobStoreKey": "BigThirtyTwoBiteCoolTestKeyCrypt", diff --git a/Streetcode/Streetcode.WebApi/appsettings.Local.json b/Streetcode/Streetcode.WebApi/appsettings.Local.json index 14b44479d..04a90d070 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.Local.json +++ b/Streetcode/Streetcode.WebApi/appsettings.Local.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" + "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" }, "CORS": { "AllowedOrigins": [ "http://localhost:3000" ], diff --git a/Streetcode/Streetcode.WebApi/appsettings.json b/Streetcode/Streetcode.WebApi/appsettings.json index c66f7473d..2595d52b9 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.json +++ b/Streetcode/Streetcode.WebApi/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" + "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" }, "EmailConfiguration": { "From": "streetcodefordev@gmail.com", From 520e3dcd707f4db2fc6be1b556d9f7373c139c9f Mon Sep 17 00:00:00 2001 From: ValDekh Date: Wed, 6 Dec 2023 18:00:24 +0200 Subject: [PATCH 10/27] Add some cases --- .../Streetcode/StreetcodeControllerTests.cs | 23 +++++++++++++++++++ .../ControllerTests/Utils/StreetcodeClient.cs | 9 ++++++++ 2 files changed, 32 insertions(+) create mode 100644 Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs new file mode 100644 index 000000000..e04c4221c --- /dev/null +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs @@ -0,0 +1,23 @@ +using Streetcode.XIntegrationTest.ControllerTests.Utils; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xunit; + +namespace Streetcode.XIntegrationTest.ControllerTests.Streetcode +{ + public class StreetcodeControllerTests : + BaseControllerTests, IClassFixture> + { + public StreetcodeControllerTests(CustomWebApplicationFactory factory) + :base(factory, "/api/Streetcode") + { + + } + + + + } +} diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs index 97e3eee4c..f6b27cd67 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs @@ -1,7 +1,9 @@ namespace Streetcode.XIntegrationTest.ControllerTests.Utils { + using global::Streetcode.BLL.MediatR.Streetcode.Streetcode.Update; using RestSharp; using RestSharp.Serializers; + using Streetcode.BLL.MediatR.Streetcode.Streetcode.Update; using System.Threading.Tasks; public class StreetcodeClient @@ -45,5 +47,12 @@ public async Task GetResponse(string requestString) return returns; } + public async Task UpdateAsync(UpdateStreetcodeCommand updateStreetcodeCommand) + { + var request = new RestRequest($"{this.SecondPartUrl}/Update", Method.Put); + request.AddJsonBody(updateStreetcodeCommand); + var response = await this.Client.ExecuteAsync(request); + return response; + } } } From 1560f3f8d2cebf0fe35f608a4b8698e36929a0d5 Mon Sep 17 00:00:00 2001 From: Kateryna Yatsiuk <113370393+KateYatsiuk@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:12:47 +0200 Subject: [PATCH 11/27] Changed datestring max length to 100 instead of 50 (#901) --- .../Entities/Streetcode/StreetcodeContent.cs | 2 +- ...0231130202258_DatestringLength.Designer.cs | 1595 +++++++++++++++++ .../20231130202258_DatestringLength.cs | 37 + .../StreetcodeDbContextModelSnapshot.cs | 4 +- 4 files changed, 1635 insertions(+), 3 deletions(-) create mode 100644 Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.Designer.cs create mode 100644 Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.cs diff --git a/Streetcode/Streetcode.DAL/Entities/Streetcode/StreetcodeContent.cs b/Streetcode/Streetcode.DAL/Entities/Streetcode/StreetcodeContent.cs index 4514ce82a..e71306ebc 100644 --- a/Streetcode/Streetcode.DAL/Entities/Streetcode/StreetcodeContent.cs +++ b/Streetcode/Streetcode.DAL/Entities/Streetcode/StreetcodeContent.cs @@ -32,7 +32,7 @@ public class StreetcodeContent public string? Teaser { get; set; } [Required] - [MaxLength(50)] + [MaxLength(100)] public string? DateString { get; set; } [MaxLength(50)] diff --git a/Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.Designer.cs b/Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.Designer.cs new file mode 100644 index 000000000..7cfdfffaa --- /dev/null +++ b/Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.Designer.cs @@ -0,0 +1,1595 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Streetcode.DAL.Persistence; + +#nullable disable + +namespace Streetcode.DAL.Persistence.Migrations +{ + [DbContext(typeof(StreetcodeDbContext))] + [Migration("20231130202258_DatestringLength")] + partial class DatestringLength + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Ukrainian_CP1251_CI_AS") + .HasAnnotation("ProductVersion", "6.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Coordinate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CoordinateType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Latitude") + .HasColumnType("decimal(18,4)"); + + b.Property("Longtitude") + .HasColumnType("decimal(18,4)"); + + b.HasKey("Id"); + + b.ToTable("coordinates", "add_content"); + + b.HasDiscriminator("CoordinateType").HasValue("coordinate_base"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.StreetcodeTagIndex", b => + { + b.Property("StreetcodeId") + .HasColumnType("int"); + + b.Property("TagId") + .HasColumnType("int"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsVisible") + .HasColumnType("bit"); + + b.HasKey("StreetcodeId", "TagId"); + + b.HasIndex("TagId"); + + b.ToTable("streetcode_tag_index", "add_content"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Subtitle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("StreetcodeId") + .HasColumnType("int"); + + b.Property("SubtitleText") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("StreetcodeId"); + + b.ToTable("subtitles", "add_content"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("tags", "add_content"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Analytics.StatisticRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("QrId") + .HasColumnType("int"); + + b.Property("StreetcodeCoordinateId") + .HasColumnType("int"); + + b.Property("StreetcodeId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("StreetcodeCoordinateId") + .IsUnique(); + + b.HasIndex("StreetcodeId"); + + b.ToTable("qr_coordinates", "coordinates"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Feedback.Response", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("responses", "feedback"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Jobs.Job", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("Salary") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("Status") + .HasColumnType("bit"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(65) + .HasColumnType("nvarchar(65)"); + + b.HasKey("Id"); + + b.ToTable("job", "jobs"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Media.Audio", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("BlobName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("MimeType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Title") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("audios", "media"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.Art", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .HasMaxLength(400) + .HasColumnType("nvarchar(400)"); + + b.Property("ImageId") + .HasColumnType("int"); + + b.Property("Title") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.HasKey("Id"); + + b.HasIndex("ImageId") + .IsUnique(); + + b.ToTable("arts", "media"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.Image", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("BlobName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("MimeType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("Id"); + + b.ToTable("images", "media"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.ImageDetails", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Alt") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("ImageId") + .HasColumnType("int"); + + b.Property("Title") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("ImageId") + .IsUnique(); + + b.ToTable("image_details", "media"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.StreetcodeImage", b => + { + b.Property("ImageId") + .HasColumnType("int"); + + b.Property("StreetcodeId") + .HasColumnType("int"); + + b.HasKey("ImageId", "StreetcodeId"); + + b.HasIndex("StreetcodeId"); + + b.ToTable("streetcode_image", "streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Media.Video", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("StreetcodeId") + .HasColumnType("int"); + + b.Property("Title") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Url") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("StreetcodeId"); + + b.ToTable("videos", "media"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.News.News", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ImageId") + .HasColumnType("int"); + + b.Property("Text") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("URL") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("ImageId") + .IsUnique() + .HasFilter("[ImageId] IS NOT NULL"); + + b.HasIndex("URL") + .IsUnique(); + + b.ToTable("news", "news"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Partners.Partner", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .HasMaxLength(600) + .HasColumnType("nvarchar(600)"); + + b.Property("IsKeyPartner") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("IsVisibleEverywhere") + .HasColumnType("bit"); + + b.Property("LogoId") + .HasColumnType("int"); + + b.Property("TargetUrl") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UrlTitle") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("LogoId") + .IsUnique(); + + b.ToTable("partners", "partners"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Partners.PartnerSourceLink", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("LogoType") + .HasColumnType("tinyint"); + + b.Property("PartnerId") + .HasColumnType("int"); + + b.Property("TargetUrl") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("PartnerId"); + + b.ToTable("partner_source_links", "partners"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Partners.StreetcodePartner", b => + { + b.Property("PartnerId") + .HasColumnType("int"); + + b.Property("StreetcodeId") + .HasColumnType("int"); + + b.HasKey("PartnerId", "StreetcodeId"); + + b.HasIndex("StreetcodeId"); + + b.ToTable("streetcode_partners", "streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Sources.SourceLinkCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ImageId") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("ImageId"); + + b.ToTable("source_link_categories", "sources"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Sources.StreetcodeCategoryContent", b => + { + b.Property("SourceLinkCategoryId") + .HasColumnType("int"); + + b.Property("StreetcodeId") + .HasColumnType("int"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("nvarchar(max)"); + + b.HasKey("SourceLinkCategoryId", "StreetcodeId"); + + b.HasIndex("StreetcodeId"); + + b.ToTable("streetcode_source_link_categories", "sources"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.RelatedFigure", b => + { + b.Property("ObserverId") + .HasColumnType("int"); + + b.Property("TargetId") + .HasColumnType("int"); + + b.HasKey("ObserverId", "TargetId"); + + b.HasIndex("TargetId"); + + b.ToTable("related_figures", "streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.StreetcodeArt", b => + { + b.Property("ArtId") + .HasColumnType("int"); + + b.Property("StreetcodeId") + .HasColumnType("int"); + + b.Property("Index") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(1); + + b.HasKey("ArtId", "StreetcodeId"); + + b.HasIndex("StreetcodeId"); + + b.HasIndex("ArtId", "StreetcodeId"); + + b.ToTable("streetcode_art", "streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Alias") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("AudioId") + .HasColumnType("int"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime2") + .HasDefaultValueSql("GETDATE()"); + + b.Property("DateString") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("EventEndOrPersonDeathDate") + .HasColumnType("datetime2"); + + b.Property("EventStartOrPersonBirthDate") + .HasColumnType("datetime2"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StreetcodeType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Teaser") + .HasMaxLength(650) + .HasColumnType("nvarchar(650)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TransliterationUrl") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("UpdatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime2") + .HasDefaultValueSql("GETDATE()"); + + b.Property("ViewCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("AudioId") + .IsUnique() + .HasFilter("[AudioId] IS NOT NULL"); + + b.HasIndex("Index") + .IsUnique(); + + b.HasIndex("TransliterationUrl") + .IsUnique(); + + b.ToTable("streetcodes", "streetcode"); + + b.HasDiscriminator("StreetcodeType").HasValue("streetcode-base"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.Fact", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("FactContent") + .IsRequired() + .HasMaxLength(600) + .HasColumnType("nvarchar(600)"); + + b.Property("ImageId") + .HasColumnType("int"); + + b.Property("StreetcodeId") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("ImageId"); + + b.HasIndex("StreetcodeId"); + + b.ToTable("facts", "streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.RelatedTerm", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("TermId") + .HasColumnType("int"); + + b.Property("Word") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("TermId"); + + b.ToTable("related_terms", "streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.Term", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("terms", "streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.Text", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AdditionalText") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("StreetcodeId") + .HasColumnType("int"); + + b.Property("TextContent") + .IsRequired() + .HasMaxLength(15000) + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.HasKey("Id"); + + b.HasIndex("StreetcodeId") + .IsUnique(); + + b.ToTable("texts", "streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Team.Positions", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Position") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("positions", "team"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Team.TeamMember", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("ImageId") + .HasColumnType("int"); + + b.Property("IsMain") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ImageId") + .IsUnique(); + + b.ToTable("team_members", "team"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Team.TeamMemberLink", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("LogoType") + .HasColumnType("tinyint"); + + b.Property("TargetUrl") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("TeamMemberId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TeamMemberId"); + + b.ToTable("team_member_links", "team"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Team.TeamMemberPositions", b => + { + b.Property("TeamMemberId") + .HasColumnType("int"); + + b.Property("PositionsId") + .HasColumnType("int"); + + b.HasKey("TeamMemberId", "PositionsId"); + + b.HasIndex("PositionsId"); + + b.ToTable("team_member_positions", "team"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Timeline.HistoricalContext", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("historical_contexts", "timeline"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Timeline.HistoricalContextTimeline", b => + { + b.Property("TimelineId") + .HasColumnType("int"); + + b.Property("HistoricalContextId") + .HasColumnType("int"); + + b.HasKey("TimelineId", "HistoricalContextId"); + + b.HasIndex("HistoricalContextId"); + + b.ToTable("HistoricalContextsTimelines"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Timeline.TimelineItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DateViewPattern") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(600) + .HasColumnType("nvarchar(600)"); + + b.Property("StreetcodeId") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("StreetcodeId"); + + b.ToTable("timeline_items", "timeline"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Toponyms.StreetcodeToponym", b => + { + b.Property("StreetcodeId") + .HasColumnType("int"); + + b.Property("ToponymId") + .HasColumnType("int"); + + b.HasKey("StreetcodeId", "ToponymId"); + + b.HasIndex("ToponymId"); + + b.ToTable("streetcode_toponym", "streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Toponyms.Toponym", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AdminRegionNew") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("AdminRegionOld") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Community") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Gromada") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Oblast") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("StreetName") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("StreetType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("toponyms", "toponyms"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Transactions.TransactionLink", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("StreetcodeId") + .HasColumnType("int"); + + b.Property("Url") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UrlTitle") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("StreetcodeId") + .IsUnique(); + + b.ToTable("transaction_links", "transactions"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Users.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Login") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Role") + .HasColumnType("int"); + + b.Property("Surname") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Users", "Users"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types.StreetcodeCoordinate", b => + { + b.HasBaseType("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Coordinate"); + + b.Property("StreetcodeId") + .HasColumnType("int"); + + b.HasIndex("StreetcodeId"); + + b.ToTable("coordinates", "add_content"); + + b.HasDiscriminator().HasValue("coordinate_streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types.ToponymCoordinate", b => + { + b.HasBaseType("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Coordinate"); + + b.Property("ToponymId") + .HasColumnType("int"); + + b.HasIndex("ToponymId") + .IsUnique() + .HasFilter("[ToponymId] IS NOT NULL"); + + b.ToTable("coordinates", "add_content"); + + b.HasDiscriminator().HasValue("coordinate_toponym"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.Types.EventStreetcode", b => + { + b.HasBaseType("Streetcode.DAL.Entities.Streetcode.StreetcodeContent"); + + b.ToTable("streetcodes", "streetcode"); + + b.HasDiscriminator().HasValue("streetcode-event"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.Types.PersonStreetcode", b => + { + b.HasBaseType("Streetcode.DAL.Entities.Streetcode.StreetcodeContent"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Rank") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.ToTable("streetcodes", "streetcode"); + + b.HasDiscriminator().HasValue("streetcode-person"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.StreetcodeTagIndex", b => + { + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") + .WithMany("StreetcodeTagIndices") + .HasForeignKey("StreetcodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Streetcode.DAL.Entities.AdditionalContent.Tag", "Tag") + .WithMany("StreetcodeTagIndices") + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Streetcode"); + + b.Navigation("Tag"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Subtitle", b => + { + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") + .WithMany("Subtitles") + .HasForeignKey("StreetcodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Analytics.StatisticRecord", b => + { + b.HasOne("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types.StreetcodeCoordinate", "StreetcodeCoordinate") + .WithOne("StatisticRecord") + .HasForeignKey("Streetcode.DAL.Entities.Analytics.StatisticRecord", "StreetcodeCoordinateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") + .WithMany("StatisticRecords") + .HasForeignKey("StreetcodeId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("Streetcode"); + + b.Navigation("StreetcodeCoordinate"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.Art", b => + { + b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Image") + .WithOne("Art") + .HasForeignKey("Streetcode.DAL.Entities.Media.Images.Art", "ImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.ImageDetails", b => + { + b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Image") + .WithOne("ImageDetails") + .HasForeignKey("Streetcode.DAL.Entities.Media.Images.ImageDetails", "ImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.StreetcodeImage", b => + { + b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Image") + .WithMany() + .HasForeignKey("ImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") + .WithMany() + .HasForeignKey("StreetcodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Image"); + + b.Navigation("Streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Media.Video", b => + { + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") + .WithMany("Videos") + .HasForeignKey("StreetcodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.News.News", b => + { + b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Image") + .WithOne("News") + .HasForeignKey("Streetcode.DAL.Entities.News.News", "ImageId"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Partners.Partner", b => + { + b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Logo") + .WithOne("Partner") + .HasForeignKey("Streetcode.DAL.Entities.Partners.Partner", "LogoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Logo"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Partners.PartnerSourceLink", b => + { + b.HasOne("Streetcode.DAL.Entities.Partners.Partner", "Partner") + .WithMany("PartnerSourceLinks") + .HasForeignKey("PartnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Partner"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Partners.StreetcodePartner", b => + { + b.HasOne("Streetcode.DAL.Entities.Partners.Partner", "Partner") + .WithMany() + .HasForeignKey("PartnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") + .WithMany() + .HasForeignKey("StreetcodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Partner"); + + b.Navigation("Streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Sources.SourceLinkCategory", b => + { + b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Image") + .WithMany("SourceLinkCategories") + .HasForeignKey("ImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Sources.StreetcodeCategoryContent", b => + { + b.HasOne("Streetcode.DAL.Entities.Sources.SourceLinkCategory", "SourceLinkCategory") + .WithMany("StreetcodeCategoryContents") + .HasForeignKey("SourceLinkCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") + .WithMany("StreetcodeCategoryContents") + .HasForeignKey("StreetcodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SourceLinkCategory"); + + b.Navigation("Streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.RelatedFigure", b => + { + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Observer") + .WithMany("Observers") + .HasForeignKey("ObserverId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Target") + .WithMany("Targets") + .HasForeignKey("TargetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Observer"); + + b.Navigation("Target"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.StreetcodeArt", b => + { + b.HasOne("Streetcode.DAL.Entities.Media.Images.Art", "Art") + .WithMany("StreetcodeArts") + .HasForeignKey("ArtId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") + .WithMany("StreetcodeArts") + .HasForeignKey("StreetcodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Art"); + + b.Navigation("Streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", b => + { + b.HasOne("Streetcode.DAL.Entities.Media.Audio", "Audio") + .WithOne("Streetcode") + .HasForeignKey("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "AudioId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Audio"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.Fact", b => + { + b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Image") + .WithMany("Facts") + .HasForeignKey("ImageId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") + .WithMany("Facts") + .HasForeignKey("StreetcodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Image"); + + b.Navigation("Streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.RelatedTerm", b => + { + b.HasOne("Streetcode.DAL.Entities.Streetcode.TextContent.Term", "Term") + .WithMany("RelatedTerms") + .HasForeignKey("TermId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Term"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.Text", b => + { + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") + .WithOne("Text") + .HasForeignKey("Streetcode.DAL.Entities.Streetcode.TextContent.Text", "StreetcodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Team.TeamMember", b => + { + b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Image") + .WithOne("TeamMember") + .HasForeignKey("Streetcode.DAL.Entities.Team.TeamMember", "ImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Team.TeamMemberLink", b => + { + b.HasOne("Streetcode.DAL.Entities.Team.TeamMember", "TeamMember") + .WithMany("TeamMemberLinks") + .HasForeignKey("TeamMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TeamMember"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Team.TeamMemberPositions", b => + { + b.HasOne("Streetcode.DAL.Entities.Team.Positions", "Positions") + .WithMany() + .HasForeignKey("PositionsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Streetcode.DAL.Entities.Team.TeamMember", "TeamMember") + .WithMany() + .HasForeignKey("TeamMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Positions"); + + b.Navigation("TeamMember"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Timeline.HistoricalContextTimeline", b => + { + b.HasOne("Streetcode.DAL.Entities.Timeline.HistoricalContext", "HistoricalContext") + .WithMany("HistoricalContextTimelines") + .HasForeignKey("HistoricalContextId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Streetcode.DAL.Entities.Timeline.TimelineItem", "Timeline") + .WithMany("HistoricalContextTimelines") + .HasForeignKey("TimelineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("HistoricalContext"); + + b.Navigation("Timeline"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Timeline.TimelineItem", b => + { + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") + .WithMany("TimelineItems") + .HasForeignKey("StreetcodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Toponyms.StreetcodeToponym", b => + { + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") + .WithMany() + .HasForeignKey("StreetcodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Streetcode.DAL.Entities.Toponyms.Toponym", "Toponym") + .WithMany() + .HasForeignKey("ToponymId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Streetcode"); + + b.Navigation("Toponym"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Transactions.TransactionLink", b => + { + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") + .WithOne("TransactionLink") + .HasForeignKey("Streetcode.DAL.Entities.Transactions.TransactionLink", "StreetcodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types.StreetcodeCoordinate", b => + { + b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") + .WithMany("Coordinates") + .HasForeignKey("StreetcodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types.ToponymCoordinate", b => + { + b.HasOne("Streetcode.DAL.Entities.Toponyms.Toponym", "Toponym") + .WithOne("Coordinate") + .HasForeignKey("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types.ToponymCoordinate", "ToponymId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Toponym"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Tag", b => + { + b.Navigation("StreetcodeTagIndices"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Media.Audio", b => + { + b.Navigation("Streetcode"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.Art", b => + { + b.Navigation("StreetcodeArts"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.Image", b => + { + b.Navigation("Art"); + + b.Navigation("Facts"); + + b.Navigation("ImageDetails"); + + b.Navigation("News"); + + b.Navigation("Partner"); + + b.Navigation("SourceLinkCategories"); + + b.Navigation("TeamMember"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Partners.Partner", b => + { + b.Navigation("PartnerSourceLinks"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Sources.SourceLinkCategory", b => + { + b.Navigation("StreetcodeCategoryContents"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", b => + { + b.Navigation("Coordinates"); + + b.Navigation("Facts"); + + b.Navigation("Observers"); + + b.Navigation("StatisticRecords"); + + b.Navigation("StreetcodeArts"); + + b.Navigation("StreetcodeCategoryContents"); + + b.Navigation("StreetcodeTagIndices"); + + b.Navigation("Subtitles"); + + b.Navigation("Targets"); + + b.Navigation("Text"); + + b.Navigation("TimelineItems"); + + b.Navigation("TransactionLink"); + + b.Navigation("Videos"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.Term", b => + { + b.Navigation("RelatedTerms"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Team.TeamMember", b => + { + b.Navigation("TeamMemberLinks"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Timeline.HistoricalContext", b => + { + b.Navigation("HistoricalContextTimelines"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Timeline.TimelineItem", b => + { + b.Navigation("HistoricalContextTimelines"); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.Toponyms.Toponym", b => + { + b.Navigation("Coordinate") + .IsRequired(); + }); + + modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types.StreetcodeCoordinate", b => + { + b.Navigation("StatisticRecord") + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.cs b/Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.cs new file mode 100644 index 000000000..707b37cba --- /dev/null +++ b/Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.cs @@ -0,0 +1,37 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Streetcode.DAL.Persistence.Migrations +{ + public partial class DatestringLength : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "DateString", + schema: "streetcode", + table: "streetcodes", + type: "nvarchar(100)", + maxLength: 100, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(50)", + oldMaxLength: 50); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "DateString", + schema: "streetcode", + table: "streetcodes", + type: "nvarchar(50)", + maxLength: 50, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(100)", + oldMaxLength: 100); + } + } +} diff --git a/Streetcode/Streetcode.DAL/Persistence/Migrations/StreetcodeDbContextModelSnapshot.cs b/Streetcode/Streetcode.DAL/Persistence/Migrations/StreetcodeDbContextModelSnapshot.cs index d8703c870..ffda3f915 100644 --- a/Streetcode/Streetcode.DAL/Persistence/Migrations/StreetcodeDbContextModelSnapshot.cs +++ b/Streetcode/Streetcode.DAL/Persistence/Migrations/StreetcodeDbContextModelSnapshot.cs @@ -576,8 +576,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateString") .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); b.Property("EventEndOrPersonDeathDate") .HasColumnType("datetime2"); From 5cce849ad42cc408738e952fd26ea99f29ad3b8d Mon Sep 17 00:00:00 2001 From: ValDekh Date: Fri, 8 Dec 2023 18:15:13 +0200 Subject: [PATCH 12/27] Add some changes --- .../appsettings.IntegrationTests.json | 1 + .../Streetcode.WebApi/appsettings.Local.json | 1 + Streetcode/Streetcode.WebApi/appsettings.json | 1 + .../CoordinateControllerTests.cs | 12 ++++++------ .../AdditionalContent/TagControllerTests.cs | 19 +++++++++---------- .../ControllerTests/BaseControllerTests.cs | 15 +++++++++------ .../Streetcode/StreetcodeControllerTests.cs | 10 ++++++---- .../Streetcode/ExtractTestStreetcode.cs | 1 + .../ControllerTests/Utils/StreetcodeClient.cs | 3 +-- 9 files changed, 35 insertions(+), 28 deletions(-) diff --git a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json index 4613c1ca2..a8da0b7b3 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json +++ b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json @@ -1,5 +1,6 @@ { "ConnectionStrings": { + // "DefaultConnection": "Server=DESKTOP-I7Q35NQ\\SQLEXPRESS;Database=StreetcodeDbtest;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true;TrustServerCertificate=true" "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" }, "Blob": { diff --git a/Streetcode/Streetcode.WebApi/appsettings.Local.json b/Streetcode/Streetcode.WebApi/appsettings.Local.json index 04a90d070..f027ab9e6 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.Local.json +++ b/Streetcode/Streetcode.WebApi/appsettings.Local.json @@ -1,5 +1,6 @@ { "ConnectionStrings": { + // "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" }, "CORS": { diff --git a/Streetcode/Streetcode.WebApi/appsettings.json b/Streetcode/Streetcode.WebApi/appsettings.json index 2595d52b9..cf0046d47 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.json +++ b/Streetcode/Streetcode.WebApi/appsettings.json @@ -1,5 +1,6 @@ { "ConnectionStrings": { + // "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" }, "EmailConfiguration": { diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/CoordinateControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/CoordinateControllerTests.cs index 5f74ab6c9..5986c9ae5 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/CoordinateControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/CoordinateControllerTests.cs @@ -1,10 +1,10 @@ -namespace Streetcode.XIntegrationTest.ControllerTests.AdditionalContent -{ - using Streetcode.BLL.DTO.AdditionalContent.Coordinates.Types; - using Streetcode.XIntegrationTest.ControllerTests.Utils; - using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; - using Xunit; +using Streetcode.BLL.DTO.AdditionalContent.Coordinates.Types; +using Streetcode.XIntegrationTest.ControllerTests.Utils; +using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; +using Xunit; +namespace Streetcode.XIntegrationTest.ControllerTests.AdditionalContent +{ public class CoordinateControllerTests : BaseControllerTests, IClassFixture> { public CoordinateControllerTests(CustomWebApplicationFactory factory) diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs index e28dfa36b..ef20a8664 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs @@ -1,14 +1,13 @@ -namespace Streetcode.XIntegrationTest.ControllerTests.AdditionalContent +using global::Streetcode.XIntegrationTest.ControllerTests.Utils; +using Streetcode.BLL.DTO.AdditionalContent; +using Streetcode.BLL.DTO.AdditionalContent.Tag; +using Streetcode.DAL.Entities.AdditionalContent; +using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Tag; +using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; +using Xunit; + +namespace Streetcode.XIntegrationTest.ControllerTests.AdditionalContent { - using Streetcode.BLL.DTO.AdditionalContent; - using Streetcode.BLL.DTO.AdditionalContent.Tag; - using Streetcode.DAL.Entities.AdditionalContent; - using Streetcode.DAL.Entities.Streetcode.TextContent; - using Streetcode.XIntegrationTest.ControllerTests.Utils; - using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Tag; - using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; - using Xunit; - public class TagControllerTests : BaseControllerTests, IClassFixture> { public TagControllerTests(CustomWebApplicationFactory factory) diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/BaseControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/BaseControllerTests.cs index b645ddd5a..0bd132cc9 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/BaseControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/BaseControllerTests.cs @@ -1,10 +1,13 @@ -namespace Streetcode.XIntegrationTest.ControllerTests +using Streetcode.DAL.Persistence; +using Streetcode.XIntegrationTest.ControllerTests.Utils; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Streetcode.DAL.Persistence; +using Streetcode.XIntegrationTest.ControllerTests.Utils; +using Xunit; + +namespace Streetcode.XIntegrationTest.ControllerTests { - using Microsoft.EntityFrameworkCore; - using Microsoft.Extensions.Configuration; - using Streetcode.DAL.Persistence; - using Streetcode.XIntegrationTest.ControllerTests.Utils; - using Xunit; public class BaseControllerTests : IntegrationTestBase, IClassFixture> { diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs index e04c4221c..3bed673a1 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs @@ -1,4 +1,5 @@ using Streetcode.XIntegrationTest.ControllerTests.Utils; +using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; using System; using System.Collections.Generic; using System.Linq; @@ -11,13 +12,14 @@ namespace Streetcode.XIntegrationTest.ControllerTests.Streetcode public class StreetcodeControllerTests : BaseControllerTests, IClassFixture> { - public StreetcodeControllerTests(CustomWebApplicationFactory factory) - :base(factory, "/api/Streetcode") + public StreetcodeControllerTests(CustomWebApplicationFactory factory) + : base(factory, "/api/Streetcode") { } - - + //[Fact] + //[ExtractTestStreetcode] + //{ } } diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs index 4d7546b39..ea4c78269 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs @@ -28,6 +28,7 @@ public override void Before(MethodInfo methodUnderTest) Alias = "dsf", Title = "Title", TransliterationUrl = Guid.NewGuid().ToString(), + Teaser = "Test Teaser", }); sqlDbHelper.SaveChanges(); } diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs index f6b27cd67..ed4109fd6 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs @@ -1,10 +1,9 @@ namespace Streetcode.XIntegrationTest.ControllerTests.Utils { + using System.Threading.Tasks; using global::Streetcode.BLL.MediatR.Streetcode.Streetcode.Update; using RestSharp; using RestSharp.Serializers; - using Streetcode.BLL.MediatR.Streetcode.Streetcode.Update; - using System.Threading.Tasks; public class StreetcodeClient { From f10a07aebeb057e821b54b67d9948ce4ec947908 Mon Sep 17 00:00:00 2001 From: Valerii Dekhtiuk Date: Mon, 11 Dec 2023 00:12:17 +0200 Subject: [PATCH 13/27] Some addition --- .../Media/VideoControllerTests.cs | 10 ++++---- .../Streetcode/StreetcodeControllerTests.cs | 24 +++++++++++++++---- .../Streetcode/ExtractTestStreetcode.cs | 8 +++++++ 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/VideoControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/VideoControllerTests.cs index a59cd3865..1cca4051e 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/VideoControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/VideoControllerTests.cs @@ -1,9 +1,9 @@ -namespace Streetcode.XIntegrationTest.ControllerTests.Media +using Streetcode.BLL.DTO.Media; +using Streetcode.BLL.DTO.Media.Audio; +using Streetcode.XIntegrationTest.ControllerTests.Utils; +using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Video; +namespace Streetcode.XIntegrationTest.ControllerTests.Media { - using Streetcode.BLL.DTO.Media; - using Streetcode.BLL.DTO.Media.Audio; - using Streetcode.XIntegrationTest.ControllerTests.Utils; - using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Video; using Xunit; public class VideoControllerTests : BaseControllerTests, IClassFixture> diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs index 3bed673a1..e3258e882 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs @@ -1,4 +1,7 @@ -using Streetcode.XIntegrationTest.ControllerTests.Utils; +using Streetcode.BLL.DTO.Streetcode.Update; +using Streetcode.BLL.MediatR.Streetcode.Streetcode.Update; +using Streetcode.DAL.Entities.Streetcode; +using Streetcode.XIntegrationTest.ControllerTests.Utils; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; using System; using System.Collections.Generic; @@ -18,8 +21,21 @@ public StreetcodeControllerTests(CustomWebApplicationFactory factory) } - //[Fact] - //[ExtractTestStreetcode] - //{ + [Fact] + [ExtractTestStreetcode] + public async Task Update_ReturnSuccessStatusCode() + { + StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; + + var updateStreetcodeCommand = new UpdateStreetcodeCommand + { + Streetcode = new StreetcodeUpdateDTO + { + Id = expectedStreetcode.Id, + Title = "New Title", + TransliterationUrl = "new-transliteration-url", + } + }; + } } } diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs index ea4c78269..5fb55b0d5 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs @@ -33,5 +33,13 @@ public override void Before(MethodInfo methodUnderTest) sqlDbHelper.SaveChanges(); } } + + public override void After(MethodInfo methodUnderTest) + { + var sqlDbHelper = BaseControllerTests.GetSqlDbHelper(); + StreetcodeForTest.Title = "Updated Title"; + StreetcodeForTest.TransliterationUrl = "updated-transliteration-url"; + sqlDbHelper.SaveChanges(); + } } } From 1bea96ebd2da335255e29fcd1717dc438519b791 Mon Sep 17 00:00:00 2001 From: ValDekh Date: Mon, 11 Dec 2023 18:09:17 +0200 Subject: [PATCH 14/27] Add some cases --- .../ControllerTests/BaseControllerTests.cs | 4 +- .../Media/AudioControllerTests.cs | 1 - .../Images/StreetcodeArtControllerTests.cs | 10 ++-- .../Media/VideoControllerTests.cs | 1 - .../Streetcode/StreetcodeControllerTests.cs | 59 ++++++++++++++----- .../ExtractTestStreetcodeCoordinate.cs | 16 ++--- .../ExtractTestToponymCoordinate.cs | 7 +-- .../Subtitle/ExtractTestSubtitle.cs | 13 +--- .../AdditionalContent/Tag/ExtractTestTag.cs | 5 +- .../Tag/StreetcodeTagIndexSetup.cs | 5 -- .../Media/Images/Art/ExtractTestArt.cs | 2 +- .../Media/Images/Image/ExtractTestImage.cs | 2 +- .../StreetcodeArt/ExtractTestStreetcodeArt.cs | 4 +- .../Media/Video/ExtractTestVideo.cs | 2 +- .../Partners/ExtractTestPartners.cs | 7 +-- .../ExtractTestSourceLinkCategory.cs | 10 +--- .../Streetcode/ExtractTestStreetcode.cs | 3 +- .../RelatedFigure/ExtractTestRelatedFigure.cs | 7 +-- .../TextContent/Facts/ExtractTestFact.cs | 7 +-- .../TextContent/Terms/ExstractTestTerm.cs | 8 +-- .../TextContent/Texts/ExstractTestText.cs | 7 +-- .../Timelines/ExtractTestTimelineItem.cs | 7 +-- .../Toponyms/ExtractTestToponym.cs | 5 +- .../ExtractTestTransactionLink.cs | 9 +-- .../Utils/CustomWebApplicationFactory.cs | 2 +- .../ControllerTests/Utils/StreetcodeClient.cs | 21 +++---- .../Utils/BlobStorageFixture.cs | 6 +- 27 files changed, 94 insertions(+), 136 deletions(-) diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/BaseControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/BaseControllerTests.cs index 0bd132cc9..7767b53ee 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/BaseControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/BaseControllerTests.cs @@ -1,6 +1,4 @@ -using Streetcode.DAL.Persistence; -using Streetcode.XIntegrationTest.ControllerTests.Utils; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Streetcode.DAL.Persistence; using Streetcode.XIntegrationTest.ControllerTests.Utils; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/AudioControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/AudioControllerTests.cs index 5fc97daec..f19749633 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/AudioControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/AudioControllerTests.cs @@ -2,7 +2,6 @@ using Streetcode.DAL.Entities.Media; using Streetcode.XIntegrationTest.ControllerTests.Utils; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Audio; -using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; using Xunit; namespace Streetcode.XIntegrationTest.ControllerTests.Media diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/StreetcodeArtControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/StreetcodeArtControllerTests.cs index 64a0cf559..62a906f18 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/StreetcodeArtControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/StreetcodeArtControllerTests.cs @@ -1,9 +1,9 @@ -namespace Streetcode.XIntegrationTest.ControllerTests.Media.Images +using Streetcode.BLL.DTO.Media.Art; +using Streetcode.XIntegrationTest.ControllerTests.Utils; +using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; +using Xunit; +namespace Streetcode.XIntegrationTest.ControllerTests.Media.Images { - using Streetcode.BLL.DTO.Media.Art; - using Streetcode.XIntegrationTest.ControllerTests.Utils; - using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; - using Xunit; public class StreetcodeArtControllerTests : BaseControllerTests, IClassFixture> { diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/VideoControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/VideoControllerTests.cs index 1cca4051e..6825ea683 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/VideoControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/VideoControllerTests.cs @@ -1,5 +1,4 @@ using Streetcode.BLL.DTO.Media; -using Streetcode.BLL.DTO.Media.Audio; using Streetcode.XIntegrationTest.ControllerTests.Utils; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Video; namespace Streetcode.XIntegrationTest.ControllerTests.Media diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs index e3258e882..3487f88fd 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs @@ -1,13 +1,21 @@ -using Streetcode.BLL.DTO.Streetcode.Update; -using Streetcode.BLL.MediatR.Streetcode.Streetcode.Update; +using Newtonsoft.Json; +using Streetcode.BLL.DTO.AdditionalContent.Subtitles; +using Streetcode.BLL.DTO.AdditionalContent.Tag; +using Streetcode.BLL.DTO.Analytics.Update; +using Streetcode.BLL.DTO.Media.Art; +using Streetcode.BLL.DTO.Media.Audio; +using Streetcode.BLL.DTO.Media.Images; +using Streetcode.BLL.DTO.Media.Video; +using Streetcode.BLL.DTO.Partners.Update; +using Streetcode.BLL.DTO.Sources.Update; +using Streetcode.BLL.DTO.Streetcode.RelatedFigure; +using Streetcode.BLL.DTO.Streetcode.TextContent.Fact; +using Streetcode.BLL.DTO.Streetcode.Update; +using Streetcode.BLL.DTO.Timeline.Update; +using Streetcode.BLL.DTO.Toponyms; using Streetcode.DAL.Entities.Streetcode; using Streetcode.XIntegrationTest.ControllerTests.Utils; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Xunit; namespace Streetcode.XIntegrationTest.ControllerTests.Streetcode @@ -27,15 +35,38 @@ public async Task Update_ReturnSuccessStatusCode() { StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; - var updateStreetcodeCommand = new UpdateStreetcodeCommand + // var updateStreetcodeCommand = new UpdateStreetcodeCommand( + var updateStreetCodeDTO = new StreetcodeUpdateDTO { - Streetcode = new StreetcodeUpdateDTO - { - Id = expectedStreetcode.Id, - Title = "New Title", - TransliterationUrl = "new-transliteration-url", - } + Id = expectedStreetcode.Id, + Title = "New Title", + TransliterationUrl = "new-transliteration-url", + Tags = new List(), + Facts = new List(), + Audios = new List(), + Images = new List(), + Videos = new List(), + Partners = new List(), + Toponyms = new List(), + Subtitles = new List(), + DateString = "20 травня 2023", + TimelineItems = new List(), + RelatedFigures = new List(), + StreetcodeArts = new List(), + StatisticRecords = new List(), + StreetcodeCategoryContents = new List() }; + var response = await this.client.UpdateAsync(updateStreetCodeDTO); + StreetcodeContent updatedStreetcode = ExtractTestStreetcode.StreetcodeForTest; + + var responseContent = JsonConvert.DeserializeObject(response.Content); + + Assert.Multiple(() => + { + Assert.True(response.IsSuccessStatusCode); + Assert.Equal(updatedStreetcode.Title, responseContent.Title); + Assert.Equal(updatedStreetcode.TransliterationUrl, responseContent.TransliterationUrl); + }); } } } diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestStreetcodeCoordinate.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestStreetcodeCoordinate.cs index cb0bc5c9d..c8aa5b104 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestStreetcodeCoordinate.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestStreetcodeCoordinate.cs @@ -19,14 +19,14 @@ public override void Before(MethodInfo methodUnderTest) { StreetcodeContent first = sqlDbHelper.GetExistItem(); first ??= sqlDbHelper.AddNewItem(new StreetcodeContent() - { - Index = 10, - UpdatedAt = DateTime.Now, - CreatedAt = DateTime.Now, - EventStartOrPersonBirthDate = DateTime.Now, - EventEndOrPersonDeathDate = DateTime.Now, - ViewCount = 1, - }); + { + Index = 10, + UpdatedAt = DateTime.Now, + CreatedAt = DateTime.Now, + EventStartOrPersonBirthDate = DateTime.Now, + EventEndOrPersonDeathDate = DateTime.Now, + ViewCount = 1, + }); CoordinateForTest = sqlDbHelper.AddNewItem( new StreetcodeCoordinate() diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestToponymCoordinate.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestToponymCoordinate.cs index eb8a45891..9884bc733 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestToponymCoordinate.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestToponymCoordinate.cs @@ -1,17 +1,12 @@ using Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types; using Streetcode.DAL.Entities.Toponyms; -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Coordinate { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestToponymCoordinate:BeforeAfterTestAttribute + internal class ExtractTestToponymCoordinate : BeforeAfterTestAttribute { public static ToponymCoordinate ToponymCoordinateForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Subtitle/ExtractTestSubtitle.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Subtitle/ExtractTestSubtitle.cs index 7c577860c..6758057bc 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Subtitle/ExtractTestSubtitle.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Subtitle/ExtractTestSubtitle.cs @@ -1,15 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Streetcode.DAL.Entities; -using Streetcode.DAL.Entities.Streetcode; -using Streetcode.DAL.Persistence; +using Streetcode.DAL.Entities.Streetcode; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; +using System.Reflection; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Subtitle diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/ExtractTestTag.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/ExtractTestTag.cs index 33d3b63b2..25bd4db21 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/ExtractTestTag.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/ExtractTestTag.cs @@ -1,11 +1,10 @@ -using Streetcode.DAL.Entities.AdditionalContent; -using System.Reflection; +using System.Reflection; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Tag { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - public class ExtractTestTag: BeforeAfterTestAttribute + public class ExtractTestTag : BeforeAfterTestAttribute { public static DAL.Entities.AdditionalContent.Tag TagForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/StreetcodeTagIndexSetup.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/StreetcodeTagIndexSetup.cs index 41f223b91..2dbc8ef87 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/StreetcodeTagIndexSetup.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/StreetcodeTagIndexSetup.cs @@ -1,10 +1,5 @@ using Streetcode.DAL.Entities.AdditionalContent; using Streetcode.DAL.Entities.Streetcode; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Tag { diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Art/ExtractTestArt.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Art/ExtractTestArt.cs index 56f738846..10e339d5f 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Art/ExtractTestArt.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Art/ExtractTestArt.cs @@ -6,7 +6,7 @@ namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Images.Art { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestArt: BeforeAfterTestAttribute + internal class ExtractTestArt : BeforeAfterTestAttribute { public static DAL.Entities.Media.Images.Art ArtForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Image/ExtractTestImage.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Image/ExtractTestImage.cs index 0b595a58c..adbe0c84e 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Image/ExtractTestImage.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Image/ExtractTestImage.cs @@ -7,7 +7,7 @@ namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Images.Image { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - public class ExtractTestImage: BeforeAfterTestAttribute + public class ExtractTestImage : BeforeAfterTestAttribute { public static DAL.Entities.Media.Images.Image ImageForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/StreetcodeArt/ExtractTestStreetcodeArt.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/StreetcodeArt/ExtractTestStreetcodeArt.cs index 06cb3fd95..0486e2f8f 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/StreetcodeArt/ExtractTestStreetcodeArt.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/StreetcodeArt/ExtractTestStreetcodeArt.cs @@ -6,7 +6,7 @@ namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Images.StreetcodeArt { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestStreetcodeArt:BeforeAfterTestAttribute + internal class ExtractTestStreetcodeArt : BeforeAfterTestAttribute { public static DAL.Entities.Streetcode.StreetcodeArt StreetcodeArtForTest; @@ -14,7 +14,7 @@ public override void Before(MethodInfo methodUnderTest) { var sqlDbHelper = BaseControllerTests.GetSqlDbHelper(); StreetcodeArtForTest = sqlDbHelper.GetExistItem(); - if(StreetcodeArtForTest == null) + if (StreetcodeArtForTest == null) { if (ExtractTestStreetcode.StreetcodeForTest == null) { diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Video/ExtractTestVideo.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Video/ExtractTestVideo.cs index 002b457e3..0cbbb38f8 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Video/ExtractTestVideo.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Video/ExtractTestVideo.cs @@ -6,7 +6,7 @@ namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Video { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestVideo: BeforeAfterTestAttribute + internal class ExtractTestVideo : BeforeAfterTestAttribute { public static DAL.Entities.Media.Video VideoForTest; public static StreetcodeContent StreetcodeWithVideo; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Partners/ExtractTestPartners.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Partners/ExtractTestPartners.cs index dd9db72e2..ed7ccf3c3 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Partners/ExtractTestPartners.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Partners/ExtractTestPartners.cs @@ -1,17 +1,12 @@ using Streetcode.DAL.Entities.Partners; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Images.Image; -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Partners { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestPartners: BeforeAfterTestAttribute + internal class ExtractTestPartners : BeforeAfterTestAttribute { public static Partner PartnerForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Source/SourceLinkCategories/ExtractTestSourceLinkCategory.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Source/SourceLinkCategories/ExtractTestSourceLinkCategory.cs index c96d6330c..380f3ce65 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Source/SourceLinkCategories/ExtractTestSourceLinkCategory.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Source/SourceLinkCategories/ExtractTestSourceLinkCategory.cs @@ -1,18 +1,12 @@ -using Streetcode.DAL.Entities.Partners; -using Streetcode.DAL.Entities.Sources; +using Streetcode.DAL.Entities.Sources; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Images.Image; -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Source.SourceLinkCategories { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestSourceLinkCategory:BeforeAfterTestAttribute + internal class ExtractTestSourceLinkCategory : BeforeAfterTestAttribute { public static SourceLinkCategory SourceLinkCategoryForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs index 5fb55b0d5..2f4030238 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs @@ -1,5 +1,4 @@ -using Streetcode.DAL.Entities.AdditionalContent; -using Streetcode.DAL.Entities.Streetcode; +using Streetcode.DAL.Entities.Streetcode; using System.Reflection; using Xunit.Sdk; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/RelatedFigure/ExtractTestRelatedFigure.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/RelatedFigure/ExtractTestRelatedFigure.cs index 84d896e4d..ea31620d7 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/RelatedFigure/ExtractTestRelatedFigure.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/RelatedFigure/ExtractTestRelatedFigure.cs @@ -1,16 +1,11 @@ using Streetcode.DAL.Entities.Streetcode; -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode.RelatedFigure { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestRelatedFigure: BeforeAfterTestAttribute + internal class ExtractTestRelatedFigure : BeforeAfterTestAttribute { public static DAL.Entities.Streetcode.RelatedFigure RelatedFigureForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Facts/ExtractTestFact.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Facts/ExtractTestFact.cs index b0ef66ce9..aa52d8f21 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Facts/ExtractTestFact.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Facts/ExtractTestFact.cs @@ -1,16 +1,11 @@ using Streetcode.DAL.Entities.Streetcode.TextContent; -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode.TextContent.Facts { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - public class ExtractTestFact: BeforeAfterTestAttribute + public class ExtractTestFact : BeforeAfterTestAttribute { public static Fact FactForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Terms/ExstractTestTerm.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Terms/ExstractTestTerm.cs index cc745822f..bd28a9c2d 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Terms/ExstractTestTerm.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Terms/ExstractTestTerm.cs @@ -1,17 +1,11 @@ using Streetcode.DAL.Entities.Streetcode.TextContent; -using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode.TextContent.Facts; -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode.TextContent.Terms { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExstractTestTerm: BeforeAfterTestAttribute + internal class ExstractTestTerm : BeforeAfterTestAttribute { public static Term TermForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Texts/ExstractTestText.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Texts/ExstractTestText.cs index 36135d839..42e2bb4e0 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Texts/ExstractTestText.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Texts/ExstractTestText.cs @@ -1,16 +1,11 @@ using Streetcode.DAL.Entities.Streetcode.TextContent; -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode.TextContent.Texts { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExstractTestText :BeforeAfterTestAttribute + internal class ExstractTestText : BeforeAfterTestAttribute { public static Text TextForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Timelines/ExtractTestTimelineItem.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Timelines/ExtractTestTimelineItem.cs index 4ecaef22b..bed77d9a8 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Timelines/ExtractTestTimelineItem.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Timelines/ExtractTestTimelineItem.cs @@ -1,16 +1,11 @@ using Streetcode.DAL.Entities.Timeline; -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Timelines { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestTimelineItem: BeforeAfterTestAttribute + internal class ExtractTestTimelineItem : BeforeAfterTestAttribute { public static TimelineItem TimelineItemForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Toponyms/ExtractTestToponym.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Toponyms/ExtractTestToponym.cs index 97c55ff66..24d6628fe 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Toponyms/ExtractTestToponym.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Toponyms/ExtractTestToponym.cs @@ -1,15 +1,12 @@ using Streetcode.DAL.Entities.Toponyms; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Coordinate; -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Toponyms { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestToponym:BeforeAfterTestAttribute + internal class ExtractTestToponym : BeforeAfterTestAttribute { public static Toponym ToponymForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Transactions/ExtractTestTransactionLink.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Transactions/ExtractTestTransactionLink.cs index 3561a7ddd..6d509064c 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Transactions/ExtractTestTransactionLink.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Transactions/ExtractTestTransactionLink.cs @@ -1,13 +1,6 @@ -using Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types; -using Streetcode.DAL.Entities.Transactions; +using Streetcode.DAL.Entities.Transactions; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Transactions; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Transactions diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/CustomWebApplicationFactory.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/CustomWebApplicationFactory.cs index 8e27ecf3f..db47e2e8d 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/CustomWebApplicationFactory.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/CustomWebApplicationFactory.cs @@ -1,8 +1,8 @@ namespace Streetcode.XIntegrationTest.ControllerTests.Utils { - using System; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; + using System; public class CustomWebApplicationFactory : WebApplicationFactory where TProgram : class diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs index ed4109fd6..1be932316 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs @@ -1,19 +1,18 @@ -namespace Streetcode.XIntegrationTest.ControllerTests.Utils -{ - using System.Threading.Tasks; - using global::Streetcode.BLL.MediatR.Streetcode.Streetcode.Update; - using RestSharp; - using RestSharp.Serializers; +using RestSharp; +using RestSharp.Serializers; +using Streetcode.BLL.DTO.Streetcode.Update; +namespace Streetcode.XIntegrationTest.ControllerTests.Utils +{ public class StreetcodeClient { protected RestClient Client; public string SecondPartUrl { get; } - public StreetcodeClient(HttpClient client, string secondPartUrl = "") + public StreetcodeClient(HttpClient client, string secondPartUrl = "") { - this.Client = new RestClient(client) { AcceptedContentTypes=ContentType.JsonAccept }; + this.Client = new RestClient(client) { AcceptedContentTypes = ContentType.JsonAccept }; this.SecondPartUrl = secondPartUrl; } @@ -46,10 +45,12 @@ public async Task GetResponse(string requestString) return returns; } - public async Task UpdateAsync(UpdateStreetcodeCommand updateStreetcodeCommand) + public async Task UpdateAsync(StreetcodeUpdateDTO updateStreetcodeDTO) { var request = new RestRequest($"{this.SecondPartUrl}/Update", Method.Put); - request.AddJsonBody(updateStreetcodeCommand); + request.AddJsonBody(updateStreetcodeDTO); + request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; }; + request.AddHeader("content-type", "application/json"); var response = await this.Client.ExecuteAsync(request); return response; } diff --git a/Streetcode/Streetcode.XIntegrationTest/ServiceTests/BlobServiceTests/Utils/BlobStorageFixture.cs b/Streetcode/Streetcode.XIntegrationTest/ServiceTests/BlobServiceTests/Utils/BlobStorageFixture.cs index 07eb4bc2c..911681aa8 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ServiceTests/BlobServiceTests/Utils/BlobStorageFixture.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ServiceTests/BlobServiceTests/Utils/BlobStorageFixture.cs @@ -5,8 +5,6 @@ using Streetcode.DAL.Entities.Media; using Streetcode.DAL.Entities.Media.Images; using Streetcode.DAL.Persistence; -using Streetcode.DAL.Repositories.Realizations.Base; -using Streetcode.XIntegrationTest.Base; using System.Text; namespace Streetcode.XIntegrationTest.ServiceTests.BlobServiceTests.Utils @@ -29,8 +27,8 @@ public BlobStorageFixture() blobPath = environmentVariables.Value.BlobStorePath; blobKey = environmentVariables.Value.BlobStoreKey; - // TestDbContext = TestDBFixture.CreateContext(Configuration.GetConnectionString("DefaultConnection")); - // RepositoryWrapper repo = new RepositoryWrapper(TestDbContext); + // TestDbContext = TestDBFixture.CreateContext(Configuration.GetConnectionString("DefaultConnection")); + // RepositoryWrapper repo = new RepositoryWrapper(TestDbContext); blobService = new BlobService(environmentVariables); // add repo Directory.CreateDirectory(blobPath); From 5f1b948aba5fe64aaf9e563eddb2b098e3408992 Mon Sep 17 00:00:00 2001 From: Valerii Dekhtiuk Date: Tue, 12 Dec 2023 01:27:47 +0200 Subject: [PATCH 15/27] Add some logic --- .../Streetcode/StreetcodeControllerTests.cs | 20 ++++++++++--------- .../Streetcode/ExtractTestStreetcode.cs | 3 +-- .../ControllerTests/Utils/SqlDbHelper.cs | 6 ++++++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs index 3487f88fd..bcd5ed5fa 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs @@ -35,7 +35,6 @@ public async Task Update_ReturnSuccessStatusCode() { StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; - // var updateStreetcodeCommand = new UpdateStreetcodeCommand( var updateStreetCodeDTO = new StreetcodeUpdateDTO { Id = expectedStreetcode.Id, @@ -57,16 +56,19 @@ public async Task Update_ReturnSuccessStatusCode() StreetcodeCategoryContents = new List() }; var response = await this.client.UpdateAsync(updateStreetCodeDTO); - StreetcodeContent updatedStreetcode = ExtractTestStreetcode.StreetcodeForTest; - var responseContent = JsonConvert.DeserializeObject(response.Content); + Assert.True(response.IsSuccessStatusCode); - Assert.Multiple(() => - { - Assert.True(response.IsSuccessStatusCode); - Assert.Equal(updatedStreetcode.Title, responseContent.Title); - Assert.Equal(updatedStreetcode.TransliterationUrl, responseContent.TransliterationUrl); - }); + //StreetcodeContent updatedStreetcode = ExtractTestStreetcode.StreetcodeForTest; + + //var responseContent = JsonConvert.DeserializeObject(response.Content); + + //Assert.Multiple(() => + //{ + // Assert.True(response.IsSuccessStatusCode); + // Assert.Equal(updatedStreetcode.Title, responseContent.Title); + // Assert.Equal(updatedStreetcode.TransliterationUrl, responseContent.TransliterationUrl); + //}); } } } diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs index 2f4030238..2a7cc5b5a 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs @@ -36,8 +36,7 @@ public override void Before(MethodInfo methodUnderTest) public override void After(MethodInfo methodUnderTest) { var sqlDbHelper = BaseControllerTests.GetSqlDbHelper(); - StreetcodeForTest.Title = "Updated Title"; - StreetcodeForTest.TransliterationUrl = "updated-transliteration-url"; + sqlDbHelper.RemoveRange(); sqlDbHelper.SaveChanges(); } } diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/SqlDbHelper.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/SqlDbHelper.cs index 137d0b39e..1aa65daf4 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/SqlDbHelper.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/SqlDbHelper.cs @@ -83,6 +83,12 @@ public T DeleteItem(T item) return this.dbContext.Set().Remove(item).Entity; } + public void RemoveRange() + where T : class, new() + { + this.dbContext.Set().RemoveRange(this.dbContext.Set()); + this.dbContext.SaveChanges(); + } public void SaveChanges() => this.dbContext.SaveChanges(); } } From 10627114c809351effa1f43aa067096c6df6ae67 Mon Sep 17 00:00:00 2001 From: ValDekh Date: Tue, 12 Dec 2023 17:59:43 +0200 Subject: [PATCH 16/27] Add some test cases --- .../Streetcode/StreetcodeControllerTests.cs | 71 ++++++++++++++----- 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs index bcd5ed5fa..931f4277f 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs @@ -16,6 +16,7 @@ using Streetcode.DAL.Entities.Streetcode; using Streetcode.XIntegrationTest.ControllerTests.Utils; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; +using System.Net; using Xunit; namespace Streetcode.XIntegrationTest.ControllerTests.Streetcode @@ -35,9 +36,59 @@ public async Task Update_ReturnSuccessStatusCode() { StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; - var updateStreetCodeDTO = new StreetcodeUpdateDTO + var updateStreetCodeDTO = this.CreateMoqStreetCodeDTO(expectedStreetcode.Id); + var response = await this.client.UpdateAsync(updateStreetCodeDTO); + + Assert.True(response.IsSuccessStatusCode); + } + + [Fact] + [ExtractTestStreetcode] + public async Task Update_ChangesTitleAndTransliterationUrl() + { + StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; + + var updateStreetCodeDTO = this.CreateMoqStreetCodeDTO(expectedStreetcode.Id); + await this.client.UpdateAsync(updateStreetCodeDTO); + + var responseGetByIdUpdated = await client.GetByIdAsync(expectedStreetcode.Id); + var responseContent = JsonConvert.DeserializeObject(responseGetByIdUpdated.Content); + + Assert.Multiple(() => + { + Assert.Equal(updateStreetCodeDTO.Title, responseContent.Title); + Assert.Equal(updateStreetCodeDTO.TransliterationUrl, responseContent.TransliterationUrl); + }); + } + + [Fact] + [ExtractTestStreetcode] + public async Task Update_WithIncorrectId_ReturnsBadRequest() + { + + StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; + var updateStreetCodeDTO = this.CreateMoqStreetCodeDTO(expectedStreetcode.Id + 1); + var response = await this.client.UpdateAsync(updateStreetCodeDTO); + + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + } + + [Fact] + [ExtractTestStreetcode] + public async Task Update_WithInvalidData_ReturnsBadRequest() + { + StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; + var updateStreetCodeDTO = this.CreateMoqStreetCodeDTO(expectedStreetcode.Id); + updateStreetCodeDTO.Title = String.IsNullOrEmpty; // Invalid data + var response = await this.client.UpdateAsync(updateStreetCodeDTO); + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + } + + private StreetcodeUpdateDTO CreateMoqStreetCodeDTO(int id) + { + return new StreetcodeUpdateDTO { - Id = expectedStreetcode.Id, + Id = id, Title = "New Title", TransliterationUrl = "new-transliteration-url", Tags = new List(), @@ -53,22 +104,8 @@ public async Task Update_ReturnSuccessStatusCode() RelatedFigures = new List(), StreetcodeArts = new List(), StatisticRecords = new List(), - StreetcodeCategoryContents = new List() + StreetcodeCategoryContents = new List(), }; - var response = await this.client.UpdateAsync(updateStreetCodeDTO); - - Assert.True(response.IsSuccessStatusCode); - - //StreetcodeContent updatedStreetcode = ExtractTestStreetcode.StreetcodeForTest; - - //var responseContent = JsonConvert.DeserializeObject(response.Content); - - //Assert.Multiple(() => - //{ - // Assert.True(response.IsSuccessStatusCode); - // Assert.Equal(updatedStreetcode.Title, responseContent.Title); - // Assert.Equal(updatedStreetcode.TransliterationUrl, responseContent.TransliterationUrl); - //}); } } } From ba5484266548efd3efb6bacfb16771800d899af0 Mon Sep 17 00:00:00 2001 From: ValDekh Date: Wed, 13 Dec 2023 18:03:40 +0200 Subject: [PATCH 17/27] Add Update StreetCode Integration Tests --- .../Streetcode/StreetcodeControllerTests.cs | 38 +++++++++++++++---- .../Streetcode/ExtractTestStreetcode.cs | 17 ++++++++- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs index 931f4277f..796e3ef53 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs @@ -1,5 +1,4 @@ -using Newtonsoft.Json; -using Streetcode.BLL.DTO.AdditionalContent.Subtitles; +using Streetcode.BLL.DTO.AdditionalContent.Subtitles; using Streetcode.BLL.DTO.AdditionalContent.Tag; using Streetcode.BLL.DTO.Analytics.Update; using Streetcode.BLL.DTO.Media.Art; @@ -13,6 +12,7 @@ using Streetcode.BLL.DTO.Streetcode.Update; using Streetcode.BLL.DTO.Timeline.Update; using Streetcode.BLL.DTO.Toponyms; +using Streetcode.BLL.Enums; using Streetcode.DAL.Entities.Streetcode; using Streetcode.XIntegrationTest.ControllerTests.Utils; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; @@ -52,12 +52,11 @@ public async Task Update_ChangesTitleAndTransliterationUrl() await this.client.UpdateAsync(updateStreetCodeDTO); var responseGetByIdUpdated = await client.GetByIdAsync(expectedStreetcode.Id); - var responseContent = JsonConvert.DeserializeObject(responseGetByIdUpdated.Content); - + var streetCodeContent = CaseIsensitiveJsonDeserializer.Deserialize(responseGetByIdUpdated.Content); Assert.Multiple(() => { - Assert.Equal(updateStreetCodeDTO.Title, responseContent.Title); - Assert.Equal(updateStreetCodeDTO.TransliterationUrl, responseContent.TransliterationUrl); + Assert.Equal(updateStreetCodeDTO.Title, streetCodeContent.Title); + Assert.Equal(updateStreetCodeDTO.TransliterationUrl, streetCodeContent.TransliterationUrl); }); } @@ -79,7 +78,32 @@ public async Task Update_WithInvalidData_ReturnsBadRequest() { StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; var updateStreetCodeDTO = this.CreateMoqStreetCodeDTO(expectedStreetcode.Id); - updateStreetCodeDTO.Title = String.IsNullOrEmpty; // Invalid data + updateStreetCodeDTO.Title = null; // Invalid data + var response = await this.client.UpdateAsync(updateStreetCodeDTO); + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + } + + [Fact] + [ExtractTestStreetcode] + public async Task Update_WithInvalidTags_ReturnsBadRequest() + { + StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; + var updateStreetCodeDTO = this.CreateMoqStreetCodeDTO(expectedStreetcode.Id); + + // Invalid tag data + updateStreetCodeDTO.Tags = new List + { + new StreetcodeTagUpdateDTO + { + Id = 9999, // Non-existent tag ID + Title = "Invalid Tag", + IsVisible = true, + Index = 0, + StreetcodeId = expectedStreetcode.Id, + ModelState = ModelState.Updated + }, + }; + var response = await this.client.UpdateAsync(updateStreetCodeDTO); Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); } diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs index 2a7cc5b5a..c4f325642 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs @@ -36,8 +36,21 @@ public override void Before(MethodInfo methodUnderTest) public override void After(MethodInfo methodUnderTest) { var sqlDbHelper = BaseControllerTests.GetSqlDbHelper(); - sqlDbHelper.RemoveRange(); - sqlDbHelper.SaveChanges(); + var streetcodeContent = sqlDbHelper.GetExistItem(); + if (streetcodeContent != null) + { + // Restore the original StreetcodeContent + streetcodeContent.EventStartOrPersonBirthDate = StreetcodeForTest.EventStartOrPersonBirthDate; + streetcodeContent.EventEndOrPersonDeathDate = StreetcodeForTest.EventEndOrPersonDeathDate; + streetcodeContent.ViewCount = StreetcodeForTest.ViewCount; + streetcodeContent.DateString = StreetcodeForTest.DateString; + streetcodeContent.Alias = StreetcodeForTest.Alias; + streetcodeContent.Title = StreetcodeForTest.Title; + streetcodeContent.TransliterationUrl = StreetcodeForTest.TransliterationUrl; + streetcodeContent.Teaser = StreetcodeForTest.Teaser; + + sqlDbHelper.SaveChanges(); + } } } } From ac8c2d9363b85b433b71f7d9e733f877a1ed0ea6 Mon Sep 17 00:00:00 2001 From: ValDekh Date: Thu, 14 Dec 2023 12:12:37 +0200 Subject: [PATCH 18/27] Correct AppSettings --- Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json | 3 +-- Streetcode/Streetcode.WebApi/appsettings.Local.json | 3 +-- Streetcode/Streetcode.WebApi/appsettings.json | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json index a8da0b7b3..6ed5ebe22 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json +++ b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json @@ -1,7 +1,6 @@ { "ConnectionStrings": { - // "DefaultConnection": "Server=DESKTOP-I7Q35NQ\\SQLEXPRESS;Database=StreetcodeDbtest;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true;TrustServerCertificate=true" - "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" + "DefaultConnection": "Server=DESKTOP-I7Q35NQ\\SQLEXPRESS;Database=StreetcodeDbtest;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true;TrustServerCertificate=true" }, "Blob": { "BlobStoreKey": "BigThirtyTwoBiteCoolTestKeyCrypt", diff --git a/Streetcode/Streetcode.WebApi/appsettings.Local.json b/Streetcode/Streetcode.WebApi/appsettings.Local.json index f027ab9e6..eece212cc 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.Local.json +++ b/Streetcode/Streetcode.WebApi/appsettings.Local.json @@ -1,7 +1,6 @@ { "ConnectionStrings": { - // "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" - "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" + "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" }, "CORS": { "AllowedOrigins": [ "http://localhost:3000" ], diff --git a/Streetcode/Streetcode.WebApi/appsettings.json b/Streetcode/Streetcode.WebApi/appsettings.json index cf0046d47..2e035202e 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.json +++ b/Streetcode/Streetcode.WebApi/appsettings.json @@ -1,7 +1,6 @@ { "ConnectionStrings": { - // "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" - "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" + "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" }, "EmailConfiguration": { "From": "streetcodefordev@gmail.com", From 36e1f75a2cf47f0d3326f03b0f97699795192677 Mon Sep 17 00:00:00 2001 From: ValDekh Date: Fri, 15 Dec 2023 12:52:17 +0200 Subject: [PATCH 19/27] Add update folder --- .../{ => Update}/StreetcodeControllerTests.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) rename Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/{ => Update}/StreetcodeControllerTests.cs (85%) diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeControllerTests.cs similarity index 85% rename from Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs rename to Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeControllerTests.cs index 796e3ef53..abaa5dd83 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/StreetcodeControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeControllerTests.cs @@ -19,7 +19,7 @@ using System.Net; using Xunit; -namespace Streetcode.XIntegrationTest.ControllerTests.Streetcode +namespace Streetcode.XIntegrationTest.ControllerTests.Streetcode.Update { public class StreetcodeControllerTests : BaseControllerTests, IClassFixture> @@ -36,8 +36,8 @@ public async Task Update_ReturnSuccessStatusCode() { StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; - var updateStreetCodeDTO = this.CreateMoqStreetCodeDTO(expectedStreetcode.Id); - var response = await this.client.UpdateAsync(updateStreetCodeDTO); + var updateStreetCodeDTO = CreateMoqStreetCodeDTO(expectedStreetcode.Id); + var response = await client.UpdateAsync(updateStreetCodeDTO); Assert.True(response.IsSuccessStatusCode); } @@ -48,8 +48,8 @@ public async Task Update_ChangesTitleAndTransliterationUrl() { StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; - var updateStreetCodeDTO = this.CreateMoqStreetCodeDTO(expectedStreetcode.Id); - await this.client.UpdateAsync(updateStreetCodeDTO); + var updateStreetCodeDTO = CreateMoqStreetCodeDTO(expectedStreetcode.Id); + await client.UpdateAsync(updateStreetCodeDTO); var responseGetByIdUpdated = await client.GetByIdAsync(expectedStreetcode.Id); var streetCodeContent = CaseIsensitiveJsonDeserializer.Deserialize(responseGetByIdUpdated.Content); @@ -66,8 +66,8 @@ public async Task Update_WithIncorrectId_ReturnsBadRequest() { StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; - var updateStreetCodeDTO = this.CreateMoqStreetCodeDTO(expectedStreetcode.Id + 1); - var response = await this.client.UpdateAsync(updateStreetCodeDTO); + var updateStreetCodeDTO = CreateMoqStreetCodeDTO(expectedStreetcode.Id + 1); + var response = await client.UpdateAsync(updateStreetCodeDTO); Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); } @@ -77,9 +77,9 @@ public async Task Update_WithIncorrectId_ReturnsBadRequest() public async Task Update_WithInvalidData_ReturnsBadRequest() { StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; - var updateStreetCodeDTO = this.CreateMoqStreetCodeDTO(expectedStreetcode.Id); + var updateStreetCodeDTO = CreateMoqStreetCodeDTO(expectedStreetcode.Id); updateStreetCodeDTO.Title = null; // Invalid data - var response = await this.client.UpdateAsync(updateStreetCodeDTO); + var response = await client.UpdateAsync(updateStreetCodeDTO); Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); } @@ -88,7 +88,7 @@ public async Task Update_WithInvalidData_ReturnsBadRequest() public async Task Update_WithInvalidTags_ReturnsBadRequest() { StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; - var updateStreetCodeDTO = this.CreateMoqStreetCodeDTO(expectedStreetcode.Id); + var updateStreetCodeDTO = CreateMoqStreetCodeDTO(expectedStreetcode.Id); // Invalid tag data updateStreetCodeDTO.Tags = new List @@ -104,7 +104,7 @@ public async Task Update_WithInvalidTags_ReturnsBadRequest() }, }; - var response = await this.client.UpdateAsync(updateStreetCodeDTO); + var response = await client.UpdateAsync(updateStreetCodeDTO); Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); } From 2b1b477ecaa1a0381ec8527119651e79e0836318 Mon Sep 17 00:00:00 2001 From: ValDekh Date: Mon, 18 Dec 2023 10:40:02 +0200 Subject: [PATCH 20/27] Change naming --- ...eControllerTests.cs => StreetcodeUpdateControllerTests.cs} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/{StreetcodeControllerTests.cs => StreetcodeUpdateControllerTests.cs} (97%) diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeUpdateControllerTests.cs similarity index 97% rename from Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeControllerTests.cs rename to Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeUpdateControllerTests.cs index abaa5dd83..a1a8f7ec0 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeUpdateControllerTests.cs @@ -21,10 +21,10 @@ namespace Streetcode.XIntegrationTest.ControllerTests.Streetcode.Update { - public class StreetcodeControllerTests : + public class StreetcodeUpdateControllerTests : BaseControllerTests, IClassFixture> { - public StreetcodeControllerTests(CustomWebApplicationFactory factory) + public StreetcodeUpdateControllerTests(CustomWebApplicationFactory factory) : base(factory, "/api/Streetcode") { From 4d8ed3414f1e4e8e359e3831e59e73d39f8afdb6 Mon Sep 17 00:00:00 2001 From: Valerii Dekhtiuk Date: Mon, 18 Dec 2023 23:37:45 +0200 Subject: [PATCH 21/27] Correct some errors --- .../Update/StreetcodeUpdateControllerTests.cs | 56 ++++++++++++------- .../Streetcode/ExtractTestUpdateStreetcode.cs | 56 +++++++++++++++++++ 2 files changed, 92 insertions(+), 20 deletions(-) create mode 100644 Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestUpdateStreetcode.cs diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeUpdateControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeUpdateControllerTests.cs index a1a8f7ec0..1349106c1 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeUpdateControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeUpdateControllerTests.cs @@ -31,24 +31,30 @@ public StreetcodeUpdateControllerTests(CustomWebApplicationFactory fact } [Fact] - [ExtractTestStreetcode] + [ExtractTestUpdateStreetcode] public async Task Update_ReturnSuccessStatusCode() { - StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; + StreetcodeContent expectedStreetcode = ExtractTestUpdateStreetcode.StreetcodeForTest; - var updateStreetCodeDTO = CreateMoqStreetCodeDTO(expectedStreetcode.Id); + var updateStreetCodeDTO = CreateMoqStreetCodeDTO( + expectedStreetcode.Id, + expectedStreetcode.Index, + expectedStreetcode.TransliterationUrl); var response = await client.UpdateAsync(updateStreetCodeDTO); Assert.True(response.IsSuccessStatusCode); } [Fact] - [ExtractTestStreetcode] + [ExtractTestUpdateStreetcode] public async Task Update_ChangesTitleAndTransliterationUrl() { - StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; + StreetcodeContent expectedStreetcode = ExtractTestUpdateStreetcode.StreetcodeForTest; - var updateStreetCodeDTO = CreateMoqStreetCodeDTO(expectedStreetcode.Id); + var updateStreetCodeDTO = CreateMoqStreetCodeDTO( + expectedStreetcode.Id, + expectedStreetcode.Index, + expectedStreetcode.TransliterationUrl); await client.UpdateAsync(updateStreetCodeDTO); var responseGetByIdUpdated = await client.GetByIdAsync(expectedStreetcode.Id); @@ -56,39 +62,48 @@ public async Task Update_ChangesTitleAndTransliterationUrl() Assert.Multiple(() => { Assert.Equal(updateStreetCodeDTO.Title, streetCodeContent.Title); - Assert.Equal(updateStreetCodeDTO.TransliterationUrl, streetCodeContent.TransliterationUrl); + Assert.Equal(updateStreetCodeDTO.DateString, streetCodeContent.DateString); }); } [Fact] - [ExtractTestStreetcode] - public async Task Update_WithIncorrectId_ReturnsBadRequest() + [ExtractTestUpdateStreetcode] + public async Task Update_WithInvalidId_ReturnsBadRequest() { - StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; - var updateStreetCodeDTO = CreateMoqStreetCodeDTO(expectedStreetcode.Id + 1); + StreetcodeContent expectedStreetcode = ExtractTestUpdateStreetcode.StreetcodeForTest; + var updateStreetCodeDTO = CreateMoqStreetCodeDTO( + expectedStreetcode.Id + 1, + expectedStreetcode.Index, + expectedStreetcode.TransliterationUrl); var response = await client.UpdateAsync(updateStreetCodeDTO); Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); } [Fact] - [ExtractTestStreetcode] + [ExtractTestUpdateStreetcode] public async Task Update_WithInvalidData_ReturnsBadRequest() { - StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; - var updateStreetCodeDTO = CreateMoqStreetCodeDTO(expectedStreetcode.Id); + StreetcodeContent expectedStreetcode = ExtractTestUpdateStreetcode.StreetcodeForTest; + var updateStreetCodeDTO = CreateMoqStreetCodeDTO( + expectedStreetcode.Id, + expectedStreetcode.Index, + expectedStreetcode.TransliterationUrl); updateStreetCodeDTO.Title = null; // Invalid data var response = await client.UpdateAsync(updateStreetCodeDTO); Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); } [Fact] - [ExtractTestStreetcode] + [ExtractTestUpdateStreetcode] public async Task Update_WithInvalidTags_ReturnsBadRequest() { - StreetcodeContent expectedStreetcode = ExtractTestStreetcode.StreetcodeForTest; - var updateStreetCodeDTO = CreateMoqStreetCodeDTO(expectedStreetcode.Id); + StreetcodeContent expectedStreetcode = ExtractTestUpdateStreetcode.StreetcodeForTest; + var updateStreetCodeDTO = CreateMoqStreetCodeDTO( + expectedStreetcode.Id, + expectedStreetcode.Index, + expectedStreetcode.TransliterationUrl); // Invalid tag data updateStreetCodeDTO.Tags = new List @@ -108,13 +123,14 @@ public async Task Update_WithInvalidTags_ReturnsBadRequest() Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); } - private StreetcodeUpdateDTO CreateMoqStreetCodeDTO(int id) + private StreetcodeUpdateDTO CreateMoqStreetCodeDTO(int id, int index, string transliterationUrl ) { return new StreetcodeUpdateDTO { Id = id, + Index = index, Title = "New Title", - TransliterationUrl = "new-transliteration-url", + TransliterationUrl = transliterationUrl, Tags = new List(), Facts = new List(), Audios = new List(), @@ -123,7 +139,7 @@ private StreetcodeUpdateDTO CreateMoqStreetCodeDTO(int id) Partners = new List(), Toponyms = new List(), Subtitles = new List(), - DateString = "20 травня 2023", + DateString = "22 травня 2023", TimelineItems = new List(), RelatedFigures = new List(), StreetcodeArts = new List(), diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestUpdateStreetcode.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestUpdateStreetcode.cs new file mode 100644 index 000000000..8e0f5b71a --- /dev/null +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestUpdateStreetcode.cs @@ -0,0 +1,56 @@ +using Streetcode.DAL.Entities.Streetcode; +using System.Reflection; +using Xunit.Sdk; + +namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode +{ + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] + class ExtractTestUpdateStreetcode : BeforeAfterTestAttribute + { + public static StreetcodeContent StreetcodeForTest; + + public override void Before(MethodInfo methodUnderTest) + { + var sqlDbHelper = BaseControllerTests.GetSqlDbHelper(); + StreetcodeForTest = sqlDbHelper.GetExistItem(); + if (StreetcodeForTest == null) + { + StreetcodeForTest = sqlDbHelper.AddNewItem(new StreetcodeContent() + { + Index = new Random().Next(0, 1000000), + UpdatedAt = DateTime.Now, + CreatedAt = DateTime.Now, + EventStartOrPersonBirthDate = DateTime.Now, + EventEndOrPersonDeathDate = DateTime.Now, + ViewCount = 1, + DateString = "20 травня 2023", + Alias = "dsf", + Title = "Title", + TransliterationUrl = Guid.NewGuid().ToString(), + Teaser = "Test Teaser", + }); + sqlDbHelper.SaveChanges(); + } + } + + public override void After(MethodInfo methodUnderTest) + { + var sqlDbHelper = BaseControllerTests.GetSqlDbHelper(); + var streetcodeContent = sqlDbHelper.GetExistItem(); + if (streetcodeContent != null) + { + // Restore the original StreetcodeContent + streetcodeContent.EventStartOrPersonBirthDate = StreetcodeForTest.EventStartOrPersonBirthDate; + streetcodeContent.EventEndOrPersonDeathDate = StreetcodeForTest.EventEndOrPersonDeathDate; + streetcodeContent.ViewCount = StreetcodeForTest.ViewCount; + streetcodeContent.DateString = StreetcodeForTest.DateString; + streetcodeContent.Alias = StreetcodeForTest.Alias; + streetcodeContent.Title = StreetcodeForTest.Title; + streetcodeContent.TransliterationUrl = StreetcodeForTest.TransliterationUrl; + streetcodeContent.Teaser = StreetcodeForTest.Teaser; + + sqlDbHelper.SaveChanges(); + } + } + } +} From e0f822f68fc608d3863aec7e06948c424c92696c Mon Sep 17 00:00:00 2001 From: Valerii Dekhtiuk Date: Mon, 18 Dec 2023 23:42:22 +0200 Subject: [PATCH 22/27] Some edition --- .../Streetcode.WebApi/appsettings.IntegrationTests.json | 4 +++- Streetcode/Streetcode.WebApi/appsettings.Local.json | 3 ++- Streetcode/Streetcode.WebApi/appsettings.json | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json index 53cd46a8b..384688a80 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json +++ b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json @@ -1,6 +1,8 @@ { "ConnectionStrings": { - "DefaultConnection": "Server=DESKTOP-I7Q35NQ\\SQLEXPRESS;Database=StreetcodeDbtest;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true;TrustServerCertificate=true" + //"DefaultConnection": "Server=DESKTOP-I7Q35NQ\\SQLEXPRESS;Database=StreetcodeDbtest;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true;TrustServerCertificate=true" + + "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" }, "Blob": { "BlobStoreKey": "BigThirtyTwoBiteCoolTestKeyCrypt", diff --git a/Streetcode/Streetcode.WebApi/appsettings.Local.json b/Streetcode/Streetcode.WebApi/appsettings.Local.json index 14b44479d..469b824dc 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.Local.json +++ b/Streetcode/Streetcode.WebApi/appsettings.Local.json @@ -1,6 +1,7 @@ { "ConnectionStrings": { - "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" + // "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" + "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" }, "CORS": { "AllowedOrigins": [ "http://localhost:3000" ], diff --git a/Streetcode/Streetcode.WebApi/appsettings.json b/Streetcode/Streetcode.WebApi/appsettings.json index c66f7473d..1e6c1d2c4 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.json +++ b/Streetcode/Streetcode.WebApi/appsettings.json @@ -1,6 +1,7 @@ { "ConnectionStrings": { - "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" + // "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" + "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" }, "EmailConfiguration": { "From": "streetcodefordev@gmail.com", From b0db67f87baa1edf556fa4592d4e41e4f5058b30 Mon Sep 17 00:00:00 2001 From: Valerii Dekhtiuk Date: Mon, 18 Dec 2023 23:58:17 +0200 Subject: [PATCH 23/27] Add some corrections --- .../appsettings.IntegrationTests.json | 4 +- .../Streetcode.WebApi/appsettings.Local.json | 3 +- Streetcode/Streetcode.WebApi/appsettings.json | 3 +- .../Update/StreetcodeUpdateControllerTests.cs | 151 ------------------ .../Streetcode/ExtractTestUpdateStreetcode.cs | 56 ------- .../Streetcode.XIntegrationTest.csproj | 4 + 6 files changed, 7 insertions(+), 214 deletions(-) delete mode 100644 Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeUpdateControllerTests.cs delete mode 100644 Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestUpdateStreetcode.cs diff --git a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json index 384688a80..53cd46a8b 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json +++ b/Streetcode/Streetcode.WebApi/appsettings.IntegrationTests.json @@ -1,8 +1,6 @@ { "ConnectionStrings": { - //"DefaultConnection": "Server=DESKTOP-I7Q35NQ\\SQLEXPRESS;Database=StreetcodeDbtest;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true;TrustServerCertificate=true" - - "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" + "DefaultConnection": "Server=DESKTOP-I7Q35NQ\\SQLEXPRESS;Database=StreetcodeDbtest;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true;TrustServerCertificate=true" }, "Blob": { "BlobStoreKey": "BigThirtyTwoBiteCoolTestKeyCrypt", diff --git a/Streetcode/Streetcode.WebApi/appsettings.Local.json b/Streetcode/Streetcode.WebApi/appsettings.Local.json index 469b824dc..0fe7bd709 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.Local.json +++ b/Streetcode/Streetcode.WebApi/appsettings.Local.json @@ -1,7 +1,6 @@ { "ConnectionStrings": { - // "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" - "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" + "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" }, "CORS": { "AllowedOrigins": [ "http://localhost:3000" ], diff --git a/Streetcode/Streetcode.WebApi/appsettings.json b/Streetcode/Streetcode.WebApi/appsettings.json index 1e6c1d2c4..73350553e 100644 --- a/Streetcode/Streetcode.WebApi/appsettings.json +++ b/Streetcode/Streetcode.WebApi/appsettings.json @@ -1,7 +1,6 @@ { "ConnectionStrings": { - // "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" - "DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=StreetcodeDbtest;Integrated Security=True" + "DefaultConnection": "Server=127.0.0.1;Database=StreetcodeDb;User Id=sa;Password=Admin@1234;MultipleActiveResultSets=true" }, "EmailConfiguration": { "From": "streetcodefordev@gmail.com", diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeUpdateControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeUpdateControllerTests.cs deleted file mode 100644 index 1349106c1..000000000 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Streetcode/Update/StreetcodeUpdateControllerTests.cs +++ /dev/null @@ -1,151 +0,0 @@ -using Streetcode.BLL.DTO.AdditionalContent.Subtitles; -using Streetcode.BLL.DTO.AdditionalContent.Tag; -using Streetcode.BLL.DTO.Analytics.Update; -using Streetcode.BLL.DTO.Media.Art; -using Streetcode.BLL.DTO.Media.Audio; -using Streetcode.BLL.DTO.Media.Images; -using Streetcode.BLL.DTO.Media.Video; -using Streetcode.BLL.DTO.Partners.Update; -using Streetcode.BLL.DTO.Sources.Update; -using Streetcode.BLL.DTO.Streetcode.RelatedFigure; -using Streetcode.BLL.DTO.Streetcode.TextContent.Fact; -using Streetcode.BLL.DTO.Streetcode.Update; -using Streetcode.BLL.DTO.Timeline.Update; -using Streetcode.BLL.DTO.Toponyms; -using Streetcode.BLL.Enums; -using Streetcode.DAL.Entities.Streetcode; -using Streetcode.XIntegrationTest.ControllerTests.Utils; -using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; -using System.Net; -using Xunit; - -namespace Streetcode.XIntegrationTest.ControllerTests.Streetcode.Update -{ - public class StreetcodeUpdateControllerTests : - BaseControllerTests, IClassFixture> - { - public StreetcodeUpdateControllerTests(CustomWebApplicationFactory factory) - : base(factory, "/api/Streetcode") - { - - } - - [Fact] - [ExtractTestUpdateStreetcode] - public async Task Update_ReturnSuccessStatusCode() - { - StreetcodeContent expectedStreetcode = ExtractTestUpdateStreetcode.StreetcodeForTest; - - var updateStreetCodeDTO = CreateMoqStreetCodeDTO( - expectedStreetcode.Id, - expectedStreetcode.Index, - expectedStreetcode.TransliterationUrl); - var response = await client.UpdateAsync(updateStreetCodeDTO); - - Assert.True(response.IsSuccessStatusCode); - } - - [Fact] - [ExtractTestUpdateStreetcode] - public async Task Update_ChangesTitleAndTransliterationUrl() - { - StreetcodeContent expectedStreetcode = ExtractTestUpdateStreetcode.StreetcodeForTest; - - var updateStreetCodeDTO = CreateMoqStreetCodeDTO( - expectedStreetcode.Id, - expectedStreetcode.Index, - expectedStreetcode.TransliterationUrl); - await client.UpdateAsync(updateStreetCodeDTO); - - var responseGetByIdUpdated = await client.GetByIdAsync(expectedStreetcode.Id); - var streetCodeContent = CaseIsensitiveJsonDeserializer.Deserialize(responseGetByIdUpdated.Content); - Assert.Multiple(() => - { - Assert.Equal(updateStreetCodeDTO.Title, streetCodeContent.Title); - Assert.Equal(updateStreetCodeDTO.DateString, streetCodeContent.DateString); - }); - } - - [Fact] - [ExtractTestUpdateStreetcode] - public async Task Update_WithInvalidId_ReturnsBadRequest() - { - - StreetcodeContent expectedStreetcode = ExtractTestUpdateStreetcode.StreetcodeForTest; - var updateStreetCodeDTO = CreateMoqStreetCodeDTO( - expectedStreetcode.Id + 1, - expectedStreetcode.Index, - expectedStreetcode.TransliterationUrl); - var response = await client.UpdateAsync(updateStreetCodeDTO); - - Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); - } - - [Fact] - [ExtractTestUpdateStreetcode] - public async Task Update_WithInvalidData_ReturnsBadRequest() - { - StreetcodeContent expectedStreetcode = ExtractTestUpdateStreetcode.StreetcodeForTest; - var updateStreetCodeDTO = CreateMoqStreetCodeDTO( - expectedStreetcode.Id, - expectedStreetcode.Index, - expectedStreetcode.TransliterationUrl); - updateStreetCodeDTO.Title = null; // Invalid data - var response = await client.UpdateAsync(updateStreetCodeDTO); - Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); - } - - [Fact] - [ExtractTestUpdateStreetcode] - public async Task Update_WithInvalidTags_ReturnsBadRequest() - { - StreetcodeContent expectedStreetcode = ExtractTestUpdateStreetcode.StreetcodeForTest; - var updateStreetCodeDTO = CreateMoqStreetCodeDTO( - expectedStreetcode.Id, - expectedStreetcode.Index, - expectedStreetcode.TransliterationUrl); - - // Invalid tag data - updateStreetCodeDTO.Tags = new List - { - new StreetcodeTagUpdateDTO - { - Id = 9999, // Non-existent tag ID - Title = "Invalid Tag", - IsVisible = true, - Index = 0, - StreetcodeId = expectedStreetcode.Id, - ModelState = ModelState.Updated - }, - }; - - var response = await client.UpdateAsync(updateStreetCodeDTO); - Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); - } - - private StreetcodeUpdateDTO CreateMoqStreetCodeDTO(int id, int index, string transliterationUrl ) - { - return new StreetcodeUpdateDTO - { - Id = id, - Index = index, - Title = "New Title", - TransliterationUrl = transliterationUrl, - Tags = new List(), - Facts = new List(), - Audios = new List(), - Images = new List(), - Videos = new List(), - Partners = new List(), - Toponyms = new List(), - Subtitles = new List(), - DateString = "22 травня 2023", - TimelineItems = new List(), - RelatedFigures = new List(), - StreetcodeArts = new List(), - StatisticRecords = new List(), - StreetcodeCategoryContents = new List(), - }; - } - } -} diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestUpdateStreetcode.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestUpdateStreetcode.cs deleted file mode 100644 index 8e0f5b71a..000000000 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestUpdateStreetcode.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Streetcode.DAL.Entities.Streetcode; -using System.Reflection; -using Xunit.Sdk; - -namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode -{ - [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - class ExtractTestUpdateStreetcode : BeforeAfterTestAttribute - { - public static StreetcodeContent StreetcodeForTest; - - public override void Before(MethodInfo methodUnderTest) - { - var sqlDbHelper = BaseControllerTests.GetSqlDbHelper(); - StreetcodeForTest = sqlDbHelper.GetExistItem(); - if (StreetcodeForTest == null) - { - StreetcodeForTest = sqlDbHelper.AddNewItem(new StreetcodeContent() - { - Index = new Random().Next(0, 1000000), - UpdatedAt = DateTime.Now, - CreatedAt = DateTime.Now, - EventStartOrPersonBirthDate = DateTime.Now, - EventEndOrPersonDeathDate = DateTime.Now, - ViewCount = 1, - DateString = "20 травня 2023", - Alias = "dsf", - Title = "Title", - TransliterationUrl = Guid.NewGuid().ToString(), - Teaser = "Test Teaser", - }); - sqlDbHelper.SaveChanges(); - } - } - - public override void After(MethodInfo methodUnderTest) - { - var sqlDbHelper = BaseControllerTests.GetSqlDbHelper(); - var streetcodeContent = sqlDbHelper.GetExistItem(); - if (streetcodeContent != null) - { - // Restore the original StreetcodeContent - streetcodeContent.EventStartOrPersonBirthDate = StreetcodeForTest.EventStartOrPersonBirthDate; - streetcodeContent.EventEndOrPersonDeathDate = StreetcodeForTest.EventEndOrPersonDeathDate; - streetcodeContent.ViewCount = StreetcodeForTest.ViewCount; - streetcodeContent.DateString = StreetcodeForTest.DateString; - streetcodeContent.Alias = StreetcodeForTest.Alias; - streetcodeContent.Title = StreetcodeForTest.Title; - streetcodeContent.TransliterationUrl = StreetcodeForTest.TransliterationUrl; - streetcodeContent.Teaser = StreetcodeForTest.Teaser; - - sqlDbHelper.SaveChanges(); - } - } - } -} diff --git a/Streetcode/Streetcode.XIntegrationTest/Streetcode.XIntegrationTest.csproj b/Streetcode/Streetcode.XIntegrationTest/Streetcode.XIntegrationTest.csproj index 9e022df0c..460f80ab3 100644 --- a/Streetcode/Streetcode.XIntegrationTest/Streetcode.XIntegrationTest.csproj +++ b/Streetcode/Streetcode.XIntegrationTest/Streetcode.XIntegrationTest.csproj @@ -51,4 +51,8 @@ + + + + From b30e441cdca4016a45d4fe7f930f3daae4fcc2f5 Mon Sep 17 00:00:00 2001 From: Oleh-Kril <91199925+Oleh-Kril@users.noreply.github.com> Date: Wed, 20 Dec 2023 17:48:24 +0200 Subject: [PATCH 24/27] merge master into develop (#974) * add swagger for stage and local * Changed datestring max length to 100 instead of 50 (#901) (#933) --------- Co-authored-by: Vitalii <98163405+MementoMorj@users.noreply.github.com> Co-authored-by: Andrii Malynovskyi <57286096+malyna2@users.noreply.github.com> Co-authored-by: Adeodonne Co-authored-by: Bohdan Bozhyk <53005363+Adeodonne@users.noreply.github.com> --- Streetcode/Streetcode.WebApi/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Streetcode/Streetcode.WebApi/Program.cs b/Streetcode/Streetcode.WebApi/Program.cs index 470debe52..86f211c7b 100644 --- a/Streetcode/Streetcode.WebApi/Program.cs +++ b/Streetcode/Streetcode.WebApi/Program.cs @@ -32,7 +32,7 @@ SupportedUICultures = supportedCulture, ApplyCurrentCultureToResponseHeaders = true }); -if (app.Environment.EnvironmentName == "Local") +if (app.Environment.EnvironmentName != "Production") { app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebAPIv5 v1")); From 52ad4ecfe65473533809d01ba0dccb0fadfada7e Mon Sep 17 00:00:00 2001 From: mykola-krai <133663112+mykola-krai@users.noreply.github.com> Date: Fri, 29 Dec 2023 18:57:31 +0200 Subject: [PATCH 25/27] Adding unit tests (#884) * Deleting the AuthorizeRoles file * Deleting the IdComparer file * Deleting the file DateToStringConverter * Adding unit tests for StreetcodeFactory * Rewriting HangfireDashboardAuthorizationFilter and adding unit tests for it * add hangfire to unit tests project --------- Co-authored-by: Oleh-Kril --- .../Util/DateToStringConverter.cs | 39 ------- Streetcode/Streetcode.BLL/Util/IdComparer.cs | 23 ---- .../Attributes/AuthorizeRoles.cs | 12 --- .../Controllers/Media/AudioController.cs | 1 - .../Media/Images/ImageController.cs | 1 - .../Partners/PartnersController.cs | 1 - .../Controllers/Source/SourcesController.cs | 1 - .../Streetcode/TextContent/FactController.cs | 1 - .../Controllers/Team/TeamController.cs | 1 - .../Controllers/Users/UserController.cs | 1 - .../HangfireDashboardAuthorizationFilter.cs | 22 ++-- .../Streetcode.WebApi.csproj | 2 +- .../Streetcode/StreetcodeFactoryTests.cs | 35 ++++++ .../HangfireAuthorizationFilterTests.cs | 102 ++++++++++++++++++ .../Streetcode.XUnitTest.csproj | 2 + 15 files changed, 156 insertions(+), 88 deletions(-) delete mode 100644 Streetcode/Streetcode.BLL/Util/DateToStringConverter.cs delete mode 100644 Streetcode/Streetcode.BLL/Util/IdComparer.cs delete mode 100644 Streetcode/Streetcode.WebApi/Attributes/AuthorizeRoles.cs create mode 100644 Streetcode/Streetcode.XUnitTest/Factories/Streetcode/StreetcodeFactoryTests.cs create mode 100644 Streetcode/Streetcode.XUnitTest/Hangfire/HangfireAuthorizationFilterTests.cs diff --git a/Streetcode/Streetcode.BLL/Util/DateToStringConverter.cs b/Streetcode/Streetcode.BLL/Util/DateToStringConverter.cs deleted file mode 100644 index 3f07d982a..000000000 --- a/Streetcode/Streetcode.BLL/Util/DateToStringConverter.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Streetcode.DAL.Enums; - -namespace Streetcode.BLL.Util -{ - public class DateToStringConverter - { - public static string FromDateToString(DateTime date, DateViewPattern pattern) - { - return pattern switch - { - DateViewPattern.Year => date.ToString("yyyy"), - DateViewPattern.MonthYear => date.ToString("yyyy, MMMM"), - DateViewPattern.SeasonYear => $"{GetSeason(date)} {date.Year}", - DateViewPattern.DateMonthYear => date.ToString("yyyy, d MMMM"), - _ =>"" - }; - } - - private static string GetSeason(DateTime dateTime) - { - if (dateTime.Month < 3 || dateTime.Month == 12) - { - return "зима"; - } - else if (dateTime.Month >= 3 && dateTime.Month < 6) - { - return "весна"; - } - else if(dateTime.Month >= 6 && dateTime.Month < 9) - { - return "літо"; - } - else - { - return "осінь"; - } - } - } -} diff --git a/Streetcode/Streetcode.BLL/Util/IdComparer.cs b/Streetcode/Streetcode.BLL/Util/IdComparer.cs deleted file mode 100644 index 758d754b6..000000000 --- a/Streetcode/Streetcode.BLL/Util/IdComparer.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using Streetcode.DAL.Entities.Partners; - -namespace Streetcode.BLL.Util -{ - public class IdComparer : IEqualityComparer - { - public bool Equals(PartnerSourceLink? x, PartnerSourceLink? y) - { - if(x == null || y == null) - { - return false; - } - - return x.Id == y.Id; - } - - public int GetHashCode([DisallowNull] PartnerSourceLink obj) - { - return obj.Id.GetHashCode(); - } - } -} diff --git a/Streetcode/Streetcode.WebApi/Attributes/AuthorizeRoles.cs b/Streetcode/Streetcode.WebApi/Attributes/AuthorizeRoles.cs deleted file mode 100644 index c7d07d832..000000000 --- a/Streetcode/Streetcode.WebApi/Attributes/AuthorizeRoles.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.AspNetCore.Authorization; -using Streetcode.DAL.Enums; -namespace Streetcode.WebApi.Attributes -{ - public class AuthorizeRoles : AuthorizeAttribute - { - public AuthorizeRoles(params UserRole[] userRoles) - { - Roles = string.Join(",", userRoles.Select(r => r.ToString()).ToArray()); - } - } -} diff --git a/Streetcode/Streetcode.WebApi/Controllers/Media/AudioController.cs b/Streetcode/Streetcode.WebApi/Controllers/Media/AudioController.cs index ae19e3918..90fa93a86 100644 --- a/Streetcode/Streetcode.WebApi/Controllers/Media/AudioController.cs +++ b/Streetcode/Streetcode.WebApi/Controllers/Media/AudioController.cs @@ -10,7 +10,6 @@ using Streetcode.BLL.MediatR.Media.Audio.Update; using Streetcode.BLL.MediatR.Media.Image.GetByStreetcodeId; using Streetcode.DAL.Enums; -using Streetcode.WebApi.Attributes; namespace Streetcode.WebApi.Controllers.Media; diff --git a/Streetcode/Streetcode.WebApi/Controllers/Media/Images/ImageController.cs b/Streetcode/Streetcode.WebApi/Controllers/Media/Images/ImageController.cs index 867b280c0..60bb6d8b2 100644 --- a/Streetcode/Streetcode.WebApi/Controllers/Media/Images/ImageController.cs +++ b/Streetcode/Streetcode.WebApi/Controllers/Media/Images/ImageController.cs @@ -7,7 +7,6 @@ using Streetcode.BLL.MediatR.Media.Image.Create; using Streetcode.BLL.MediatR.Media.Image.Delete; using Streetcode.BLL.MediatR.Media.Image.Update; -using Streetcode.WebApi.Attributes; using Streetcode.DAL.Enums; using Microsoft.Net.Http.Headers; diff --git a/Streetcode/Streetcode.WebApi/Controllers/Partners/PartnersController.cs b/Streetcode/Streetcode.WebApi/Controllers/Partners/PartnersController.cs index e7845935d..6d551fd5f 100644 --- a/Streetcode/Streetcode.WebApi/Controllers/Partners/PartnersController.cs +++ b/Streetcode/Streetcode.WebApi/Controllers/Partners/PartnersController.cs @@ -10,7 +10,6 @@ using Streetcode.BLL.MediatR.Partners.GetByStreetcodeIdToUpdate; using Streetcode.DAL.Entities.Partners; using Streetcode.DAL.Enums; -using Streetcode.WebApi.Attributes; namespace Streetcode.WebApi.Controllers.Partners; diff --git a/Streetcode/Streetcode.WebApi/Controllers/Source/SourcesController.cs b/Streetcode/Streetcode.WebApi/Controllers/Source/SourcesController.cs index 6936f6bdd..3e246c69d 100644 --- a/Streetcode/Streetcode.WebApi/Controllers/Source/SourcesController.cs +++ b/Streetcode/Streetcode.WebApi/Controllers/Source/SourcesController.cs @@ -6,7 +6,6 @@ using Streetcode.BLL.MediatR.Sources.SourceLink.Update; using Streetcode.BLL.MediatR.Sources.SourceLink.Delete; using Streetcode.DAL.Enums; -using Streetcode.WebApi.Attributes; using Streetcode.BLL.MediatR.Sources.SourceLinkCategory.GetAll; using Streetcode.BLL.MediatR.Sources.SourceLinkCategory.GetCategoryContentByStreetcodeId; diff --git a/Streetcode/Streetcode.WebApi/Controllers/Streetcode/TextContent/FactController.cs b/Streetcode/Streetcode.WebApi/Controllers/Streetcode/TextContent/FactController.cs index ad9215920..3e082da34 100644 --- a/Streetcode/Streetcode.WebApi/Controllers/Streetcode/TextContent/FactController.cs +++ b/Streetcode/Streetcode.WebApi/Controllers/Streetcode/TextContent/FactController.cs @@ -7,7 +7,6 @@ using Streetcode.BLL.MediatR.Streetcode.Fact.GetByStreetcodeId; using Streetcode.BLL.MediatR.Streetcode.Fact.Update; using Streetcode.DAL.Enums; -using Streetcode.WebApi.Attributes; namespace Streetcode.WebApi.Controllers.Streetcode.TextContent; diff --git a/Streetcode/Streetcode.WebApi/Controllers/Team/TeamController.cs b/Streetcode/Streetcode.WebApi/Controllers/Team/TeamController.cs index dcfed564b..a5d5d28e1 100644 --- a/Streetcode/Streetcode.WebApi/Controllers/Team/TeamController.cs +++ b/Streetcode/Streetcode.WebApi/Controllers/Team/TeamController.cs @@ -8,7 +8,6 @@ using Streetcode.BLL.MediatR.Team.GetByRoleId; using Streetcode.BLL.MediatR.Team.Update; using Streetcode.DAL.Enums; -using Streetcode.WebApi.Attributes; namespace Streetcode.WebApi.Controllers.Team { diff --git a/Streetcode/Streetcode.WebApi/Controllers/Users/UserController.cs b/Streetcode/Streetcode.WebApi/Controllers/Users/UserController.cs index 50f7ca5db..a2cea0419 100644 --- a/Streetcode/Streetcode.WebApi/Controllers/Users/UserController.cs +++ b/Streetcode/Streetcode.WebApi/Controllers/Users/UserController.cs @@ -4,7 +4,6 @@ using Streetcode.BLL.MediatR.Users.Login; using Streetcode.BLL.MediatR.Users.RefreshToken; using Streetcode.DAL.Enums; -using Streetcode.WebApi.Attributes; namespace Streetcode.WebApi.Controllers.Users { diff --git a/Streetcode/Streetcode.WebApi/Hangfire/HangfireDashboardAuthorizationFilter.cs b/Streetcode/Streetcode.WebApi/Hangfire/HangfireDashboardAuthorizationFilter.cs index 31369e899..0577b798e 100644 --- a/Streetcode/Streetcode.WebApi/Hangfire/HangfireDashboardAuthorizationFilter.cs +++ b/Streetcode/Streetcode.WebApi/Hangfire/HangfireDashboardAuthorizationFilter.cs @@ -1,3 +1,4 @@ +using System.Security.Claims; using Hangfire.Dashboard; using Streetcode.DAL.Enums; @@ -5,12 +6,21 @@ namespace Streetcode.BLL.Services.Hangfire; public class HangfireDashboardAuthorizationFilter : IDashboardAuthorizationFilter { - public bool Authorize(DashboardContext context) - { - var user = context.GetHttpContext().User; + public bool Authorize(DashboardContext context) + { + var user = GetUser(context); + var isMainAdministrator = IsMainAdministrator(user); - var isAdministrator = user.IsInRole(UserRole.MainAdministrator.ToString()); + return isMainAdministrator; + } - return isAdministrator; - } + public bool IsMainAdministrator(ClaimsPrincipal user) + { + return user.IsInRole(UserRole.MainAdministrator.ToString()); + } + + public virtual ClaimsPrincipal GetUser(DashboardContext context) + { + return context.GetHttpContext().User; + } } \ No newline at end of file diff --git a/Streetcode/Streetcode.WebApi/Streetcode.WebApi.csproj b/Streetcode/Streetcode.WebApi/Streetcode.WebApi.csproj index e04a3f4e5..300b16659 100644 --- a/Streetcode/Streetcode.WebApi/Streetcode.WebApi.csproj +++ b/Streetcode/Streetcode.WebApi/Streetcode.WebApi.csproj @@ -18,7 +18,7 @@ - + diff --git a/Streetcode/Streetcode.XUnitTest/Factories/Streetcode/StreetcodeFactoryTests.cs b/Streetcode/Streetcode.XUnitTest/Factories/Streetcode/StreetcodeFactoryTests.cs new file mode 100644 index 000000000..92f1f1814 --- /dev/null +++ b/Streetcode/Streetcode.XUnitTest/Factories/Streetcode/StreetcodeFactoryTests.cs @@ -0,0 +1,35 @@ +using Streetcode.BLL.Factories.Streetcode; +using Xunit; +using Streetcode.DAL.Enums; +using Streetcode.DAL.Entities.Streetcode.Types; + +namespace Streetcode.XUnitTest.Factories.Streetcode; + +public class StreetcodeFactoryTests +{ + [Fact] + public void CreateStreetcode_StreetcodeTypePerson_ReturnsPersonStreetcode() + { + // Arrange + var streetcodeTypePerson = StreetcodeType.Person; + + // Act + var streetcode = StreetcodeFactory.CreateStreetcode(streetcodeTypePerson); + + // Assert + Assert.IsType(streetcode); + } + + [Fact] + public void CreateStreetcode_StreetcodeTypeEvent_ReturnsEventStreetcode() + { + // Arrange + var streetcodeTypeEvent = StreetcodeType.Event; + + // Act + var streetcode = StreetcodeFactory.CreateStreetcode(streetcodeTypeEvent); + + // Assert + Assert.IsType(streetcode); + } +} \ No newline at end of file diff --git a/Streetcode/Streetcode.XUnitTest/Hangfire/HangfireAuthorizationFilterTests.cs b/Streetcode/Streetcode.XUnitTest/Hangfire/HangfireAuthorizationFilterTests.cs new file mode 100644 index 000000000..0756524b8 --- /dev/null +++ b/Streetcode/Streetcode.XUnitTest/Hangfire/HangfireAuthorizationFilterTests.cs @@ -0,0 +1,102 @@ +using System.Security.Claims; +using Hangfire; +using Hangfire.Annotations; +using Hangfire.Dashboard; +using Moq; +using Streetcode.BLL.Services.Hangfire; +using Streetcode.DAL.Enums; +using Xunit; + +namespace Streetcode.XUnitTest.Hangfire; + +public class HangfireAuthorizationFilterTests +{ + public static IEnumerable NonMainAdministratorRoles => + new List + { + new object[] { UserRole.Administrator.ToString() }, + new object[] { UserRole.Moderator.ToString() }, + new object[] { string.Empty }, + }; + + private class MockDashboardContext : DashboardContext + { + public MockDashboardContext([NotNull] JobStorage storage, [NotNull] DashboardOptions options) + : base(storage, options) + { + } + } + + public class MockHangfireDashboardAuthorizationFilter : HangfireDashboardAuthorizationFilter + { + private readonly string _userRole; + + public MockHangfireDashboardAuthorizationFilter(string userRole) + { + this._userRole = userRole; + } + + public override ClaimsPrincipal GetUser(DashboardContext context) + { + return new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Role, _userRole) })); + } + } + + [Fact] + public void IsMainAdministrator_UserIsMainAdministrator_ReturnsTrue() + { + // Arrange + var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Role, UserRole.MainAdministrator.ToString()) })); + var filter = new HangfireDashboardAuthorizationFilter(); + + // Act + bool result = filter.IsMainAdministrator(user); + + // Assert + Assert.True(result); + } + + [Theory] + [MemberData(nameof(NonMainAdministratorRoles))] + public void IsMainAdministrator_UserIsNotMainAdministrator_ReturnsFalse(string role) + { + // Arrange + var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Role, role) })); + var filter = new HangfireDashboardAuthorizationFilter(); + + // Act + bool result = filter.IsMainAdministrator(user); + + // Assert + Assert.False(result); + } + + [Fact] + public void Authorize_UserIsMainAdministrator_ReturnsTrue() + { + // Arrange + var mockDashboardContext = new MockDashboardContext(new Mock().Object, new Mock().Object); + var mockFilter = new MockHangfireDashboardAuthorizationFilter(UserRole.MainAdministrator.ToString()); + + // Act + bool result = mockFilter.Authorize(mockDashboardContext); + + // Assert + Assert.True(result); + } + + [Theory] + [MemberData(nameof(NonMainAdministratorRoles))] + public void Authorize_UserIsNotMainAdministrator_ReturnsFalse(string role) + { + // Arrange + var mockDashboardContext = new MockDashboardContext(new Mock().Object, new Mock().Object); + var mockFilter = new MockHangfireDashboardAuthorizationFilter(role); + + // Act + bool result = mockFilter.Authorize(mockDashboardContext); + + // Assert + Assert.False(result); + } +} \ No newline at end of file diff --git a/Streetcode/Streetcode.XUnitTest/Streetcode.XUnitTest.csproj b/Streetcode/Streetcode.XUnitTest/Streetcode.XUnitTest.csproj index 7a9e61659..efb7c1e0f 100644 --- a/Streetcode/Streetcode.XUnitTest/Streetcode.XUnitTest.csproj +++ b/Streetcode/Streetcode.XUnitTest/Streetcode.XUnitTest.csproj @@ -17,6 +17,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -44,6 +45,7 @@ + \ No newline at end of file From 62f6f3d0c16b56d2daf98f7798828c965a715bdb Mon Sep 17 00:00:00 2001 From: Bohdan Bozhyk <53005363+Adeodonne@users.noreply.github.com> Date: Sat, 30 Dec 2023 18:35:54 +0200 Subject: [PATCH 26/27] fix swagger for stage (#993) --- Streetcode/Streetcode.WebApi/Program.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Streetcode/Streetcode.WebApi/Program.cs b/Streetcode/Streetcode.WebApi/Program.cs index 86f211c7b..b36fe685f 100644 --- a/Streetcode/Streetcode.WebApi/Program.cs +++ b/Streetcode/Streetcode.WebApi/Program.cs @@ -4,6 +4,7 @@ using Streetcode.WebApi.Extensions; using Microsoft.AspNetCore.Localization; using Streetcode.BLL.Services.Hangfire; +using Microsoft.AspNetCore.HttpOverrides; var builder = WebApplication.CreateBuilder(args); @@ -18,8 +19,16 @@ builder.Services.ConfigureInstagram(builder); builder.Services.ConfigureSerilog(builder); builder.Services.ConfigureRateLimitMiddleware(builder); +builder.Services.Configure(options => +{ + options.ForwardedHeaders = + ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; +}); var app = builder.Build(); + +app.UseForwardedHeaders(); + var supportedCulture = new[] { new CultureInfo("en-US"), From 793d4c00ee121c8e8bf0b902c2407b304f00208a Mon Sep 17 00:00:00 2001 From: BohdanBybliv <125794488+BohdanBybliv@users.noreply.github.com> Date: Sun, 7 Jan 2024 20:07:18 +0200 Subject: [PATCH 27/27] Revert "Integration tests for Streetcode Update Controller" --- .../GetCount/GetStreetcodesCountHander.cs | 23 +- .../GetCount/GetStreetcodesCountQuery.cs | 2 +- .../Entities/Streetcode/StreetcodeContent.cs | 2 +- ...0231130202258_DatestringLength.Designer.cs | 1595 ----------------- .../20231130202258_DatestringLength.cs | 37 - .../StreetcodeDbContextModelSnapshot.cs | 4 +- .../Streetcode/StreetcodeController.cs | 4 +- .../CoordinateControllerTests.cs | 12 +- .../AdditionalContent/TagControllerTests.cs | 19 +- .../ControllerTests/BaseControllerTests.cs | 13 +- .../Media/AudioControllerTests.cs | 1 + .../Images/StreetcodeArtControllerTests.cs | 10 +- .../Media/VideoControllerTests.cs | 9 +- .../ExtractTestStreetcodeCoordinate.cs | 16 +- .../ExtractTestToponymCoordinate.cs | 7 +- .../Subtitle/ExtractTestSubtitle.cs | 13 +- .../AdditionalContent/Tag/ExtractTestTag.cs | 5 +- .../Tag/StreetcodeTagIndexSetup.cs | 5 + .../Media/Images/Art/ExtractTestArt.cs | 2 +- .../Media/Images/Image/ExtractTestImage.cs | 2 +- .../StreetcodeArt/ExtractTestStreetcodeArt.cs | 4 +- .../Media/Video/ExtractTestVideo.cs | 2 +- .../Partners/ExtractTestPartners.cs | 7 +- .../ExtractTestSourceLinkCategory.cs | 10 +- .../Streetcode/ExtractTestStreetcode.cs | 24 +- .../RelatedFigure/ExtractTestRelatedFigure.cs | 7 +- .../TextContent/Facts/ExtractTestFact.cs | 7 +- .../TextContent/Terms/ExstractTestTerm.cs | 8 +- .../TextContent/Texts/ExstractTestText.cs | 7 +- .../Timelines/ExtractTestTimelineItem.cs | 7 +- .../Toponyms/ExtractTestToponym.cs | 5 +- .../ExtractTestTransactionLink.cs | 9 +- .../Utils/CustomWebApplicationFactory.cs | 2 +- .../ControllerTests/Utils/SqlDbHelper.cs | 6 - .../ControllerTests/Utils/StreetcodeClient.cs | 23 +- .../Utils/BlobStorageFixture.cs | 6 +- 36 files changed, 157 insertions(+), 1758 deletions(-) delete mode 100644 Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.Designer.cs delete mode 100644 Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.cs diff --git a/Streetcode/Streetcode.BLL/MediatR/Streetcode/Streetcode/GetCount/GetStreetcodesCountHander.cs b/Streetcode/Streetcode.BLL/MediatR/Streetcode/Streetcode/GetCount/GetStreetcodesCountHander.cs index bc5b679af..d9405bd15 100644 --- a/Streetcode/Streetcode.BLL/MediatR/Streetcode/Streetcode/GetCount/GetStreetcodesCountHander.cs +++ b/Streetcode/Streetcode.BLL/MediatR/Streetcode/Streetcode/GetCount/GetStreetcodesCountHander.cs @@ -1,11 +1,16 @@ -using AutoMapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AutoMapper; using FluentResults; using MediatR; using Microsoft.Extensions.Localization; +using Streetcode.BLL.DTO.Streetcode; using Streetcode.BLL.Interfaces.Logging; +using Streetcode.BLL.MediatR.Streetcode.Streetcode.GetAllShort; using Streetcode.BLL.SharedResource; -using Streetcode.DAL.Entities.Streetcode; -using Streetcode.DAL.Enums; using Streetcode.DAL.Repositories.Interfaces.Base; namespace Streetcode.BLL.MediatR.Streetcode.Streetcode.GetCount @@ -26,17 +31,7 @@ public GetStreetcodesCountHander(IRepositoryWrapper repositoryWrapper, IMapper m public async Task> Handle(GetStreetcodesCountQuery request, CancellationToken cancellationToken) { - IEnumerable streetcodes; - - if (request.onlyPublished) - { - streetcodes = await _repositoryWrapper.StreetcodeRepository - .GetAllAsync(s => s.Status == StreetcodeStatus.Published); - } - else - { - streetcodes = await _repositoryWrapper.StreetcodeRepository.GetAllAsync(); - } + var streetcodes = await _repositoryWrapper.StreetcodeRepository.GetAllAsync(); if (streetcodes != null) { diff --git a/Streetcode/Streetcode.BLL/MediatR/Streetcode/Streetcode/GetCount/GetStreetcodesCountQuery.cs b/Streetcode/Streetcode.BLL/MediatR/Streetcode/Streetcode/GetCount/GetStreetcodesCountQuery.cs index 8fb88e9dc..0f8262151 100644 --- a/Streetcode/Streetcode.BLL/MediatR/Streetcode/Streetcode/GetCount/GetStreetcodesCountQuery.cs +++ b/Streetcode/Streetcode.BLL/MediatR/Streetcode/Streetcode/GetCount/GetStreetcodesCountQuery.cs @@ -3,5 +3,5 @@ namespace Streetcode.BLL.MediatR.Streetcode.Streetcode.GetCount { - public record GetStreetcodesCountQuery(bool onlyPublished) : IRequest>; + public record GetStreetcodesCountQuery : IRequest>; } diff --git a/Streetcode/Streetcode.DAL/Entities/Streetcode/StreetcodeContent.cs b/Streetcode/Streetcode.DAL/Entities/Streetcode/StreetcodeContent.cs index e71306ebc..4514ce82a 100644 --- a/Streetcode/Streetcode.DAL/Entities/Streetcode/StreetcodeContent.cs +++ b/Streetcode/Streetcode.DAL/Entities/Streetcode/StreetcodeContent.cs @@ -32,7 +32,7 @@ public class StreetcodeContent public string? Teaser { get; set; } [Required] - [MaxLength(100)] + [MaxLength(50)] public string? DateString { get; set; } [MaxLength(50)] diff --git a/Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.Designer.cs b/Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.Designer.cs deleted file mode 100644 index 7cfdfffaa..000000000 --- a/Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.Designer.cs +++ /dev/null @@ -1,1595 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Streetcode.DAL.Persistence; - -#nullable disable - -namespace Streetcode.DAL.Persistence.Migrations -{ - [DbContext(typeof(StreetcodeDbContext))] - [Migration("20231130202258_DatestringLength")] - partial class DatestringLength - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .UseCollation("SQL_Ukrainian_CP1251_CI_AS") - .HasAnnotation("ProductVersion", "6.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Coordinate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("CoordinateType") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Latitude") - .HasColumnType("decimal(18,4)"); - - b.Property("Longtitude") - .HasColumnType("decimal(18,4)"); - - b.HasKey("Id"); - - b.ToTable("coordinates", "add_content"); - - b.HasDiscriminator("CoordinateType").HasValue("coordinate_base"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.StreetcodeTagIndex", b => - { - b.Property("StreetcodeId") - .HasColumnType("int"); - - b.Property("TagId") - .HasColumnType("int"); - - b.Property("Index") - .HasColumnType("int"); - - b.Property("IsVisible") - .HasColumnType("bit"); - - b.HasKey("StreetcodeId", "TagId"); - - b.HasIndex("TagId"); - - b.ToTable("streetcode_tag_index", "add_content"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Subtitle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("StreetcodeId") - .HasColumnType("int"); - - b.Property("SubtitleText") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.HasKey("Id"); - - b.HasIndex("StreetcodeId"); - - b.ToTable("subtitles", "add_content"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Tag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Title") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("tags", "add_content"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Analytics.StatisticRecord", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Address") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("QrId") - .HasColumnType("int"); - - b.Property("StreetcodeCoordinateId") - .HasColumnType("int"); - - b.Property("StreetcodeId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("StreetcodeCoordinateId") - .IsUnique(); - - b.HasIndex("StreetcodeId"); - - b.ToTable("qr_coordinates", "coordinates"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Feedback.Response", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Description") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Name") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("responses", "feedback"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Jobs.Job", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Description") - .IsRequired() - .HasMaxLength(2000) - .HasColumnType("nvarchar(2000)"); - - b.Property("Salary") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("Status") - .HasColumnType("bit"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(65) - .HasColumnType("nvarchar(65)"); - - b.HasKey("Id"); - - b.ToTable("job", "jobs"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Media.Audio", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("BlobName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("MimeType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b.Property("Title") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("audios", "media"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.Art", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Description") - .HasMaxLength(400) - .HasColumnType("nvarchar(400)"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Title") - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.HasKey("Id"); - - b.HasIndex("ImageId") - .IsUnique(); - - b.ToTable("arts", "media"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("BlobName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("MimeType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b.HasKey("Id"); - - b.ToTable("images", "media"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.ImageDetails", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Alt") - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Title") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.HasIndex("ImageId") - .IsUnique(); - - b.ToTable("image_details", "media"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.StreetcodeImage", b => - { - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("StreetcodeId") - .HasColumnType("int"); - - b.HasKey("ImageId", "StreetcodeId"); - - b.HasIndex("StreetcodeId"); - - b.ToTable("streetcode_image", "streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Media.Video", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Description") - .HasColumnType("nvarchar(max)"); - - b.Property("StreetcodeId") - .HasColumnType("int"); - - b.Property("Title") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Url") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("StreetcodeId"); - - b.ToTable("videos", "media"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.News.News", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("CreationDate") - .HasColumnType("datetime2"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Text") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.Property("URL") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.HasIndex("ImageId") - .IsUnique() - .HasFilter("[ImageId] IS NOT NULL"); - - b.HasIndex("URL") - .IsUnique(); - - b.ToTable("news", "news"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Partners.Partner", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Description") - .HasMaxLength(600) - .HasColumnType("nvarchar(600)"); - - b.Property("IsKeyPartner") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(false); - - b.Property("IsVisibleEverywhere") - .HasColumnType("bit"); - - b.Property("LogoId") - .HasColumnType("int"); - - b.Property("TargetUrl") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UrlTitle") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("LogoId") - .IsUnique(); - - b.ToTable("partners", "partners"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Partners.PartnerSourceLink", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("LogoType") - .HasColumnType("tinyint"); - - b.Property("PartnerId") - .HasColumnType("int"); - - b.Property("TargetUrl") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("PartnerId"); - - b.ToTable("partner_source_links", "partners"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Partners.StreetcodePartner", b => - { - b.Property("PartnerId") - .HasColumnType("int"); - - b.Property("StreetcodeId") - .HasColumnType("int"); - - b.HasKey("PartnerId", "StreetcodeId"); - - b.HasIndex("StreetcodeId"); - - b.ToTable("streetcode_partners", "streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Sources.SourceLinkCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.ToTable("source_link_categories", "sources"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Sources.StreetcodeCategoryContent", b => - { - b.Property("SourceLinkCategoryId") - .HasColumnType("int"); - - b.Property("StreetcodeId") - .HasColumnType("int"); - - b.Property("Text") - .IsRequired() - .HasMaxLength(10000) - .HasColumnType("nvarchar(max)"); - - b.HasKey("SourceLinkCategoryId", "StreetcodeId"); - - b.HasIndex("StreetcodeId"); - - b.ToTable("streetcode_source_link_categories", "sources"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.RelatedFigure", b => - { - b.Property("ObserverId") - .HasColumnType("int"); - - b.Property("TargetId") - .HasColumnType("int"); - - b.HasKey("ObserverId", "TargetId"); - - b.HasIndex("TargetId"); - - b.ToTable("related_figures", "streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.StreetcodeArt", b => - { - b.Property("ArtId") - .HasColumnType("int"); - - b.Property("StreetcodeId") - .HasColumnType("int"); - - b.Property("Index") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(1); - - b.HasKey("ArtId", "StreetcodeId"); - - b.HasIndex("StreetcodeId"); - - b.HasIndex("ArtId", "StreetcodeId"); - - b.ToTable("streetcode_art", "streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Alias") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("AudioId") - .HasColumnType("int"); - - b.Property("CreatedAt") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2") - .HasDefaultValueSql("GETDATE()"); - - b.Property("DateString") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("EventEndOrPersonDeathDate") - .HasColumnType("datetime2"); - - b.Property("EventStartOrPersonBirthDate") - .HasColumnType("datetime2"); - - b.Property("Index") - .HasColumnType("int"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("StreetcodeType") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Teaser") - .HasMaxLength(650) - .HasColumnType("nvarchar(650)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("TransliterationUrl") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.Property("UpdatedAt") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2") - .HasDefaultValueSql("GETDATE()"); - - b.Property("ViewCount") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("AudioId") - .IsUnique() - .HasFilter("[AudioId] IS NOT NULL"); - - b.HasIndex("Index") - .IsUnique(); - - b.HasIndex("TransliterationUrl") - .IsUnique(); - - b.ToTable("streetcodes", "streetcode"); - - b.HasDiscriminator("StreetcodeType").HasValue("streetcode-base"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.Fact", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("FactContent") - .IsRequired() - .HasMaxLength(600) - .HasColumnType("nvarchar(600)"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("StreetcodeId") - .HasColumnType("int"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.HasIndex("StreetcodeId"); - - b.ToTable("facts", "streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.RelatedTerm", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("TermId") - .HasColumnType("int"); - - b.Property("Word") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("TermId"); - - b.ToTable("related_terms", "streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.Term", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Description") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("terms", "streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.Text", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("AdditionalText") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("StreetcodeId") - .HasColumnType("int"); - - b.Property("TextContent") - .IsRequired() - .HasMaxLength(15000) - .HasColumnType("nvarchar(max)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.HasKey("Id"); - - b.HasIndex("StreetcodeId") - .IsUnique(); - - b.ToTable("texts", "streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Team.Positions", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Position") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("positions", "team"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Team.TeamMember", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Description") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("IsMain") - .HasColumnType("bit"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("ImageId") - .IsUnique(); - - b.ToTable("team_members", "team"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Team.TeamMemberLink", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("LogoType") - .HasColumnType("tinyint"); - - b.Property("TargetUrl") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("TeamMemberId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("TeamMemberId"); - - b.ToTable("team_member_links", "team"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Team.TeamMemberPositions", b => - { - b.Property("TeamMemberId") - .HasColumnType("int"); - - b.Property("PositionsId") - .HasColumnType("int"); - - b.HasKey("TeamMemberId", "PositionsId"); - - b.HasIndex("PositionsId"); - - b.ToTable("team_member_positions", "team"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Timeline.HistoricalContext", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Title") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("historical_contexts", "timeline"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Timeline.HistoricalContextTimeline", b => - { - b.Property("TimelineId") - .HasColumnType("int"); - - b.Property("HistoricalContextId") - .HasColumnType("int"); - - b.HasKey("TimelineId", "HistoricalContextId"); - - b.HasIndex("HistoricalContextId"); - - b.ToTable("HistoricalContextsTimelines"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Timeline.TimelineItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Date") - .HasColumnType("datetime2"); - - b.Property("DateViewPattern") - .HasColumnType("int"); - - b.Property("Description") - .HasMaxLength(600) - .HasColumnType("nvarchar(600)"); - - b.Property("StreetcodeId") - .HasColumnType("int"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.HasIndex("StreetcodeId"); - - b.ToTable("timeline_items", "timeline"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Toponyms.StreetcodeToponym", b => - { - b.Property("StreetcodeId") - .HasColumnType("int"); - - b.Property("ToponymId") - .HasColumnType("int"); - - b.HasKey("StreetcodeId", "ToponymId"); - - b.HasIndex("ToponymId"); - - b.ToTable("streetcode_toponym", "streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Toponyms.Toponym", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("AdminRegionNew") - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.Property("AdminRegionOld") - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.Property("Community") - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.Property("Gromada") - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.Property("Oblast") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("StreetName") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.Property("StreetType") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("toponyms", "toponyms"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Transactions.TransactionLink", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("StreetcodeId") - .HasColumnType("int"); - - b.Property("Url") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UrlTitle") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("StreetcodeId") - .IsUnique(); - - b.ToTable("transaction_links", "transactions"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Users.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Login") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Password") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("Role") - .HasColumnType("int"); - - b.Property("Surname") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("Users", "Users"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types.StreetcodeCoordinate", b => - { - b.HasBaseType("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Coordinate"); - - b.Property("StreetcodeId") - .HasColumnType("int"); - - b.HasIndex("StreetcodeId"); - - b.ToTable("coordinates", "add_content"); - - b.HasDiscriminator().HasValue("coordinate_streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types.ToponymCoordinate", b => - { - b.HasBaseType("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Coordinate"); - - b.Property("ToponymId") - .HasColumnType("int"); - - b.HasIndex("ToponymId") - .IsUnique() - .HasFilter("[ToponymId] IS NOT NULL"); - - b.ToTable("coordinates", "add_content"); - - b.HasDiscriminator().HasValue("coordinate_toponym"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.Types.EventStreetcode", b => - { - b.HasBaseType("Streetcode.DAL.Entities.Streetcode.StreetcodeContent"); - - b.ToTable("streetcodes", "streetcode"); - - b.HasDiscriminator().HasValue("streetcode-event"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.Types.PersonStreetcode", b => - { - b.HasBaseType("Streetcode.DAL.Entities.Streetcode.StreetcodeContent"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Rank") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.ToTable("streetcodes", "streetcode"); - - b.HasDiscriminator().HasValue("streetcode-person"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.StreetcodeTagIndex", b => - { - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") - .WithMany("StreetcodeTagIndices") - .HasForeignKey("StreetcodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Streetcode.DAL.Entities.AdditionalContent.Tag", "Tag") - .WithMany("StreetcodeTagIndices") - .HasForeignKey("TagId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Streetcode"); - - b.Navigation("Tag"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Subtitle", b => - { - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") - .WithMany("Subtitles") - .HasForeignKey("StreetcodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Analytics.StatisticRecord", b => - { - b.HasOne("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types.StreetcodeCoordinate", "StreetcodeCoordinate") - .WithOne("StatisticRecord") - .HasForeignKey("Streetcode.DAL.Entities.Analytics.StatisticRecord", "StreetcodeCoordinateId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") - .WithMany("StatisticRecords") - .HasForeignKey("StreetcodeId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.Navigation("Streetcode"); - - b.Navigation("StreetcodeCoordinate"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.Art", b => - { - b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Image") - .WithOne("Art") - .HasForeignKey("Streetcode.DAL.Entities.Media.Images.Art", "ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.ImageDetails", b => - { - b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Image") - .WithOne("ImageDetails") - .HasForeignKey("Streetcode.DAL.Entities.Media.Images.ImageDetails", "ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.StreetcodeImage", b => - { - b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Image") - .WithMany() - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") - .WithMany() - .HasForeignKey("StreetcodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Image"); - - b.Navigation("Streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Media.Video", b => - { - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") - .WithMany("Videos") - .HasForeignKey("StreetcodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.News.News", b => - { - b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Image") - .WithOne("News") - .HasForeignKey("Streetcode.DAL.Entities.News.News", "ImageId"); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Partners.Partner", b => - { - b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Logo") - .WithOne("Partner") - .HasForeignKey("Streetcode.DAL.Entities.Partners.Partner", "LogoId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Logo"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Partners.PartnerSourceLink", b => - { - b.HasOne("Streetcode.DAL.Entities.Partners.Partner", "Partner") - .WithMany("PartnerSourceLinks") - .HasForeignKey("PartnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Partner"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Partners.StreetcodePartner", b => - { - b.HasOne("Streetcode.DAL.Entities.Partners.Partner", "Partner") - .WithMany() - .HasForeignKey("PartnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") - .WithMany() - .HasForeignKey("StreetcodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Partner"); - - b.Navigation("Streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Sources.SourceLinkCategory", b => - { - b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Image") - .WithMany("SourceLinkCategories") - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Sources.StreetcodeCategoryContent", b => - { - b.HasOne("Streetcode.DAL.Entities.Sources.SourceLinkCategory", "SourceLinkCategory") - .WithMany("StreetcodeCategoryContents") - .HasForeignKey("SourceLinkCategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") - .WithMany("StreetcodeCategoryContents") - .HasForeignKey("StreetcodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("SourceLinkCategory"); - - b.Navigation("Streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.RelatedFigure", b => - { - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Observer") - .WithMany("Observers") - .HasForeignKey("ObserverId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Target") - .WithMany("Targets") - .HasForeignKey("TargetId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Observer"); - - b.Navigation("Target"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.StreetcodeArt", b => - { - b.HasOne("Streetcode.DAL.Entities.Media.Images.Art", "Art") - .WithMany("StreetcodeArts") - .HasForeignKey("ArtId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") - .WithMany("StreetcodeArts") - .HasForeignKey("StreetcodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Art"); - - b.Navigation("Streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", b => - { - b.HasOne("Streetcode.DAL.Entities.Media.Audio", "Audio") - .WithOne("Streetcode") - .HasForeignKey("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "AudioId") - .OnDelete(DeleteBehavior.Cascade); - - b.Navigation("Audio"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.Fact", b => - { - b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Image") - .WithMany("Facts") - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") - .WithMany("Facts") - .HasForeignKey("StreetcodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Image"); - - b.Navigation("Streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.RelatedTerm", b => - { - b.HasOne("Streetcode.DAL.Entities.Streetcode.TextContent.Term", "Term") - .WithMany("RelatedTerms") - .HasForeignKey("TermId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Term"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.Text", b => - { - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") - .WithOne("Text") - .HasForeignKey("Streetcode.DAL.Entities.Streetcode.TextContent.Text", "StreetcodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Team.TeamMember", b => - { - b.HasOne("Streetcode.DAL.Entities.Media.Images.Image", "Image") - .WithOne("TeamMember") - .HasForeignKey("Streetcode.DAL.Entities.Team.TeamMember", "ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Team.TeamMemberLink", b => - { - b.HasOne("Streetcode.DAL.Entities.Team.TeamMember", "TeamMember") - .WithMany("TeamMemberLinks") - .HasForeignKey("TeamMemberId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("TeamMember"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Team.TeamMemberPositions", b => - { - b.HasOne("Streetcode.DAL.Entities.Team.Positions", "Positions") - .WithMany() - .HasForeignKey("PositionsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Streetcode.DAL.Entities.Team.TeamMember", "TeamMember") - .WithMany() - .HasForeignKey("TeamMemberId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Positions"); - - b.Navigation("TeamMember"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Timeline.HistoricalContextTimeline", b => - { - b.HasOne("Streetcode.DAL.Entities.Timeline.HistoricalContext", "HistoricalContext") - .WithMany("HistoricalContextTimelines") - .HasForeignKey("HistoricalContextId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Streetcode.DAL.Entities.Timeline.TimelineItem", "Timeline") - .WithMany("HistoricalContextTimelines") - .HasForeignKey("TimelineId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("HistoricalContext"); - - b.Navigation("Timeline"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Timeline.TimelineItem", b => - { - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") - .WithMany("TimelineItems") - .HasForeignKey("StreetcodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Toponyms.StreetcodeToponym", b => - { - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") - .WithMany() - .HasForeignKey("StreetcodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Streetcode.DAL.Entities.Toponyms.Toponym", "Toponym") - .WithMany() - .HasForeignKey("ToponymId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Streetcode"); - - b.Navigation("Toponym"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Transactions.TransactionLink", b => - { - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") - .WithOne("TransactionLink") - .HasForeignKey("Streetcode.DAL.Entities.Transactions.TransactionLink", "StreetcodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types.StreetcodeCoordinate", b => - { - b.HasOne("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", "Streetcode") - .WithMany("Coordinates") - .HasForeignKey("StreetcodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types.ToponymCoordinate", b => - { - b.HasOne("Streetcode.DAL.Entities.Toponyms.Toponym", "Toponym") - .WithOne("Coordinate") - .HasForeignKey("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types.ToponymCoordinate", "ToponymId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Toponym"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Tag", b => - { - b.Navigation("StreetcodeTagIndices"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Media.Audio", b => - { - b.Navigation("Streetcode"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.Art", b => - { - b.Navigation("StreetcodeArts"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Media.Images.Image", b => - { - b.Navigation("Art"); - - b.Navigation("Facts"); - - b.Navigation("ImageDetails"); - - b.Navigation("News"); - - b.Navigation("Partner"); - - b.Navigation("SourceLinkCategories"); - - b.Navigation("TeamMember"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Partners.Partner", b => - { - b.Navigation("PartnerSourceLinks"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Sources.SourceLinkCategory", b => - { - b.Navigation("StreetcodeCategoryContents"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.StreetcodeContent", b => - { - b.Navigation("Coordinates"); - - b.Navigation("Facts"); - - b.Navigation("Observers"); - - b.Navigation("StatisticRecords"); - - b.Navigation("StreetcodeArts"); - - b.Navigation("StreetcodeCategoryContents"); - - b.Navigation("StreetcodeTagIndices"); - - b.Navigation("Subtitles"); - - b.Navigation("Targets"); - - b.Navigation("Text"); - - b.Navigation("TimelineItems"); - - b.Navigation("TransactionLink"); - - b.Navigation("Videos"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Streetcode.TextContent.Term", b => - { - b.Navigation("RelatedTerms"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Team.TeamMember", b => - { - b.Navigation("TeamMemberLinks"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Timeline.HistoricalContext", b => - { - b.Navigation("HistoricalContextTimelines"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Timeline.TimelineItem", b => - { - b.Navigation("HistoricalContextTimelines"); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.Toponyms.Toponym", b => - { - b.Navigation("Coordinate") - .IsRequired(); - }); - - modelBuilder.Entity("Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types.StreetcodeCoordinate", b => - { - b.Navigation("StatisticRecord") - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.cs b/Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.cs deleted file mode 100644 index 707b37cba..000000000 --- a/Streetcode/Streetcode.DAL/Persistence/Migrations/20231130202258_DatestringLength.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Streetcode.DAL.Persistence.Migrations -{ - public partial class DatestringLength : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "DateString", - schema: "streetcode", - table: "streetcodes", - type: "nvarchar(100)", - maxLength: 100, - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(50)", - oldMaxLength: 50); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "DateString", - schema: "streetcode", - table: "streetcodes", - type: "nvarchar(50)", - maxLength: 50, - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(100)", - oldMaxLength: 100); - } - } -} diff --git a/Streetcode/Streetcode.DAL/Persistence/Migrations/StreetcodeDbContextModelSnapshot.cs b/Streetcode/Streetcode.DAL/Persistence/Migrations/StreetcodeDbContextModelSnapshot.cs index ffda3f915..d8703c870 100644 --- a/Streetcode/Streetcode.DAL/Persistence/Migrations/StreetcodeDbContextModelSnapshot.cs +++ b/Streetcode/Streetcode.DAL/Persistence/Migrations/StreetcodeDbContextModelSnapshot.cs @@ -576,8 +576,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateString") .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); b.Property("EventEndOrPersonDeathDate") .HasColumnType("datetime2"); diff --git a/Streetcode/Streetcode.WebApi/Controllers/Streetcode/StreetcodeController.cs b/Streetcode/Streetcode.WebApi/Controllers/Streetcode/StreetcodeController.cs index 6cf02d06a..6205d3d7a 100644 --- a/Streetcode/Streetcode.WebApi/Controllers/Streetcode/StreetcodeController.cs +++ b/Streetcode/Streetcode.WebApi/Controllers/Streetcode/StreetcodeController.cs @@ -90,9 +90,9 @@ public async Task GetAllCatalog([FromQuery] int page, [FromQuery] } [HttpGet] - public async Task GetCount([FromQuery] bool? onlyPublished) + public async Task GetCount() { - return HandleResult(await Mediator.Send(new GetStreetcodesCountQuery(onlyPublished ?? false))); + return HandleResult(await Mediator.Send(new GetStreetcodesCountQuery())); } [HttpGet("{url}")] diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/CoordinateControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/CoordinateControllerTests.cs index 5986c9ae5..5f74ab6c9 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/CoordinateControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/CoordinateControllerTests.cs @@ -1,10 +1,10 @@ -using Streetcode.BLL.DTO.AdditionalContent.Coordinates.Types; -using Streetcode.XIntegrationTest.ControllerTests.Utils; -using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; -using Xunit; - -namespace Streetcode.XIntegrationTest.ControllerTests.AdditionalContent +namespace Streetcode.XIntegrationTest.ControllerTests.AdditionalContent { + using Streetcode.BLL.DTO.AdditionalContent.Coordinates.Types; + using Streetcode.XIntegrationTest.ControllerTests.Utils; + using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; + using Xunit; + public class CoordinateControllerTests : BaseControllerTests, IClassFixture> { public CoordinateControllerTests(CustomWebApplicationFactory factory) diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs index ef20a8664..e28dfa36b 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/AdditionalContent/TagControllerTests.cs @@ -1,13 +1,14 @@ -using global::Streetcode.XIntegrationTest.ControllerTests.Utils; -using Streetcode.BLL.DTO.AdditionalContent; -using Streetcode.BLL.DTO.AdditionalContent.Tag; -using Streetcode.DAL.Entities.AdditionalContent; -using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Tag; -using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; -using Xunit; - -namespace Streetcode.XIntegrationTest.ControllerTests.AdditionalContent +namespace Streetcode.XIntegrationTest.ControllerTests.AdditionalContent { + using Streetcode.BLL.DTO.AdditionalContent; + using Streetcode.BLL.DTO.AdditionalContent.Tag; + using Streetcode.DAL.Entities.AdditionalContent; + using Streetcode.DAL.Entities.Streetcode.TextContent; + using Streetcode.XIntegrationTest.ControllerTests.Utils; + using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Tag; + using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; + using Xunit; + public class TagControllerTests : BaseControllerTests, IClassFixture> { public TagControllerTests(CustomWebApplicationFactory factory) diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/BaseControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/BaseControllerTests.cs index 7767b53ee..b645ddd5a 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/BaseControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/BaseControllerTests.cs @@ -1,11 +1,10 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Streetcode.DAL.Persistence; -using Streetcode.XIntegrationTest.ControllerTests.Utils; -using Xunit; - -namespace Streetcode.XIntegrationTest.ControllerTests +namespace Streetcode.XIntegrationTest.ControllerTests { + using Microsoft.EntityFrameworkCore; + using Microsoft.Extensions.Configuration; + using Streetcode.DAL.Persistence; + using Streetcode.XIntegrationTest.ControllerTests.Utils; + using Xunit; public class BaseControllerTests : IntegrationTestBase, IClassFixture> { diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/AudioControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/AudioControllerTests.cs index f19749633..5fc97daec 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/AudioControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/AudioControllerTests.cs @@ -2,6 +2,7 @@ using Streetcode.DAL.Entities.Media; using Streetcode.XIntegrationTest.ControllerTests.Utils; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Audio; +using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; using Xunit; namespace Streetcode.XIntegrationTest.ControllerTests.Media diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/StreetcodeArtControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/StreetcodeArtControllerTests.cs index 62a906f18..64a0cf559 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/StreetcodeArtControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/Images/StreetcodeArtControllerTests.cs @@ -1,9 +1,9 @@ -using Streetcode.BLL.DTO.Media.Art; -using Streetcode.XIntegrationTest.ControllerTests.Utils; -using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; -using Xunit; -namespace Streetcode.XIntegrationTest.ControllerTests.Media.Images +namespace Streetcode.XIntegrationTest.ControllerTests.Media.Images { + using Streetcode.BLL.DTO.Media.Art; + using Streetcode.XIntegrationTest.ControllerTests.Utils; + using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; + using Xunit; public class StreetcodeArtControllerTests : BaseControllerTests, IClassFixture> { diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/VideoControllerTests.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/VideoControllerTests.cs index 6825ea683..a59cd3865 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/VideoControllerTests.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Media/VideoControllerTests.cs @@ -1,8 +1,9 @@ -using Streetcode.BLL.DTO.Media; -using Streetcode.XIntegrationTest.ControllerTests.Utils; -using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Video; -namespace Streetcode.XIntegrationTest.ControllerTests.Media +namespace Streetcode.XIntegrationTest.ControllerTests.Media { + using Streetcode.BLL.DTO.Media; + using Streetcode.BLL.DTO.Media.Audio; + using Streetcode.XIntegrationTest.ControllerTests.Utils; + using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Video; using Xunit; public class VideoControllerTests : BaseControllerTests, IClassFixture> diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestStreetcodeCoordinate.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestStreetcodeCoordinate.cs index c8aa5b104..cb0bc5c9d 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestStreetcodeCoordinate.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestStreetcodeCoordinate.cs @@ -19,14 +19,14 @@ public override void Before(MethodInfo methodUnderTest) { StreetcodeContent first = sqlDbHelper.GetExistItem(); first ??= sqlDbHelper.AddNewItem(new StreetcodeContent() - { - Index = 10, - UpdatedAt = DateTime.Now, - CreatedAt = DateTime.Now, - EventStartOrPersonBirthDate = DateTime.Now, - EventEndOrPersonDeathDate = DateTime.Now, - ViewCount = 1, - }); + { + Index = 10, + UpdatedAt = DateTime.Now, + CreatedAt = DateTime.Now, + EventStartOrPersonBirthDate = DateTime.Now, + EventEndOrPersonDeathDate = DateTime.Now, + ViewCount = 1, + }); CoordinateForTest = sqlDbHelper.AddNewItem( new StreetcodeCoordinate() diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestToponymCoordinate.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestToponymCoordinate.cs index 9884bc733..eb8a45891 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestToponymCoordinate.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Coordinate/ExtractTestToponymCoordinate.cs @@ -1,12 +1,17 @@ using Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types; using Streetcode.DAL.Entities.Toponyms; +using System; +using System.Collections.Generic; +using System.Linq; using System.Reflection; +using System.Text; +using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Coordinate { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestToponymCoordinate : BeforeAfterTestAttribute + internal class ExtractTestToponymCoordinate:BeforeAfterTestAttribute { public static ToponymCoordinate ToponymCoordinateForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Subtitle/ExtractTestSubtitle.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Subtitle/ExtractTestSubtitle.cs index 6758057bc..7c577860c 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Subtitle/ExtractTestSubtitle.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Subtitle/ExtractTestSubtitle.cs @@ -1,6 +1,15 @@ -using Streetcode.DAL.Entities.Streetcode; -using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; +using System; +using System.Collections.Generic; +using System.Linq; using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Streetcode.DAL.Entities; +using Streetcode.DAL.Entities.Streetcode; +using Streetcode.DAL.Persistence; +using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Subtitle diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/ExtractTestTag.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/ExtractTestTag.cs index 25bd4db21..33d3b63b2 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/ExtractTestTag.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/ExtractTestTag.cs @@ -1,10 +1,11 @@ -using System.Reflection; +using Streetcode.DAL.Entities.AdditionalContent; +using System.Reflection; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Tag { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - public class ExtractTestTag : BeforeAfterTestAttribute + public class ExtractTestTag: BeforeAfterTestAttribute { public static DAL.Entities.AdditionalContent.Tag TagForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/StreetcodeTagIndexSetup.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/StreetcodeTagIndexSetup.cs index 2dbc8ef87..41f223b91 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/StreetcodeTagIndexSetup.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/AdditionalContent/Tag/StreetcodeTagIndexSetup.cs @@ -1,5 +1,10 @@ using Streetcode.DAL.Entities.AdditionalContent; using Streetcode.DAL.Entities.Streetcode; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Tag { diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Art/ExtractTestArt.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Art/ExtractTestArt.cs index 10e339d5f..56f738846 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Art/ExtractTestArt.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Art/ExtractTestArt.cs @@ -6,7 +6,7 @@ namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Images.Art { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestArt : BeforeAfterTestAttribute + internal class ExtractTestArt: BeforeAfterTestAttribute { public static DAL.Entities.Media.Images.Art ArtForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Image/ExtractTestImage.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Image/ExtractTestImage.cs index adbe0c84e..0b595a58c 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Image/ExtractTestImage.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/Image/ExtractTestImage.cs @@ -7,7 +7,7 @@ namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Images.Image { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - public class ExtractTestImage : BeforeAfterTestAttribute + public class ExtractTestImage: BeforeAfterTestAttribute { public static DAL.Entities.Media.Images.Image ImageForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/StreetcodeArt/ExtractTestStreetcodeArt.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/StreetcodeArt/ExtractTestStreetcodeArt.cs index 0486e2f8f..06cb3fd95 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/StreetcodeArt/ExtractTestStreetcodeArt.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Images/StreetcodeArt/ExtractTestStreetcodeArt.cs @@ -6,7 +6,7 @@ namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Images.StreetcodeArt { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestStreetcodeArt : BeforeAfterTestAttribute + internal class ExtractTestStreetcodeArt:BeforeAfterTestAttribute { public static DAL.Entities.Streetcode.StreetcodeArt StreetcodeArtForTest; @@ -14,7 +14,7 @@ public override void Before(MethodInfo methodUnderTest) { var sqlDbHelper = BaseControllerTests.GetSqlDbHelper(); StreetcodeArtForTest = sqlDbHelper.GetExistItem(); - if (StreetcodeArtForTest == null) + if(StreetcodeArtForTest == null) { if (ExtractTestStreetcode.StreetcodeForTest == null) { diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Video/ExtractTestVideo.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Video/ExtractTestVideo.cs index 0cbbb38f8..002b457e3 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Video/ExtractTestVideo.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Media/Video/ExtractTestVideo.cs @@ -6,7 +6,7 @@ namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Video { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestVideo : BeforeAfterTestAttribute + internal class ExtractTestVideo: BeforeAfterTestAttribute { public static DAL.Entities.Media.Video VideoForTest; public static StreetcodeContent StreetcodeWithVideo; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Partners/ExtractTestPartners.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Partners/ExtractTestPartners.cs index ed7ccf3c3..dd9db72e2 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Partners/ExtractTestPartners.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Partners/ExtractTestPartners.cs @@ -1,12 +1,17 @@ using Streetcode.DAL.Entities.Partners; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Images.Image; +using System; +using System.Collections.Generic; +using System.Linq; using System.Reflection; +using System.Text; +using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Partners { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestPartners : BeforeAfterTestAttribute + internal class ExtractTestPartners: BeforeAfterTestAttribute { public static Partner PartnerForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Source/SourceLinkCategories/ExtractTestSourceLinkCategory.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Source/SourceLinkCategories/ExtractTestSourceLinkCategory.cs index 380f3ce65..c96d6330c 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Source/SourceLinkCategories/ExtractTestSourceLinkCategory.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Source/SourceLinkCategories/ExtractTestSourceLinkCategory.cs @@ -1,12 +1,18 @@ -using Streetcode.DAL.Entities.Sources; +using Streetcode.DAL.Entities.Partners; +using Streetcode.DAL.Entities.Sources; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Images.Image; +using System; +using System.Collections.Generic; +using System.Linq; using System.Reflection; +using System.Text; +using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Source.SourceLinkCategories { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestSourceLinkCategory : BeforeAfterTestAttribute + internal class ExtractTestSourceLinkCategory:BeforeAfterTestAttribute { public static SourceLinkCategory SourceLinkCategoryForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs index c4f325642..4d7546b39 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/ExtractTestStreetcode.cs @@ -1,4 +1,5 @@ -using Streetcode.DAL.Entities.Streetcode; +using Streetcode.DAL.Entities.AdditionalContent; +using Streetcode.DAL.Entities.Streetcode; using System.Reflection; using Xunit.Sdk; @@ -27,30 +28,9 @@ public override void Before(MethodInfo methodUnderTest) Alias = "dsf", Title = "Title", TransliterationUrl = Guid.NewGuid().ToString(), - Teaser = "Test Teaser", }); sqlDbHelper.SaveChanges(); } } - - public override void After(MethodInfo methodUnderTest) - { - var sqlDbHelper = BaseControllerTests.GetSqlDbHelper(); - var streetcodeContent = sqlDbHelper.GetExistItem(); - if (streetcodeContent != null) - { - // Restore the original StreetcodeContent - streetcodeContent.EventStartOrPersonBirthDate = StreetcodeForTest.EventStartOrPersonBirthDate; - streetcodeContent.EventEndOrPersonDeathDate = StreetcodeForTest.EventEndOrPersonDeathDate; - streetcodeContent.ViewCount = StreetcodeForTest.ViewCount; - streetcodeContent.DateString = StreetcodeForTest.DateString; - streetcodeContent.Alias = StreetcodeForTest.Alias; - streetcodeContent.Title = StreetcodeForTest.Title; - streetcodeContent.TransliterationUrl = StreetcodeForTest.TransliterationUrl; - streetcodeContent.Teaser = StreetcodeForTest.Teaser; - - sqlDbHelper.SaveChanges(); - } - } } } diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/RelatedFigure/ExtractTestRelatedFigure.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/RelatedFigure/ExtractTestRelatedFigure.cs index ea31620d7..84d896e4d 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/RelatedFigure/ExtractTestRelatedFigure.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/RelatedFigure/ExtractTestRelatedFigure.cs @@ -1,11 +1,16 @@ using Streetcode.DAL.Entities.Streetcode; +using System; +using System.Collections.Generic; +using System.Linq; using System.Reflection; +using System.Text; +using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode.RelatedFigure { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestRelatedFigure : BeforeAfterTestAttribute + internal class ExtractTestRelatedFigure: BeforeAfterTestAttribute { public static DAL.Entities.Streetcode.RelatedFigure RelatedFigureForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Facts/ExtractTestFact.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Facts/ExtractTestFact.cs index aa52d8f21..b0ef66ce9 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Facts/ExtractTestFact.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Facts/ExtractTestFact.cs @@ -1,11 +1,16 @@ using Streetcode.DAL.Entities.Streetcode.TextContent; +using System; +using System.Collections.Generic; +using System.Linq; using System.Reflection; +using System.Text; +using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode.TextContent.Facts { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - public class ExtractTestFact : BeforeAfterTestAttribute + public class ExtractTestFact: BeforeAfterTestAttribute { public static Fact FactForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Terms/ExstractTestTerm.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Terms/ExstractTestTerm.cs index bd28a9c2d..cc745822f 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Terms/ExstractTestTerm.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Terms/ExstractTestTerm.cs @@ -1,11 +1,17 @@ using Streetcode.DAL.Entities.Streetcode.TextContent; +using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode.TextContent.Facts; +using System; +using System.Collections.Generic; +using System.Linq; using System.Reflection; +using System.Text; +using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode.TextContent.Terms { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExstractTestTerm : BeforeAfterTestAttribute + internal class ExstractTestTerm: BeforeAfterTestAttribute { public static Term TermForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Texts/ExstractTestText.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Texts/ExstractTestText.cs index 42e2bb4e0..36135d839 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Texts/ExstractTestText.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Streetcode/TextContent/Texts/ExstractTestText.cs @@ -1,11 +1,16 @@ using Streetcode.DAL.Entities.Streetcode.TextContent; +using System; +using System.Collections.Generic; +using System.Linq; using System.Reflection; +using System.Text; +using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode.TextContent.Texts { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExstractTestText : BeforeAfterTestAttribute + internal class ExstractTestText :BeforeAfterTestAttribute { public static Text TextForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Timelines/ExtractTestTimelineItem.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Timelines/ExtractTestTimelineItem.cs index bed77d9a8..4ecaef22b 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Timelines/ExtractTestTimelineItem.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Timelines/ExtractTestTimelineItem.cs @@ -1,11 +1,16 @@ using Streetcode.DAL.Entities.Timeline; +using System; +using System.Collections.Generic; +using System.Linq; using System.Reflection; +using System.Text; +using System.Threading.Tasks; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Timelines { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestTimelineItem : BeforeAfterTestAttribute + internal class ExtractTestTimelineItem: BeforeAfterTestAttribute { public static TimelineItem TimelineItemForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Toponyms/ExtractTestToponym.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Toponyms/ExtractTestToponym.cs index 24d6628fe..97c55ff66 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Toponyms/ExtractTestToponym.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Toponyms/ExtractTestToponym.cs @@ -1,12 +1,15 @@ using Streetcode.DAL.Entities.Toponyms; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.AdditionalContent.Coordinate; +using System; +using System.Collections.Generic; +using System.Linq; using System.Reflection; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Toponyms { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal class ExtractTestToponym : BeforeAfterTestAttribute + internal class ExtractTestToponym:BeforeAfterTestAttribute { public static Toponym ToponymForTest; diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Transactions/ExtractTestTransactionLink.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Transactions/ExtractTestTransactionLink.cs index 6d509064c..3561a7ddd 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Transactions/ExtractTestTransactionLink.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/BeforeAndAfterTestAtribute/Transactions/ExtractTestTransactionLink.cs @@ -1,6 +1,13 @@ -using Streetcode.DAL.Entities.Transactions; +using Streetcode.DAL.Entities.AdditionalContent.Coordinates.Types; +using Streetcode.DAL.Entities.Transactions; using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Streetcode; +using System; +using System.Collections.Generic; +using System.Linq; using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Transactions; using Xunit.Sdk; namespace Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Transactions diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/CustomWebApplicationFactory.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/CustomWebApplicationFactory.cs index db47e2e8d..8e27ecf3f 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/CustomWebApplicationFactory.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/CustomWebApplicationFactory.cs @@ -1,8 +1,8 @@ namespace Streetcode.XIntegrationTest.ControllerTests.Utils { + using System; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; - using System; public class CustomWebApplicationFactory : WebApplicationFactory where TProgram : class diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/SqlDbHelper.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/SqlDbHelper.cs index 1aa65daf4..137d0b39e 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/SqlDbHelper.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/SqlDbHelper.cs @@ -83,12 +83,6 @@ public T DeleteItem(T item) return this.dbContext.Set().Remove(item).Entity; } - public void RemoveRange() - where T : class, new() - { - this.dbContext.Set().RemoveRange(this.dbContext.Set()); - this.dbContext.SaveChanges(); - } public void SaveChanges() => this.dbContext.SaveChanges(); } } diff --git a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs index 1be932316..97e3eee4c 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ControllerTests/Utils/StreetcodeClient.cs @@ -1,18 +1,18 @@ -using RestSharp; -using RestSharp.Serializers; -using Streetcode.BLL.DTO.Streetcode.Update; - -namespace Streetcode.XIntegrationTest.ControllerTests.Utils +namespace Streetcode.XIntegrationTest.ControllerTests.Utils { + using RestSharp; + using RestSharp.Serializers; + using System.Threading.Tasks; + public class StreetcodeClient { protected RestClient Client; public string SecondPartUrl { get; } - public StreetcodeClient(HttpClient client, string secondPartUrl = "") + public StreetcodeClient(HttpClient client, string secondPartUrl = "") { - this.Client = new RestClient(client) { AcceptedContentTypes = ContentType.JsonAccept }; + this.Client = new RestClient(client) { AcceptedContentTypes=ContentType.JsonAccept }; this.SecondPartUrl = secondPartUrl; } @@ -45,14 +45,5 @@ public async Task GetResponse(string requestString) return returns; } - public async Task UpdateAsync(StreetcodeUpdateDTO updateStreetcodeDTO) - { - var request = new RestRequest($"{this.SecondPartUrl}/Update", Method.Put); - request.AddJsonBody(updateStreetcodeDTO); - request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; }; - request.AddHeader("content-type", "application/json"); - var response = await this.Client.ExecuteAsync(request); - return response; - } } } diff --git a/Streetcode/Streetcode.XIntegrationTest/ServiceTests/BlobServiceTests/Utils/BlobStorageFixture.cs b/Streetcode/Streetcode.XIntegrationTest/ServiceTests/BlobServiceTests/Utils/BlobStorageFixture.cs index 911681aa8..07eb4bc2c 100644 --- a/Streetcode/Streetcode.XIntegrationTest/ServiceTests/BlobServiceTests/Utils/BlobStorageFixture.cs +++ b/Streetcode/Streetcode.XIntegrationTest/ServiceTests/BlobServiceTests/Utils/BlobStorageFixture.cs @@ -5,6 +5,8 @@ using Streetcode.DAL.Entities.Media; using Streetcode.DAL.Entities.Media.Images; using Streetcode.DAL.Persistence; +using Streetcode.DAL.Repositories.Realizations.Base; +using Streetcode.XIntegrationTest.Base; using System.Text; namespace Streetcode.XIntegrationTest.ServiceTests.BlobServiceTests.Utils @@ -27,8 +29,8 @@ public BlobStorageFixture() blobPath = environmentVariables.Value.BlobStorePath; blobKey = environmentVariables.Value.BlobStoreKey; - // TestDbContext = TestDBFixture.CreateContext(Configuration.GetConnectionString("DefaultConnection")); - // RepositoryWrapper repo = new RepositoryWrapper(TestDbContext); + // TestDbContext = TestDBFixture.CreateContext(Configuration.GetConnectionString("DefaultConnection")); + // RepositoryWrapper repo = new RepositoryWrapper(TestDbContext); blobService = new BlobService(environmentVariables); // add repo Directory.CreateDirectory(blobPath);