Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update master 22.01.2024 10 a.m #1089

Merged
merged 16 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public GetStreetcodeByFilterHandler(IRepositoryWrapper repositoryWrapper, ILogge
public async Task<Result<List<StreetcodeFilterResultDTO>>> Handle(GetStreetcodeByFilterQuery request, CancellationToken cancellationToken)
{
string searchQuery = request.Filter.SearchQuery;
searchQuery = searchQuery.Trim();

var results = new List<StreetcodeFilterResultDTO>();

Expand Down
Original file line number Diff line number Diff line change
@@ -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"

},
"Blob": {
"BlobStoreKey": "BigThirtyTwoBiteCoolTestKeyCrypt",
Expand Down
2 changes: 1 addition & 1 deletion Streetcode/Streetcode.WebApi/appsettings.Local.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"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"
},
"CORS": {
"AllowedOrigins": [ "http://localhost:3000" ],
Expand Down
2 changes: 1 addition & 1 deletion Streetcode/Streetcode.WebApi/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"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"
},
"EmailConfiguration": {
"From": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
@@ -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<CustomWebApplicationFactory<Program>>
{
public CoordinateControllerTests(CustomWebApplicationFactory<Program> factory)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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;

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<CustomWebApplicationFactory<Program>>
{
public TagControllerTests(CustomWebApplicationFactory<Program> factory)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace Streetcode.XIntegrationTest.ControllerTests
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<CustomWebApplicationFactory<Program>>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +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<CustomWebApplicationFactory<Program>>
{
public StreetcodeArtControllerTests(CustomWebApplicationFactory<Program> factory)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace Streetcode.XIntegrationTest.ControllerTests.Media
using Streetcode.BLL.DTO.Media;
using Streetcode.XIntegrationTest.ControllerTests.Utils;
using Streetcode.XIntegrationTest.ControllerTests.Utils.BeforeAndAfterTestAtribute.Media.Video;
using Xunit;
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<CustomWebApplicationFactory<Program>>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
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.Create
{
public class StreetcodeCreateControllerTests : BaseControllerTests, IClassFixture<CustomWebApplicationFactory<Program>>
{
public StreetcodeCreateControllerTests(CustomWebApplicationFactory<Program> factory)
: base(factory, "/api/Streetcode")
{

}

[Fact]
[ExtractCreateTestStreetcode]
public async Task Create_ReturnsSuccessStatusCode()
{
// Arrange
var streetcodeCreateDTO = ExtractCreateTestStreetcode.StreetcodeForTest;

// Act
var response = await client.CreateAsync(streetcodeCreateDTO);

// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}


[Fact]
[ExtractCreateTestStreetcode]
public async Task Create_CreatesNewStreetcode()
{
// Arrange
var streetcodeCreateDTO = ExtractCreateTestStreetcode.StreetcodeForTest;

// Act
var response = await client.CreateAsync(streetcodeCreateDTO);
var streetcodeId = StreetcodeIndexFetch.GetStreetcodeByIndex(streetcodeCreateDTO.Index);
var getResponse = await client.GetByIdAsync(streetcodeId);
var fetchedStreetcode = CaseIsensitiveJsonDeserializer.Deserialize<StreetcodeContent>(getResponse.Content);

// Assert
Assert.Equal(streetcodeCreateDTO.Title, fetchedStreetcode.Title);
Assert.Equal(streetcodeCreateDTO.TransliterationUrl, fetchedStreetcode.TransliterationUrl);
}

[Fact]
[ExtractCreateTestStreetcode]
public async Task Create_WithInvalidData_ReturnsBadRequest()
{
// Arrange
var streetcodeCreateDTO = ExtractCreateTestStreetcode.StreetcodeForTest;
streetcodeCreateDTO.Title = null; // Invalid data

// Act
var response = await client.CreateAsync(streetcodeCreateDTO);

// Assert
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
}

[Fact]
[ExtractTestStreetcode]
[ExtractCreateTestStreetcode]
public async Task Create_WithExistingStreetcode_ReturnsConflict()
{
// Arrange
var streetcodeCreateDTO = ExtractCreateTestStreetcode.StreetcodeForTest;
streetcodeCreateDTO.Index = ExtractTestStreetcode.StreetcodeForTest.Index;

// Act
var response = await client.CreateAsync(streetcodeCreateDTO);

// Assert
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
}

[Fact]
[ExtractCreateTestStreetcode]
public async Task Create_WithLongTransliterationUrl_ReturnsBadRequest()
{
// Arrange
var transliterationUrlMaxLength = 150;
var streetcodeCreateDTO = ExtractCreateTestStreetcode.StreetcodeForTest;
streetcodeCreateDTO.TransliterationUrl = new string('a', transliterationUrlMaxLength + 1);

// Act
var response = await client.CreateAsync(streetcodeCreateDTO);

// Assert
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public override void Before(MethodInfo methodUnderTest)
{
StreetcodeContent first = sqlDbHelper.GetExistItem<StreetcodeContent>();
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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
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;

public override void Before(MethodInfo methodUnderTest)
{
var sqlDbHelper = BaseControllerTests.GetSqlDbHelper();
StreetcodeArtForTest = sqlDbHelper.GetExistItem<DAL.Entities.Streetcode.StreetcodeArt>();
if(StreetcodeArtForTest == null)
if (StreetcodeArtForTest == null)
{
if (ExtractTestStreetcode.StreetcodeForTest == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Loading
Loading