diff --git a/.github/workflows/aspnetcore.yml b/.github/workflows/aspnetcore.yml index 57fceeeb5..6e5b25712 100644 --- a/.github/workflows/aspnetcore.yml +++ b/.github/workflows/aspnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + dotnet-version: 10.0.x - name: Install .NET Aspire workload run: dotnet workload install aspire - name: Restore diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 748f1b578..7e83529a6 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -19,9 +19,9 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - lfs: true # jeśli używasz Git LFS + lfs: true - - name: Setup .NET 9 SDK + - name: Setup .NET 10 SDK uses: actions/setup-dotnet@v3 with: - dotnet-version: '9.0.x' + dotnet-version: '10.0.x' diff --git a/.github/workflows/docker-image-pr.yml b/.github/workflows/docker-image-pr.yml index 73f0e0309..4556fe160 100644 --- a/.github/workflows/docker-image-pr.yml +++ b/.github/workflows/docker-image-pr.yml @@ -25,6 +25,8 @@ jobs: for i in {1..10}; do nc -z localhost 27017 && echo "MongoDB is up" && break echo "Retrying in 3 seconds..." + echo "Container logs:" + docker logs grandnode2-container --tail 20 sleep 3 done @@ -79,12 +81,21 @@ jobs: else echo "Received HTTP response code: $RESPONSE. Retrying in 3 seconds..." fi + echo "Container logs:" + docker logs grandnode2-container --tail 30 sleep 3 done echo "Application did not start successfully. Final response code: $RESPONSE" exit 1 - + + - name: Show container logs + run: | + echo "=== Full container logs ===" + docker logs grandnode2-container + echo "=== Container status ===" + docker inspect grandnode2-container --format='{{.State.Status}} - Exit: {{.State.ExitCode}}' + - name: Stop and remove the container run: | docker stop grandnode2-container - docker rm grandnode2-container + docker rm grandnode2-container \ No newline at end of file diff --git a/.github/workflows/grandnode.yml b/.github/workflows/grandnode.yml index ad7c7c6a3..81cdfdfd1 100644 --- a/.github/workflows/grandnode.yml +++ b/.github/workflows/grandnode.yml @@ -17,7 +17,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + dotnet-version: 10.0.x - name: Create mongoDB Docker container run: sudo docker run -d -p 27017:27017 mongo:latest - name: Install .NET Aspire workload diff --git a/Directory.Packages.props b/Directory.Packages.props index bed463045..5f787c5f7 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,80 +3,80 @@ true - - + + - - + + - - - - - - - - + + + + + + + + - - + + - + - - - - + + + + - - + + - - - - - - - - - - + + + + + + + + + + - + - + - - + + - - + + - - + + - - - - - - - - - + + + + + + + + + - - + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 415043435..e2f11fe3f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build stage -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build-env LABEL stage=build-env WORKDIR /app @@ -24,9 +24,14 @@ RUN for plugin in /app/Plugins/*; do \ RUN dotnet publish /app/Web/Grand.Web/Grand.Web.csproj -c Release -o ./build/release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH # Runtime stage -FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime EXPOSE 8080 WORKDIR /app COPY --from=build-env /app/build/release . + +RUN chown -R app:app /app/App_Data /app/wwwroot /app/Plugins + +USER app + ENTRYPOINT ["dotnet", "Grand.Web.dll"] diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 01d349288..a9d9c5bd1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,9 +13,9 @@ variables: steps: - task: UseDotNet@2 - displayName: 'Install .NET Core SDK 9' + displayName: 'Install .NET Core SDK 10' inputs: - version: '9.0.x' + version: '10.0.x' - task: Bash@3 displayName: Install .NET Aspire workload diff --git a/global.json b/global.json index 41c9ad2ed..f72210cac 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,6 @@ { "sdk": { - "version": "9.0.100", - "rollForward": "latestFeature", - "allowPrerelease": false + "version": "10.0.100", + "rollForward": "latestFeature" } -} +} \ No newline at end of file diff --git a/src/Aspire/Aspire.AppHost/Aspire.AppHost.csproj b/src/Aspire/Aspire.AppHost/Aspire.AppHost.csproj index 17a2cccee..d13247fb5 100644 --- a/src/Aspire/Aspire.AppHost/Aspire.AppHost.csproj +++ b/src/Aspire/Aspire.AppHost/Aspire.AppHost.csproj @@ -23,6 +23,7 @@ + diff --git a/src/Build/Grand.Common.props b/src/Build/Grand.Common.props index 17a1a4961..bb4383b86 100644 --- a/src/Build/Grand.Common.props +++ b/src/Build/Grand.Common.props @@ -1,6 +1,6 @@ - net9.0 + net10.0 latest true diff --git a/src/Business/Grand.Business.Common/Utilities/PowerExcelMapper.cs b/src/Business/Grand.Business.Common/Utilities/PowerExcelMapper.cs index d1ca00146..50c5ef9e1 100644 --- a/src/Business/Grand.Business.Common/Utilities/PowerExcelMapper.cs +++ b/src/Business/Grand.Business.Common/Utilities/PowerExcelMapper.cs @@ -21,21 +21,22 @@ private static async Task ReadAsync(Stream stream) return ms; } - public new async Task> FetchAsync(Stream stream, int sheetIndex = 0, + public async Task> FetchAsync(Stream stream, int sheetIndex = 0, Func valueParser = null) { using var ms = await ReadAsync(stream); + ms.Position = 0; return Fetch(ms, typeof(T), sheetIndex, valueParser).OfType(); } - public new IEnumerable Fetch(Stream stream, Type type, int sheetIndex, + public IEnumerable Fetch(Stream stream, Type type, int sheetIndex, Func valueParser = null) { Workbook = WorkbookFactory.Create(stream); return Fetch(type, sheetIndex, valueParser); } - public new IEnumerable Fetch(Type type, int sheetIndex = 0, Func valueParser = null) + public IEnumerable Fetch(Type type, int sheetIndex = 0, Func valueParser = null) { var sheet = Workbook.GetSheetAt(sheetIndex); return Fetch(sheet, type, valueParser); diff --git a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs index b19af9b63..8430a85c2 100644 --- a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs +++ b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs @@ -8,6 +8,7 @@ using Grand.SharedKernel; using Grand.SharedKernel.Extensions; using MediatR; +using System.IO; namespace Grand.Business.Marketing.Services.Newsletters; @@ -278,9 +279,9 @@ public virtual async Task ImportNewsletterSubscribersFromTxt(Stream stream, { var count = 0; using var reader = new StreamReader(stream); - while (!reader.EndOfStream) + string line; + while ((line = await reader.ReadLineAsync()) is not null) { - var line = await reader.ReadLineAsync(); if (string.IsNullOrWhiteSpace(line)) continue; var tmp = line.Split(','); diff --git a/src/Core/Grand.Infrastructure/Caching/Redis/RedisMessageBus.cs b/src/Core/Grand.Infrastructure/Caching/Redis/RedisMessageBus.cs index 78970ae22..7117afb2c 100644 --- a/src/Core/Grand.Infrastructure/Caching/Redis/RedisMessageBus.cs +++ b/src/Core/Grand.Infrastructure/Caching/Redis/RedisMessageBus.cs @@ -42,11 +42,16 @@ public async Task PublishAsync(TMessage msg) where TMessage : IMessage public Task SubscribeAsync() { - _subscriber.SubscribeAsync(RedisChannel.Literal(_redisConfig.RedisPubSubChannel), (_, redisValue) => + _ = _subscriber.SubscribeAsync(RedisChannel.Literal(_redisConfig.RedisPubSubChannel), (_, redisValue) => { try { - var message = JsonSerializer.Deserialize(redisValue); + MessageEventClient message = null; + if (!redisValue.IsNull) + { + // Use the string overload explicitly to resolve ambiguity + message = JsonSerializer.Deserialize(redisValue.ToString()); + } if (message != null && message.ClientId != ClientId) OnSubscriptionChanged(message); } diff --git a/src/Core/Grand.Infrastructure/Configuration/SecurityConfig.cs b/src/Core/Grand.Infrastructure/Configuration/SecurityConfig.cs index 5174ab745..ff29b3f5e 100644 --- a/src/Core/Grand.Infrastructure/Configuration/SecurityConfig.cs +++ b/src/Core/Grand.Infrastructure/Configuration/SecurityConfig.cs @@ -73,11 +73,6 @@ public class SecurityConfig public int HttpsRedirectionRedirect { get; set; } public int? HttpsRedirectionHttpsPort { get; set; } - /// - /// When enabled, allowing Razor files to be updated if they're edited. - /// - public bool EnableRuntimeCompilation { get; set; } - /// /// Gets or sets a value indicating whether to verify access to a specific controller and action in the admin panel /// using menu configuration. diff --git a/src/Core/Grand.Infrastructure/StartupBase.cs b/src/Core/Grand.Infrastructure/StartupBase.cs index e8fb400d3..33f1c35d8 100644 --- a/src/Core/Grand.Infrastructure/StartupBase.cs +++ b/src/Core/Grand.Infrastructure/StartupBase.cs @@ -123,8 +123,7 @@ private static T StartupConfig(this IServiceCollection services, IConfigurati /// Collection of service descriptors private static void AddHttpContextAccessor(this IServiceCollection services) { - services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); } /// diff --git a/src/Modules/Grand.Module.Api/Extensions/OpenApiOptionsExtensions.cs b/src/Modules/Grand.Module.Api/Extensions/OpenApiOptionsExtensions.cs index 100b9012a..455def999 100644 --- a/src/Modules/Grand.Module.Api/Extensions/OpenApiOptionsExtensions.cs +++ b/src/Modules/Grand.Module.Api/Extensions/OpenApiOptionsExtensions.cs @@ -1,8 +1,7 @@ using Grand.Module.Api.Attributes; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.OpenApi; -using Microsoft.OpenApi.Any; -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; namespace Grand.Module.Api.Infrastructure.Extensions { @@ -17,7 +16,7 @@ public static void AddOperationTransformer(this OpenApiOptions options) { if (operation.Parameters == null) { - operation.Parameters = new List(); + operation.Parameters = new List(); } operation.Parameters.Add(new OpenApiParameter { @@ -27,8 +26,8 @@ public static void AddOperationTransformer(this OpenApiOptions options) Description = "Show only the first n items.", Required = false, Schema = new OpenApiSchema { - Minimum = 0, - Type = "integer" + Minimum = "0", + Type = JsonSchemaType.Integer } }); operation.Parameters.Add(new OpenApiParameter { @@ -38,8 +37,8 @@ public static void AddOperationTransformer(this OpenApiOptions options) Description = "Skip the first n items", Required = false, Schema = new OpenApiSchema { - Minimum = 0, - Type = "integer" + Minimum = "0", + Type = JsonSchemaType.Integer } }); operation.Parameters.Add(new OpenApiParameter { @@ -47,10 +46,9 @@ public static void AddOperationTransformer(this OpenApiOptions options) AllowReserved = true, In = ParameterLocation.Query, Description = "Order items by property values (LINQ notation)", - Example = new OpenApiString("Name, DisplayOrder"), Required = false, Schema = new OpenApiSchema { - Type = "string" + Type = JsonSchemaType.String } }); operation.Parameters.Add(new OpenApiParameter { @@ -58,10 +56,9 @@ public static void AddOperationTransformer(this OpenApiOptions options) AllowReserved = true, In = ParameterLocation.Query, Description = "Filter items by property values (LINQ notation) ", - Example = new OpenApiString("Name == \"John\""), Required = false, Schema = new OpenApiSchema { - Type = "string" + Type = JsonSchemaType.String } }); operation.Parameters.Add(new OpenApiParameter { @@ -69,10 +66,9 @@ public static void AddOperationTransformer(this OpenApiOptions options) AllowReserved = true, In = ParameterLocation.Query, Description = "Select specific properties from the model (LINQ notation)", - Example = new OpenApiString("Id, Name"), Required = false, Schema = new OpenApiSchema { - Type = "string" + Type = JsonSchemaType.String } }); } @@ -92,7 +88,7 @@ public static void AddCsrfTokenTransformer(this OpenApiOptions options) In = ParameterLocation.Header, Required = true, Schema = new OpenApiSchema { - Type = "string", + Type = JsonSchemaType.String, Description = "Antiforgery token" } }); diff --git a/src/Modules/Grand.Module.Api/Infrastructure/Transformers/BearerSecuritySchemeTransformer.cs b/src/Modules/Grand.Module.Api/Infrastructure/Transformers/BearerSecuritySchemeTransformer.cs index 9498d77cd..52747ba27 100644 --- a/src/Modules/Grand.Module.Api/Infrastructure/Transformers/BearerSecuritySchemeTransformer.cs +++ b/src/Modules/Grand.Module.Api/Infrastructure/Transformers/BearerSecuritySchemeTransformer.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.OpenApi; -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; namespace Grand.Module.Api.Infrastructure.Transformers; internal sealed class BearerSecuritySchemeTransformer(IAuthenticationSchemeProvider authenticationSchemeProvider) : IOpenApiDocumentTransformer @@ -10,7 +10,7 @@ public async Task TransformAsync(OpenApiDocument document, OpenApiDocumentTransf var authenticationSchemes = await authenticationSchemeProvider.GetAllSchemesAsync(); if (authenticationSchemes.Any(authScheme => authScheme.Name == "Bearer")) { - var requirements = new Dictionary { + var requirements = new Dictionary { ["Bearer"] = new OpenApiSecurityScheme { Type = SecuritySchemeType.Http, Scheme = "bearer", diff --git a/src/Modules/Grand.Module.Api/Infrastructure/Transformers/EnumSchemaTransformer.cs b/src/Modules/Grand.Module.Api/Infrastructure/Transformers/EnumSchemaTransformer.cs index 9761f89bf..fdc98ff6f 100644 --- a/src/Modules/Grand.Module.Api/Infrastructure/Transformers/EnumSchemaTransformer.cs +++ b/src/Modules/Grand.Module.Api/Infrastructure/Transformers/EnumSchemaTransformer.cs @@ -1,5 +1,5 @@ using Microsoft.AspNetCore.OpenApi; -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; namespace Grand.Module.Api.Infrastructure.Transformers; diff --git a/src/Modules/Grand.Module.Api/Infrastructure/Transformers/IgnoreFieldSchemaTransformer.cs b/src/Modules/Grand.Module.Api/Infrastructure/Transformers/IgnoreFieldSchemaTransformer.cs index c0380cb02..91e0b80b3 100644 --- a/src/Modules/Grand.Module.Api/Infrastructure/Transformers/IgnoreFieldSchemaTransformer.cs +++ b/src/Modules/Grand.Module.Api/Infrastructure/Transformers/IgnoreFieldSchemaTransformer.cs @@ -1,6 +1,6 @@ using Grand.SharedKernel.Attributes; using Microsoft.AspNetCore.OpenApi; -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; using System.Reflection; namespace Grand.Module.Api.Infrastructure.Transformers; @@ -31,6 +31,5 @@ public Task TransformAsync(OpenApiSchema schema, OpenApiSchemaTransformerContext foreach (var propertyToExclude in excludedSchemaPropertyKey) schema.Properties.Remove(propertyToExclude); return Task.CompletedTask; - //throw new NotImplementedException(); } } diff --git a/src/Plugins/Authentication.Facebook/Authentication.Facebook.csproj b/src/Plugins/Authentication.Facebook/Authentication.Facebook.csproj index 323c3828a..b32d2dfe9 100644 --- a/src/Plugins/Authentication.Facebook/Authentication.Facebook.csproj +++ b/src/Plugins/Authentication.Facebook/Authentication.Facebook.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/Plugins/Authentication.Google/Authentication.Google.csproj b/src/Plugins/Authentication.Google/Authentication.Google.csproj index 881337f8e..ca0135aca 100644 --- a/src/Plugins/Authentication.Google/Authentication.Google.csproj +++ b/src/Plugins/Authentication.Google/Authentication.Google.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/Plugins/Payments.BrainTree/Payments.BrainTree.csproj b/src/Plugins/Payments.BrainTree/Payments.BrainTree.csproj index d6ced0aeb..f67f87a10 100644 --- a/src/Plugins/Payments.BrainTree/Payments.BrainTree.csproj +++ b/src/Plugins/Payments.BrainTree/Payments.BrainTree.csproj @@ -22,7 +22,7 @@ - + diff --git a/src/Plugins/Payments.StripeCheckout/Areas/Admin/Views/StripeCheckout/Configure.cshtml b/src/Plugins/Payments.StripeCheckout/Areas/Admin/Views/StripeCheckout/Configure.cshtml index 7eeb90901..3686d4e8e 100644 --- a/src/Plugins/Payments.StripeCheckout/Areas/Admin/Views/StripeCheckout/Configure.cshtml +++ b/src/Plugins/Payments.StripeCheckout/Areas/Admin/Views/StripeCheckout/Configure.cshtml @@ -1,14 +1,9 @@ -@inject IUrlHelperFactory UrlHelperFactory -@inject IActionContextAccessor ActionContextAccessor -@inject IContextAccessor contextAccessor +@inject IContextAccessor contextAccessor @{ Layout = "_ConfigurePlugin"; - var urlHelper = UrlHelperFactory.GetUrlHelper(ActionContextAccessor.ActionContext!); - var webhookUrl = contextAccessor.StoreContext.CurrentHost.Url.TrimEnd('/') + urlHelper.RouteUrl(StripeCheckoutDefaults.WebHook); + var webhookUrl = contextAccessor.StoreContext.CurrentHost.Url.TrimEnd('/') + Url.RouteUrl(StripeCheckoutDefaults.WebHook); } @using Grand.Infrastructure -@using Microsoft.AspNetCore.Mvc.Infrastructure -@using Microsoft.AspNetCore.Mvc.Routing @using Payments.StripeCheckout @model Payments.StripeCheckout.Models.ConfigurationModel @await Component.InvokeAsync("StoreScope") diff --git a/src/Plugins/Payments.StripeCheckout/Payments.StripeCheckout.csproj b/src/Plugins/Payments.StripeCheckout/Payments.StripeCheckout.csproj index d87a41f30..55a1cd0e6 100644 --- a/src/Plugins/Payments.StripeCheckout/Payments.StripeCheckout.csproj +++ b/src/Plugins/Payments.StripeCheckout/Payments.StripeCheckout.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/Tests/Grand.Business.Authentication.Tests/Services/ApiAuthenticationServiceTests.cs b/src/Tests/Grand.Business.Authentication.Tests/Services/ApiAuthenticationServiceTests.cs index 32ca6ab19..3a9e4625b 100644 --- a/src/Tests/Grand.Business.Authentication.Tests/Services/ApiAuthenticationServiceTests.cs +++ b/src/Tests/Grand.Business.Authentication.Tests/Services/ApiAuthenticationServiceTests.cs @@ -47,7 +47,7 @@ public async Task Valid_NullEmail_ReturnFalse() context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, "")); var result = await _jwtBearerAuthenticationService.Valid(context); Assert.IsFalse(result); - Assert.AreEqual(await _jwtBearerAuthenticationService.ErrorMessage(), "Email not exists in the context"); + Assert.AreEqual("Email not exists in the context", await _jwtBearerAuthenticationService.ErrorMessage()); } [TestMethod] @@ -62,8 +62,8 @@ public async Task Valid_NullToken_ReturnFalse() context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, "")); var result = await _jwtBearerAuthenticationService.Valid(context); Assert.IsFalse(result); - Assert.AreEqual(await _jwtBearerAuthenticationService.ErrorMessage(), - "Wrong token, change password on the customer and create token again"); + Assert.AreEqual("Wrong token, change password on the customer and create token again", + await _jwtBearerAuthenticationService.ErrorMessage()); } [TestMethod] @@ -81,8 +81,8 @@ public async Task Valid_NotFoundCoustomer_ReturnFalse() .Returns(() => Task.FromResult(null)); var result = await _jwtBearerAuthenticationService.Valid(context); Assert.IsFalse(result); - Assert.AreEqual(await _jwtBearerAuthenticationService.ErrorMessage(), - "Email not exists/or not active in the customer table"); + Assert.AreEqual("Email not exists/or not active in the customer table", + await _jwtBearerAuthenticationService.ErrorMessage()); } [TestMethod] @@ -100,8 +100,8 @@ public async Task Valid_NotActiveCustomer_ReturnFalse() .Returns(() => Task.FromResult(new Customer { Active = false })); var result = await _jwtBearerAuthenticationService.Valid(context); Assert.IsFalse(result); - Assert.AreEqual(await _jwtBearerAuthenticationService.ErrorMessage(), - "Email not exists/or not active in the customer table"); + Assert.AreEqual("Email not exists/or not active in the customer table", + await _jwtBearerAuthenticationService.ErrorMessage()); } [TestMethod] diff --git a/src/Tests/Grand.Business.Authentication.Tests/Services/CookieOptionsFactoryTests.cs b/src/Tests/Grand.Business.Authentication.Tests/Services/CookieOptionsFactoryTests.cs index 2d511f837..76e19337d 100644 --- a/src/Tests/Grand.Business.Authentication.Tests/Services/CookieOptionsFactoryTests.cs +++ b/src/Tests/Grand.Business.Authentication.Tests/Services/CookieOptionsFactoryTests.cs @@ -36,7 +36,7 @@ public void Create_WhenCalledWithoutExpiryDate_SetsDefaultExpiryDate() // Verify expiration is close to expected (allowing for slight processing time differences) var difference = (options.Expires.Value - expectedExpiryDate).TotalMinutes; - Assert.IsTrue(Math.Abs(difference) < 1, "Expiry time should be within 1 minute of expected value"); + Assert.IsLessThan(1, Math.Abs(difference), "Expiry time should be within 1 minute of expected value"); } [TestMethod] diff --git a/src/Tests/Grand.Business.Authentication.Tests/Services/JwtBearerCustomerAuthenticationServiceTests.cs b/src/Tests/Grand.Business.Authentication.Tests/Services/JwtBearerCustomerAuthenticationServiceTests.cs index 0b92234da..ec45adec1 100644 --- a/src/Tests/Grand.Business.Authentication.Tests/Services/JwtBearerCustomerAuthenticationServiceTests.cs +++ b/src/Tests/Grand.Business.Authentication.Tests/Services/JwtBearerCustomerAuthenticationServiceTests.cs @@ -54,7 +54,7 @@ public async Task Valid_NullEmail_ReturnFalse() context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, "")); var result = await _jwtBearerCustomerAuthenticationService.Valid(context); Assert.IsFalse(result); - Assert.AreEqual(await _jwtBearerCustomerAuthenticationService.ErrorMessage(), "Not found customer"); + Assert.AreEqual("Not found customer", await _jwtBearerCustomerAuthenticationService.ErrorMessage()); } [TestMethod] @@ -73,8 +73,8 @@ public async Task Valid_NullToken_ReturnFalse() context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, "")); var result = await _jwtBearerCustomerAuthenticationService.Valid(context); Assert.IsFalse(result); - Assert.AreEqual(await _jwtBearerCustomerAuthenticationService.ErrorMessage(), - "Invalid token or cancel by refresh token"); + Assert.AreEqual("Invalid token or cancel by refresh token", + await _jwtBearerCustomerAuthenticationService.ErrorMessage()); } @@ -97,8 +97,8 @@ public async Task Valid_NotActiveCustomer_ReturnFalse() .Returns(() => Task.FromResult(new Customer { Active = false })); var result = await _jwtBearerCustomerAuthenticationService.Valid(context); Assert.IsFalse(result); - Assert.AreEqual(await _jwtBearerCustomerAuthenticationService.ErrorMessage(), - "Customer not exists/or not active in the customer table"); + Assert.AreEqual("Customer not exists/or not active in the customer table", + await _jwtBearerCustomerAuthenticationService.ErrorMessage()); } [TestMethod] @@ -123,8 +123,8 @@ public async Task Valid_NoPermissions_Customer_ReturnFalse() var result = await _jwtBearerCustomerAuthenticationService.Valid(context); Assert.IsFalse(result); - Assert.AreEqual(await _jwtBearerCustomerAuthenticationService.ErrorMessage(), - "You do not have permission to use API operation (Customer group)"); + Assert.AreEqual("You do not have permission to use API operation (Customer group)", + await _jwtBearerCustomerAuthenticationService.ErrorMessage()); } [TestMethod] diff --git a/src/Tests/Grand.Business.Authentication.Tests/Startup/StartupApplicationTests.cs b/src/Tests/Grand.Business.Authentication.Tests/Startup/StartupApplicationTests.cs index c9c6e788f..b04710427 100644 --- a/src/Tests/Grand.Business.Authentication.Tests/Startup/StartupApplicationTests.cs +++ b/src/Tests/Grand.Business.Authentication.Tests/Startup/StartupApplicationTests.cs @@ -26,6 +26,6 @@ public void ConfigureServicesTest() //Act _application.ConfigureServices(_serviceCollection, _configuration); //Assert - Assert.IsTrue(_serviceCollection.Count > 0); + Assert.IsGreaterThan(0, _serviceCollection.Count); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/ProductDeletedEventHandlerTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/ProductDeletedEventHandlerTests.cs index 57c846408..0157dad81 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/ProductDeletedEventHandlerTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/ProductDeletedEventHandlerTests.cs @@ -57,9 +57,9 @@ public async Task HandleTest() //Assert var result = _repository.Table.FirstOrDefault(x => x.Id == product.Id); Assert.IsNotNull(result); - Assert.IsTrue(result.RelatedProducts.Count == 0); - Assert.IsTrue(result.RecommendedProduct.Count == 0); - Assert.IsTrue(result.CrossSellProduct.Count == 0); - Assert.IsTrue(result.SimilarProducts.Count == 0); + Assert.IsEmpty(result.RelatedProducts); + Assert.IsEmpty(result.RecommendedProduct); + Assert.IsEmpty(result.CrossSellProduct); + Assert.IsEmpty(result.SimilarProducts); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Extensions/ProductAttributeExtensionsTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Extensions/ProductAttributeExtensionsTests.cs index 48aebbce6..6967e6279 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Extensions/ProductAttributeExtensionsTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Extensions/ProductAttributeExtensionsTests.cs @@ -15,12 +15,12 @@ public void ShouldHaveValues_ReturnExpentedResult() var pam4 = new ProductAttributeMapping { AttributeControlTypeId = AttributeControlType.FileUpload }; var pam5 = new ProductAttributeMapping { AttributeControlTypeId = AttributeControlType.DropdownList }; ProductAttributeMapping pam6 = null; - Assert.AreEqual(false, pam.ShouldHaveValues()); - Assert.AreEqual(false, pam2.ShouldHaveValues()); - Assert.AreEqual(false, pam3.ShouldHaveValues()); - Assert.AreEqual(false, pam4.ShouldHaveValues()); - Assert.AreEqual(false, pam6.ShouldHaveValues()); - Assert.AreEqual(true, pam5.ShouldHaveValues()); + Assert.IsFalse(pam.ShouldHaveValues()); + Assert.IsFalse(pam2.ShouldHaveValues()); + Assert.IsFalse(pam3.ShouldHaveValues()); + Assert.IsFalse(pam4.ShouldHaveValues()); + Assert.IsFalse(pam6.ShouldHaveValues()); + Assert.IsTrue(pam5.ShouldHaveValues()); } @@ -33,12 +33,12 @@ public void ValidationRulesAllowed_ReturnExpentedResult() var pam4 = new ProductAttributeMapping { AttributeControlTypeId = AttributeControlType.FileUpload }; var pam5 = new ProductAttributeMapping { AttributeControlTypeId = AttributeControlType.DropdownList }; ProductAttributeMapping pam6 = null; - Assert.AreEqual(true, pam.ValidationRulesAllowed()); - Assert.AreEqual(true, pam2.ValidationRulesAllowed()); - Assert.AreEqual(true, pam4.ValidationRulesAllowed()); - Assert.AreEqual(false, pam3.ValidationRulesAllowed()); - Assert.AreEqual(false, pam6.ValidationRulesAllowed()); - Assert.AreEqual(false, pam5.ValidationRulesAllowed()); + Assert.IsTrue(pam.ValidationRulesAllowed()); + Assert.IsTrue(pam2.ValidationRulesAllowed()); + Assert.IsTrue(pam4.ValidationRulesAllowed()); + Assert.IsFalse(pam3.ValidationRulesAllowed()); + Assert.IsFalse(pam6.ValidationRulesAllowed()); + Assert.IsFalse(pam5.ValidationRulesAllowed()); } [TestMethod] @@ -50,12 +50,12 @@ public void CanBeUsedAsCondition_ReturnExpentedResult() var pam4 = new ProductAttributeMapping { AttributeControlTypeId = AttributeControlType.FileUpload }; var pam5 = new ProductAttributeMapping { AttributeControlTypeId = AttributeControlType.DropdownList }; ProductAttributeMapping pam6 = null; - Assert.AreEqual(false, pam.CanBeUsedAsCondition()); - Assert.AreEqual(false, pam2.CanBeUsedAsCondition()); - Assert.AreEqual(false, pam4.CanBeUsedAsCondition()); - Assert.AreEqual(false, pam3.CanBeUsedAsCondition()); - Assert.AreEqual(false, pam6.CanBeUsedAsCondition()); - Assert.AreEqual(true, pam5.CanBeUsedAsCondition()); + Assert.IsFalse(pam.CanBeUsedAsCondition()); + Assert.IsFalse(pam2.CanBeUsedAsCondition()); + Assert.IsFalse(pam4.CanBeUsedAsCondition()); + Assert.IsFalse(pam3.CanBeUsedAsCondition()); + Assert.IsFalse(pam6.CanBeUsedAsCondition()); + Assert.IsTrue(pam5.CanBeUsedAsCondition()); } [TestMethod] @@ -68,12 +68,12 @@ public void IsNonCombinable_ReturnExpentedResult() var pam5 = new ProductAttributeMapping { AttributeControlTypeId = AttributeControlType.DropdownList }; ProductAttributeMapping pam6 = null; var pam7 = new ProductAttributeMapping { Combination = true }; - Assert.AreEqual(true, pam.IsNonCombinable()); - Assert.AreEqual(true, pam2.IsNonCombinable()); - Assert.AreEqual(true, pam4.IsNonCombinable()); - Assert.AreEqual(true, pam3.IsNonCombinable()); - Assert.AreEqual(false, pam6.IsNonCombinable()); - Assert.AreEqual(true, pam5.IsNonCombinable()); - Assert.AreEqual(false, pam7.IsNonCombinable()); + Assert.IsTrue(pam.IsNonCombinable()); + Assert.IsTrue(pam2.IsNonCombinable()); + Assert.IsTrue(pam4.IsNonCombinable()); + Assert.IsTrue(pam3.IsNonCombinable()); + Assert.IsFalse(pam6.IsNonCombinable()); + Assert.IsTrue(pam5.IsNonCombinable()); + Assert.IsFalse(pam7.IsNonCombinable()); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Extensions/ProductExtensionsTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Extensions/ProductExtensionsTests.cs index 5f90a94ef..c78fcbf7a 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Extensions/ProductExtensionsTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Extensions/ProductExtensionsTests.cs @@ -13,7 +13,7 @@ public void Can_parse_allowed_quantities() var product = new Product { AllowedQuantities = "1,3,42,1,dsad,123,d22,d,122223" }; var result = product.ParseAllowedQuantities(); - Assert.AreEqual(6, result.Length); + Assert.HasCount(6, result); Assert.AreEqual(1, result[0]); Assert.AreEqual(3, result[1]); Assert.AreEqual(42, result[2]); diff --git a/src/Tests/Grand.Business.Catalog.Tests/Queries/Handlers/GetSearchProductsQueryHandlerTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Queries/Handlers/GetSearchProductsQueryHandlerTests.cs index a30d38b03..78dda398a 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Queries/Handlers/GetSearchProductsQueryHandlerTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Queries/Handlers/GetSearchProductsQueryHandlerTests.cs @@ -37,6 +37,6 @@ public async Task HandleTest() //Act var result = await handler.Handle(searchProductsQuery, CancellationToken.None); //Arrange - Assert.IsNotNull(result); + Assert.IsNotNull(result.products); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandLayoutServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandLayoutServiceTests.cs index 7d9b69c9c..4489846c8 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandLayoutServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandLayoutServiceTests.cs @@ -43,7 +43,7 @@ public async Task GetAllBrandLayoutsTest() var layouts = await _brandLayoutService.GetAllBrandLayouts(); //Assert - Assert.AreEqual(3, layouts.Count); + Assert.HasCount(3, layouts); } [TestMethod] @@ -69,7 +69,7 @@ public async Task InsertBrandLayoutTest() //Act await _brandLayoutService.InsertBrandLayout(new BrandLayout()); //Assert - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); } [TestMethod] @@ -107,6 +107,6 @@ public async Task DeleteBrandLayoutTest() //Assert Assert.IsNull(_repository.Table.FirstOrDefault(x => x.Name == "test1")); - Assert.AreEqual(1, _repository.Table.Count()); + Assert.HasCount(1, _repository.Table); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs index 392d2bb08..1f07b7d96 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs @@ -50,7 +50,7 @@ public async Task GetAllBrandsTest() var brand = await _brandService.GetAllBrands(); //Assert - Assert.AreEqual(3, brand.Count); + Assert.HasCount(3, brand); } [TestMethod] @@ -76,7 +76,7 @@ public async Task InsertBrandTest() //Act await _brandService.InsertBrand(new Brand()); //Assert - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); } [TestMethod] @@ -114,7 +114,7 @@ public async Task DeleteBrandTest() //Assert Assert.IsNull(_repository.Table.FirstOrDefault(x => x.Name == "test1")); - Assert.AreEqual(1, _repository.Table.Count()); + Assert.HasCount(1, _repository.Table); } [TestMethod] @@ -137,6 +137,6 @@ public async Task GetAllBrandsByDiscountTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.Count); + Assert.HasCount(1, result); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryLayoutServiceDbTest.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryLayoutServiceDbTest.cs index 2ed4c4168..7a9478349 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryLayoutServiceDbTest.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryLayoutServiceDbTest.cs @@ -59,7 +59,7 @@ public async Task GetAllCategoryLayouts() var layouts = await _categoryLayoutService.GetAllCategoryLayouts(); //Assert - Assert.AreEqual(3, layouts.Count); + Assert.HasCount(3, layouts); } [TestMethod] @@ -80,7 +80,7 @@ public async Task DeleteCategoryLayout() //Assert Assert.IsNull(_repository.Table.FirstOrDefault(x => x.Name == "test1")); - Assert.AreEqual(1, _repository.Table.Count()); + Assert.HasCount(1, _repository.Table); } @@ -90,7 +90,7 @@ public async Task InsertCategoryLayout_True() //Act await _categoryLayoutService.InsertCategoryLayout(new CategoryLayout()); //Assert - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); } [TestMethod] diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs index 3ef79dec1..a03f29eba 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs @@ -49,7 +49,7 @@ public async Task InsertCategory() //Act await _categoryService.InsertCategory(new Category()); //Assert - Assert.IsTrue(_categoryRepository.Table.Any()); + Assert.IsNotEmpty(_categoryRepository.Table); } [TestMethod] @@ -74,7 +74,7 @@ public async Task DeleteCategory() //Act await _categoryService.DeleteCategory(allCategory.FirstOrDefault(x => x.Id == "1")); //Assert - Assert.IsTrue(_categoryRepository.Table.Count() == 4); + Assert.HasCount(4, _categoryRepository.Table); Assert.IsNull(_categoryRepository.Table.FirstOrDefault(x => x.Id == "1")); } @@ -86,7 +86,7 @@ public async Task GetCategoryBreadCrumb() var category = new Category { Id = "6", ParentCategoryId = "3", Published = true }; await _categoryService.InsertCategory(category); var result = await _categoryService.GetCategoryBreadCrumb(category); - Assert.IsTrue(result.Count == 2); + Assert.HasCount(2, result); Assert.IsTrue(result.Any(c => c.Id.Equals("6"))); Assert.IsTrue(result.Any(c => c.Id.Equals("3"))); } @@ -98,7 +98,7 @@ public void GetCategoryBreadCrumb_AllCategory() allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult()); var category = new Category { ParentCategoryId = "3" }; var result = _categoryService.GetCategoryBreadCrumb(category, allCategory); - Assert.IsTrue(result.Count == 0); + Assert.IsEmpty(result); } [TestMethod] @@ -107,7 +107,7 @@ public async Task GetAllCategories() var allCategory = GetMockCategoryList(); allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult()); var result = await _categoryService.GetAllCategories(); - Assert.IsTrue(result.Count == 5); + Assert.HasCount(5, result); } [TestMethod] @@ -116,7 +116,7 @@ public async Task GetMenuCategories() var allCategory = GetMockCategoryList(); allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult()); var result = await _categoryService.GetMenuCategories(); - Assert.IsTrue(result.Count == 1); + Assert.HasCount(1, result); } [TestMethod] @@ -125,7 +125,7 @@ public async Task GetAllCategoriesByParentCategoryId() var allCategory = GetMockCategoryList(); allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult()); var result = await _categoryService.GetAllCategoriesByParentCategoryId("5"); - Assert.IsTrue(result.Count == 1); + Assert.HasCount(1, result); } [TestMethod] @@ -134,7 +134,7 @@ public async Task GetAllCategoriesDisplayedOnHomePage() var allCategory = GetMockCategoryList(); allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult()); var result = await _categoryService.GetAllCategoriesDisplayedOnHomePage(); - Assert.IsTrue(result.Count == 2); + Assert.HasCount(2, result); } [TestMethod] @@ -143,7 +143,7 @@ public async Task GetAllCategoriesFeaturedProductsOnHomePage() var allCategory = GetMockCategoryList(); allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult()); var result = await _categoryService.GetAllCategoriesFeaturedProductsOnHomePage(); - Assert.IsTrue(result.Count == 2); + Assert.HasCount(2, result); } [TestMethod] @@ -152,7 +152,7 @@ public async Task GetAllCategoriesSearchBox() var allCategory = GetMockCategoryList(); allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult()); var result = await _categoryService.GetAllCategoriesSearchBox(); - Assert.IsTrue(result.Count == 2); + Assert.HasCount(2, result); } [TestMethod] @@ -181,7 +181,7 @@ public async Task GetCategoryBreadCrumb_ShouldReturnTwoElement() var category = new Category { Id = "6", ParentCategoryId = "3", Published = true }; await _categoryService.InsertCategory(category); var result = _categoryService.GetCategoryBreadCrumb(category, allCategory); - Assert.IsTrue(result.Count == 2); + Assert.HasCount(2, result); Assert.IsTrue(result.Any(c => c.Id.Equals("6"))); Assert.IsTrue(result.Any(c => c.Id.Equals("3"))); } @@ -193,7 +193,7 @@ public void GetCategoryBreadCrumb_ShouldReturnThreeElement() allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult()); var category = new Category { Id = "6", ParentCategoryId = "1", Published = true }; var result = _categoryService.GetCategoryBreadCrumb(category, allCategory); - Assert.IsTrue(result.Count == 3); + Assert.HasCount(3, result); Assert.IsTrue(result.Any(c => c.Id.Equals("6"))); Assert.IsTrue(result.Any(c => c.Id.Equals("1"))); Assert.IsTrue(result.Any(c => c.Id.Equals("5"))); diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceTests.cs index 29746808e..e6f7cc705 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceTests.cs @@ -89,7 +89,7 @@ public void GetCategoryBreadCrumb_ShouldReturnEmptyList() _aclServiceMock.Setup(a => a.Authorize(It.IsAny(), It.IsAny())).Returns(() => true); _aclServiceMock.Setup(a => a.Authorize(It.IsAny(), It.IsAny())).Returns(() => true); var result = _categoryService.GetCategoryBreadCrumb(category, allCategory); - Assert.IsTrue(result.Count == 0); + Assert.IsEmpty(result); } [TestMethod] @@ -102,7 +102,7 @@ public void GetCategoryBreadCrumb_ShouldReturnTwoElement() _aclServiceMock.Setup(a => a.Authorize(It.IsAny(), It.IsAny())).Returns(() => true); _aclServiceMock.Setup(a => a.Authorize(It.IsAny(), It.IsAny())).Returns(() => true); var result = _categoryService.GetCategoryBreadCrumb(category, allCategory); - Assert.IsTrue(result.Count == 2); + Assert.HasCount(2, result); Assert.IsTrue(result.Any(c => c.Id.Equals("6"))); Assert.IsTrue(result.Any(c => c.Id.Equals("3"))); } @@ -117,7 +117,7 @@ public void GetCategoryBreadCrumb_ShouldReturnThreeElement() _aclServiceMock.Setup(a => a.Authorize(It.IsAny(), It.IsAny())).Returns(() => true); _aclServiceMock.Setup(a => a.Authorize(It.IsAny(), It.IsAny())).Returns(() => true); var result = _categoryService.GetCategoryBreadCrumb(category, allCategory); - Assert.IsTrue(result.Count == 3); + Assert.HasCount(3, result); Assert.IsTrue(result.Any(c => c.Id.Equals("6"))); Assert.IsTrue(result.Any(c => c.Id.Equals("1"))); Assert.IsTrue(result.Any(c => c.Id.Equals("5"))); diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/ProductCategoryServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/ProductCategoryServiceTests.cs index baf72e6bf..129bbeb9d 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/ProductCategoryServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/ProductCategoryServiceTests.cs @@ -56,8 +56,8 @@ public async Task GetProductCategoriesByCategoryIdTest() var pc2 = await _productCategoryService.GetProductCategoriesByCategoryId("2"); //Assert - Assert.AreEqual(1, pc1.Count); - Assert.AreEqual(2, pc2.Count); + Assert.HasCount(1, pc1); + Assert.HasCount(2, pc2); } [TestMethod] @@ -77,7 +77,7 @@ await _productCategoryService.InsertProductCategory(new ProductCategory { Catego var pc1 = await _productCategoryService.GetProductCategoriesByCategoryId("1"); //Assert - Assert.AreEqual(1, pc1.Count); + Assert.HasCount(1, pc1); Assert.AreEqual(10, pc1.FirstOrDefault().DisplayOrder); } @@ -102,7 +102,7 @@ public async Task UpdateProductCategoryTest() var pc1 = await _productCategoryService.GetProductCategoriesByCategoryId("10"); //Assert - Assert.AreEqual(1, pc1.Count); + Assert.HasCount(1, pc1); Assert.AreEqual(5, pc1.FirstOrDefault().DisplayOrder); } @@ -125,6 +125,6 @@ public async Task DeleteProductCategoryTest() var pc1 = await _productCategoryService.GetProductCategoriesByCategoryId("1"); //Assert - Assert.AreEqual(0, pc1.Count); + Assert.IsEmpty(pc1); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/CollectionLayoutServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/CollectionLayoutServiceTests.cs index cb7bcc890..a27535845 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/CollectionLayoutServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/CollectionLayoutServiceTests.cs @@ -43,7 +43,7 @@ public async Task GetAllCollectionLayoutsTest() var layouts = await _collectionLayoutService.GetAllCollectionLayouts(); //Assert - Assert.AreEqual(3, layouts.Count); + Assert.HasCount(3, layouts); } [TestMethod] @@ -69,7 +69,7 @@ public async Task InsertCollectionLayoutTest() //Act await _collectionLayoutService.InsertCollectionLayout(new CollectionLayout()); //Assert - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); } [TestMethod] @@ -107,6 +107,6 @@ public async Task DeleteCollectionLayoutTest() //Assert Assert.IsNull(_repository.Table.FirstOrDefault(x => x.Name == "test1")); - Assert.AreEqual(1, _repository.Table.Count()); + Assert.HasCount(1, _repository.Table); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/ProductCollectionServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/ProductCollectionServiceTests.cs index 6ad830dd5..3cb5bbe6d 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/ProductCollectionServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/ProductCollectionServiceTests.cs @@ -56,8 +56,8 @@ public async Task GetProductCollectionsByCollectionIdTest() var pc2 = await _productCollectionService.GetProductCollectionsByCollectionId("2", ""); //Assert - Assert.AreEqual(1, pc1.Count); - Assert.AreEqual(2, pc2.Count); + Assert.HasCount(1, pc1); + Assert.HasCount(2, pc2); } [TestMethod] @@ -77,7 +77,7 @@ await _productCollectionService.InsertProductCollection( var pc1 = await _productCollectionService.GetProductCollectionsByCollectionId("1", ""); //Assert - Assert.AreEqual(1, pc1.Count); + Assert.HasCount(1, pc1); Assert.AreEqual(10, pc1.FirstOrDefault().DisplayOrder); } @@ -102,7 +102,7 @@ public async Task UpdateProductCollectionTest() var pc1 = await _productCollectionService.GetProductCollectionsByCollectionId("10", ""); //Assert - Assert.AreEqual(1, pc1.Count); + Assert.HasCount(1, pc1); Assert.AreEqual(5, pc1.FirstOrDefault().DisplayOrder); } @@ -125,6 +125,6 @@ public async Task DeleteProductCollectionTest() var pc1 = await _productCollectionService.GetProductCollectionsByCollectionId("1", ""); //Assert - Assert.AreEqual(0, pc1.Count); + Assert.IsEmpty(pc1); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountHandlerServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountHandlerServiceTests.cs index 076737230..80221b76d 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountHandlerServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountHandlerServiceTests.cs @@ -61,7 +61,7 @@ public async Task GetAllowedDiscounts_ShouldReturnEmptyList_WhenIgnoreDiscountsI var result = await _discountApplicationService.GetAllowedDiscounts(product, customer, store, currency); // Assert - Assert.AreEqual(0, result.Count); + Assert.IsEmpty(result); } [TestMethod] @@ -101,7 +101,7 @@ public async Task GetAllowedDiscounts_ShouldReturnDiscounts_WhenDiscountsAreVali var result = await _discountApplicationService.GetAllowedDiscounts(product, customer, store, currency); // Assert - Assert.AreEqual(1, result.Count); + Assert.HasCount(1, result); Assert.AreEqual("discount1", result[0].DiscountId); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs index ef72e1418..706a96652 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs @@ -103,7 +103,7 @@ public async Task GetAllDiscountsTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } [TestMethod] @@ -179,7 +179,7 @@ public void LoadAllDiscountProvidersTest() //Act var providers = _discountProviderLoader.LoadAllDiscountProviders(); //Assert - Assert.AreEqual(1, providers.Count); + Assert.HasCount(1, providers); } [TestMethod] @@ -234,7 +234,7 @@ public async Task GetAllCouponCodesByDiscountIdTest() //Act var coupon = await _dicountService.GetAllCouponCodesByDiscountId(discount.Id); //Assert - Assert.AreEqual(2, coupon.Count); + Assert.HasCount(2, coupon); } [TestMethod] @@ -604,7 +604,7 @@ public async Task GetAllDiscountUsageHistoryTest() var usageHistory = await handler.Handle(new GetDiscountUsageHistoryQuery(), CancellationToken.None); //Assert - Assert.AreEqual(2, usageHistory.Count); + Assert.HasCount(2, usageHistory); } [TestMethod] @@ -848,6 +848,6 @@ public void LoadDiscountAmountProvidersTest() //Act var discountProviders = _discountProviderLoader.LoadDiscountAmountProviders(); //Assert - Assert.AreEqual(1, discountProviders.Count); + Assert.HasCount(1, discountProviders); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/BrandImportDataObjectTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/BrandImportDataObjectTests.cs index d654135bd..bf19ad0ca 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/BrandImportDataObjectTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/BrandImportDataObjectTests.cs @@ -87,8 +87,8 @@ public async Task ExecuteTest_Import_Insert() await _brandImportDataObject.Execute(brands); //Assert - Assert.IsTrue(_repository.Table.Any()); - Assert.AreEqual(3, _repository.Table.Count()); + Assert.IsNotEmpty(_repository.Table); + Assert.HasCount(3, _repository.Table); } [TestMethod] @@ -126,11 +126,11 @@ public async Task ExecuteTest_Import_Update() await _brandImportDataObject.Execute(brands); //Assert - Assert.IsTrue(_repository.Table.Any()); - Assert.AreEqual(3, _repository.Table.Count()); + Assert.IsNotEmpty(_repository.Table); + Assert.HasCount(3, _repository.Table); Assert.AreEqual("update3", _repository.Table.FirstOrDefault(x => x.Id == brand3.Id).Name); Assert.AreEqual(3, _repository.Table.FirstOrDefault(x => x.Id == brand3.Id).DisplayOrder); - Assert.AreEqual(false, _repository.Table.FirstOrDefault(x => x.Id == brand3.Id).Published); + Assert.IsFalse(_repository.Table.FirstOrDefault(x => x.Id == brand3.Id).Published); } [TestMethod] @@ -159,11 +159,11 @@ public async Task ExecuteTest_Import_Insert_Update() await _brandImportDataObject.Execute(brands); //Assert - Assert.IsTrue(_repository.Table.Any()); - Assert.AreEqual(3, _repository.Table.Count()); + Assert.IsNotEmpty(_repository.Table); + Assert.HasCount(3, _repository.Table); Assert.AreEqual("update3", _repository.Table.FirstOrDefault(x => x.Id == brand3.Id).Name); Assert.AreEqual(3, _repository.Table.FirstOrDefault(x => x.Id == brand3.Id).DisplayOrder); - Assert.AreEqual(false, _repository.Table.FirstOrDefault(x => x.Id == brand3.Id).Published); + Assert.IsFalse(_repository.Table.FirstOrDefault(x => x.Id == brand3.Id).Published); } private void InitAutoMapper() diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CategoryImportDataObjectTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CategoryImportDataObjectTests.cs index 115c5e1f1..7efa3521c 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CategoryImportDataObjectTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CategoryImportDataObjectTests.cs @@ -88,8 +88,8 @@ public async Task ExecuteTest_Import_Insert() await _categoryImportDataObject.Execute(categorys); //Assert - Assert.IsTrue(_repository.Table.Any()); - Assert.AreEqual(3, _repository.Table.Count()); + Assert.IsNotEmpty(_repository.Table); + Assert.HasCount(3, _repository.Table); } [TestMethod] @@ -127,11 +127,11 @@ public async Task ExecuteTest_Import_Update() await _categoryImportDataObject.Execute(categorys); //Assert - Assert.IsTrue(_repository.Table.Any()); - Assert.AreEqual(3, _repository.Table.Count()); + Assert.IsNotEmpty(_repository.Table); + Assert.HasCount(3, _repository.Table); Assert.AreEqual("update3", _repository.Table.FirstOrDefault(x => x.Id == category3.Id).Name); Assert.AreEqual(3, _repository.Table.FirstOrDefault(x => x.Id == category3.Id).DisplayOrder); - Assert.AreEqual(false, _repository.Table.FirstOrDefault(x => x.Id == category3.Id).Published); + Assert.IsFalse(_repository.Table.FirstOrDefault(x => x.Id == category3.Id).Published); } [TestMethod] @@ -160,11 +160,11 @@ public async Task ExecuteTest_Import_Insert_Update() await _categoryImportDataObject.Execute(categorys); //Assert - Assert.IsTrue(_repository.Table.Any()); - Assert.AreEqual(3, _repository.Table.Count()); + Assert.IsNotEmpty(_repository.Table); + Assert.HasCount(3, _repository.Table); Assert.AreEqual("update3", _repository.Table.FirstOrDefault(x => x.Id == category3.Id).Name); Assert.AreEqual(3, _repository.Table.FirstOrDefault(x => x.Id == category3.Id).DisplayOrder); - Assert.AreEqual(false, _repository.Table.FirstOrDefault(x => x.Id == category3.Id).Published); + Assert.IsFalse(_repository.Table.FirstOrDefault(x => x.Id == category3.Id).Published); } private void InitAutoMapper() diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CollectionImportDataObjectTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CollectionImportDataObjectTests.cs index 815a6079f..f387c9d7f 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CollectionImportDataObjectTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CollectionImportDataObjectTests.cs @@ -88,8 +88,8 @@ public async Task ExecuteTest_Import_Insert() await _collectionImportDataObject.Execute(collections); //Assert - Assert.IsTrue(_repository.Table.Any()); - Assert.AreEqual(3, _repository.Table.Count()); + Assert.IsNotEmpty(_repository.Table); + Assert.HasCount(3, _repository.Table); } [TestMethod] @@ -130,11 +130,11 @@ public async Task ExecuteTest_Import_Update() await _collectionImportDataObject.Execute(collections); //Assert - Assert.IsTrue(_repository.Table.Any()); - Assert.AreEqual(3, _repository.Table.Count()); + Assert.IsNotEmpty(_repository.Table); + Assert.HasCount(3, _repository.Table); Assert.AreEqual("update3", _repository.Table.FirstOrDefault(x => x.Id == collection3.Id).Name); Assert.AreEqual(3, _repository.Table.FirstOrDefault(x => x.Id == collection3.Id).DisplayOrder); - Assert.AreEqual(false, _repository.Table.FirstOrDefault(x => x.Id == collection3.Id).Published); + Assert.IsFalse(_repository.Table.FirstOrDefault(x => x.Id == collection3.Id).Published); } [TestMethod] @@ -164,11 +164,11 @@ public async Task ExecuteTest_Import_Insert_Update() await _collectionImportDataObject.Execute(collections); //Assert - Assert.IsTrue(_repository.Table.Any()); - Assert.AreEqual(3, _repository.Table.Count()); + Assert.IsNotEmpty(_repository.Table); + Assert.HasCount(3, _repository.Table); Assert.AreEqual("update3", _repository.Table.FirstOrDefault(x => x.Id == collection3.Id).Name); Assert.AreEqual(3, _repository.Table.FirstOrDefault(x => x.Id == collection3.Id).DisplayOrder); - Assert.AreEqual(false, _repository.Table.FirstOrDefault(x => x.Id == collection3.Id).Published); + Assert.IsFalse(_repository.Table.FirstOrDefault(x => x.Id == collection3.Id).Published); } private void InitAutoMapper() diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs index f121b3d56..0e4035aaa 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs @@ -208,7 +208,7 @@ public async Task ExecuteTest_Import_Update() Assert.AreEqual(3, _repository.Table.Count()); Assert.AreEqual("update3", _repository.Table.FirstOrDefault(x => x.Id == product3.Id).Name); Assert.AreEqual(3, _repository.Table.FirstOrDefault(x => x.Id == product3.Id).DisplayOrder); - Assert.AreEqual(false, _repository.Table.FirstOrDefault(x => x.Id == product3.Id).Published); + Assert.IsFalse(_repository.Table.FirstOrDefault(x => x.Id == product3.Id).Published); } [TestMethod] @@ -262,7 +262,7 @@ public async Task ExecuteTest_Import_Insert_Update() Assert.AreEqual(3, _repository.Table.Count()); Assert.AreEqual("update3", _repository.Table.FirstOrDefault(x => x.Id == product3.Id).Name); Assert.AreEqual(3, _repository.Table.FirstOrDefault(x => x.Id == product3.Id).DisplayOrder); - Assert.AreEqual(false, _repository.Table.FirstOrDefault(x => x.Id == product3.Id).Published); + Assert.IsFalse(_repository.Table.FirstOrDefault(x => x.Id == product3.Id).Published); } private void InitAutoMapper() diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/AuctionServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/AuctionServiceTests.cs index 914f9cf63..046934c9e 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/AuctionServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/AuctionServiceTests.cs @@ -105,7 +105,7 @@ public async Task GetBidsByProductIdTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } [TestMethod] @@ -132,7 +132,7 @@ public async Task GetBidsByCustomerIdTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.Count); + Assert.HasCount(1, result); } [TestMethod] @@ -148,8 +148,8 @@ public async Task InsertBidTest() await _auctionService.InsertBid(bid1); //Assert - Assert.IsTrue(_repository.Table.Any()); - Assert.AreEqual(1, _repository.Table.Count()); + Assert.IsNotEmpty(_repository.Table); + Assert.HasCount(1, _repository.Table); } [TestMethod] @@ -184,7 +184,7 @@ public async Task DeleteBidTest() //Act await _auctionService.DeleteBid(bid1); //Assert - Assert.AreEqual(0, _repository.Table.Count()); + Assert.IsEmpty(_repository.Table); } [TestMethod] @@ -220,7 +220,7 @@ public async Task GetAuctionsToEndTest() var result = await _auctionService.GetAuctionsToEnd(); //Assert - Assert.AreEqual(1, result.Count); + Assert.HasCount(1, result); } [TestMethod] @@ -237,7 +237,7 @@ public async Task UpdateAuctionEndedTest() await _auctionService.UpdateAuctionEnded(product1, true, true); //Assert - Assert.AreEqual(true, _productrepository.Table.FirstOrDefault(x => x.Id == product1.Id).AuctionEnded); + Assert.IsTrue(_productrepository.Table.FirstOrDefault(x => x.Id == product1.Id).AuctionEnded); } [TestMethod] diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/OutOfStockSubscriptionServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/OutOfStockSubscriptionServiceTests.cs index 20500dc62..f23e214a8 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/OutOfStockSubscriptionServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/OutOfStockSubscriptionServiceTests.cs @@ -48,7 +48,7 @@ public async Task GetAllSubscriptionsByCustomerIdTest() var result = await _outOfStockSubscriptionService.GetAllSubscriptionsByCustomerId("1"); //Assert - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } [TestMethod] @@ -167,7 +167,7 @@ public async Task InsertSubscriptionTest() //Assert Assert.IsTrue(_repository.Table.Any()); - Assert.IsTrue(_repository.Table.Count() == 1); + Assert.AreEqual(1, _repository.Table.Count()); } [TestMethod] @@ -185,7 +185,7 @@ public async Task UpdateSubscriptionTest() //Act await _outOfStockSubscriptionService.UpdateSubscription(outOfStockSubscription1); //Assert - Assert.IsTrue(_repository.Table.FirstOrDefault().CustomerId == "2"); + Assert.AreEqual("2", _repository.Table.FirstOrDefault().CustomerId); } [TestMethod] @@ -204,7 +204,7 @@ public async Task DeleteSubscriptionTest() //Assert Assert.IsFalse(_repository.Table.Any()); - Assert.IsTrue(_repository.Table.Count() == 0); + Assert.AreEqual(0, _repository.Table.Count()); } [TestMethod] diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeParserTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeParserTests.cs index 6b7f3561e..a735ecb8a 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeParserTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeParserTests.cs @@ -41,7 +41,7 @@ public void ParseProductAttributeMappings_ReturnEmptyList() product.ProductAttributeMappings.Add(new ProductAttributeMapping { Id = "key10" }); product.ProductAttributeMappings.Add(new ProductAttributeMapping { Id = "key12" }); var result = product.ParseProductAttributeMappings(customAtr); - Assert.IsTrue(result.Count == 0); + Assert.IsEmpty(result); } [TestMethod] @@ -74,7 +74,7 @@ public void AddProductAttribute_ReturnExpectedValues() { var result = ProductExtensions.AddProductAttribute(customAtr, new ProductAttributeMapping { Id = "key6" }, "value6"); - Assert.IsTrue(result.Count == 5); + Assert.HasCount(5, result); Assert.IsTrue(result.Last().Value.Equals("value6")); } @@ -82,7 +82,7 @@ public void AddProductAttribute_ReturnExpectedValues() public void RemoveProductAttribute_ReturnExpectedValues() { var result = ProductExtensions.RemoveProductAttribute(customAtr, new ProductAttributeMapping { Id = "key1" }); - Assert.IsTrue(result.Count == 3); + Assert.HasCount(3, result); Assert.IsFalse(result.Any(c => c.Key.Equals("key1"))); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeServiceTests.cs index 2a14da1db..ea606f7d3 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeServiceTests.cs @@ -48,7 +48,7 @@ public async Task GetAllProductAttributesTest() var result = await _productAttributeService.GetAllProductAttributes(); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } [TestMethod] @@ -92,7 +92,7 @@ public async Task UpdateProductAttributeTest() //Act await _productAttributeService.UpdateProductAttribute(pa1); //Assert - Assert.IsTrue(_repositoryproductAttribute.Table.FirstOrDefault().Name == "test"); + Assert.AreEqual("test", _repositoryproductAttribute.Table.FirstOrDefault().Name); } [TestMethod] @@ -125,7 +125,7 @@ public async Task DeleteProductAttributeMappingTest() //Act await _productAttributeService.DeleteProductAttributeMapping(pm1, product.Id); //Assert - Assert.AreEqual(2, _repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeMappings.Count); + Assert.HasCount(2, _repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeMappings); } [TestMethod] @@ -139,7 +139,7 @@ public async Task InsertProductAttributeMappingTest() //Act await _productAttributeService.InsertProductAttributeMapping(pm1, product.Id); //Assert - Assert.AreEqual(1, _repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeMappings.Count); + Assert.HasCount(1, _repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeMappings); } [TestMethod] @@ -154,8 +154,8 @@ public async Task UpdateProductAttributeMappingTest() pm1.TextPrompt = "test"; await _productAttributeService.UpdateProductAttributeMapping(pm1, product.Id); //Assert - Assert.IsTrue(_repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeMappings - .FirstOrDefault(x => x.Id == pm1.Id).TextPrompt == "test"); + Assert.AreEqual("test", _repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeMappings + .FirstOrDefault(x => x.Id == pm1.Id).TextPrompt); } [TestMethod] @@ -174,9 +174,9 @@ public async Task DeleteProductAttributeValueTest() //Act await _productAttributeService.DeleteProductAttributeValue(pav1, product.Id, pm1.Id); //Assert - Assert.AreEqual(1, + Assert.HasCount(1, _repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeMappings - .FirstOrDefault(x => x.Id == pm1.Id).ProductAttributeValues.Count); + .FirstOrDefault(x => x.Id == pm1.Id).ProductAttributeValues); } [TestMethod] @@ -192,9 +192,9 @@ public async Task InsertProductAttributeValueTest() //Act await _productAttributeService.InsertProductAttributeValue(pav1, product.Id, pm1.Id); //Assert - Assert.AreEqual(1, + Assert.HasCount(1, _repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeMappings - .FirstOrDefault(x => x.Id == pm1.Id).ProductAttributeValues.Count); + .FirstOrDefault(x => x.Id == pm1.Id).ProductAttributeValues); } [TestMethod] @@ -213,8 +213,8 @@ public async Task UpdateProductAttributeValueTest() await _productAttributeService.UpdateProductAttributeValue(pav1, product.Id, pm1.Id); //Assert - Assert.IsTrue(_repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeMappings - .FirstOrDefault(x => x.Id == pm1.Id).ProductAttributeValues.FirstOrDefault().Name == "test"); + Assert.AreEqual("test", _repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeMappings + .FirstOrDefault(x => x.Id == pm1.Id).ProductAttributeValues.FirstOrDefault().Name); } @@ -234,8 +234,8 @@ public async Task DeleteProductAttributeCombinationTest() //Act await _productAttributeService.DeleteProductAttributeCombination(pac1, product.Id); //Assert - Assert.AreEqual(2, - _repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeCombinations.Count); + Assert.HasCount(2, + _repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeCombinations); } [TestMethod] @@ -248,8 +248,8 @@ public async Task InsertProductAttributeCombinationTest() //Act await _productAttributeService.InsertProductAttributeCombination(pac1, product.Id); //Assert - Assert.AreEqual(1, - _repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeCombinations.Count); + Assert.HasCount(1, + _repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeCombinations); } [TestMethod] @@ -264,7 +264,7 @@ public async Task UpdateProductAttributeCombinationTest() pac1.Text = "test"; await _productAttributeService.UpdateProductAttributeCombination(pac1, product.Id); //Assert - Assert.IsTrue(_repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeCombinations - .FirstOrDefault(x => x.Id == pac1.Id).Text == "test"); + Assert.AreEqual("test", _repository.Table.FirstOrDefault(x => x.Id == product.Id).ProductAttributeCombinations + .FirstOrDefault(x => x.Id == pac1.Id).Text); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductLayoutServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductLayoutServiceTests.cs index 5f2e5ece3..8dd4f78c0 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductLayoutServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductLayoutServiceTests.cs @@ -43,7 +43,7 @@ public async Task GetAllProductLayoutsTest() var layouts = await _productLayoutService.GetAllProductLayouts(); //Assert - Assert.AreEqual(3, layouts.Count); + Assert.HasCount(3, layouts); } [TestMethod] diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductReservationServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductReservationServiceTests.cs index 0acadd75b..eb2542cd4 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductReservationServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductReservationServiceTests.cs @@ -38,7 +38,7 @@ public async Task GetProductReservationsByProductIdTest() //Act var result = await _service.GetProductReservationsByProductId("1", null, null); - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } [TestMethod] @@ -149,7 +149,7 @@ public async Task GetCustomerReservationsHelpersTest() var result = await _service.GetCustomerReservationsHelpers("1"); //Assert Assert.IsNotNull(result); - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } [TestMethod] @@ -165,6 +165,6 @@ await _repositoryCustomerReservationsHelper.InsertAsync(new CustomerReservations var result = await _service.GetCustomerReservationsHelperBySciId("1"); //Assert Assert.IsNotNull(result); - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductReviewServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductReviewServiceTests.cs index e6da3d11d..904995b35 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductReviewServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductReviewServiceTests.cs @@ -38,7 +38,7 @@ public async Task GetAllProductReviewsTest() var result = await _productReviewService.GetAllProductReviews("1", null); //Assert - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } [TestMethod] diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.cs index dce7a3060..9305e18cd 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.cs @@ -83,7 +83,7 @@ public async Task GetAllProductsDisplayedOnHomePageTest() var result = await _productService.GetAllProductsDisplayedOnHomePage(); //Assert - Assert.IsTrue(result.Count == 2); + Assert.HasCount(2, result); } [TestMethod] @@ -96,7 +96,7 @@ public async Task GetAllProductsDisplayedOnBestSellerTest() var result = await _productService.GetAllProductsDisplayedOnBestSeller(); //Assert - Assert.IsTrue(result.Count == 2); + Assert.HasCount(2, result); } [TestMethod] @@ -143,7 +143,7 @@ public async Task GetProductsByIdsTest() var result = await _productService.GetProductsByIds(["1"]); //Assert - Assert.IsTrue(result.Count > 0); + Assert.IsNotEmpty(result); } [TestMethod] @@ -156,7 +156,7 @@ public async Task GetProductsByDiscountTest() var result = await _productService.GetProductsByDiscount("1"); //Assert - Assert.IsTrue(result.Count > 0); + Assert.IsNotEmpty(result); } [TestMethod] @@ -187,7 +187,7 @@ public async Task UpdateProductTest() //Assert Assert.IsNotNull(result); - Assert.IsTrue(result.Name == "test2"); + Assert.AreEqual("test2", result.Name); } [TestMethod] @@ -230,7 +230,7 @@ public async Task GetCategoryProductNumberTest() var result = _productService.GetCategoryProductNumber(new Customer(), ["1"]); //Assert - Assert.IsTrue(result == 1); + Assert.AreEqual(1, result); } [TestMethod] @@ -248,7 +248,7 @@ public async Task GetProductsByProductAtributeIdTest() var result = await _productService.GetProductsByProductAttributeId("1"); //Assert - Assert.IsTrue(result.Count > 0); + Assert.IsNotEmpty(result); } [TestMethod] @@ -260,7 +260,7 @@ public async Task GetAssociatedProductsTest() var result = await _productService.GetAssociatedProducts("1"); //Assert - Assert.IsTrue(result.Count > 0); + Assert.IsNotEmpty(result); } [TestMethod] @@ -339,7 +339,7 @@ public async Task InsertRelatedProductTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.RelatedProducts.Count); + Assert.HasCount(1, result.RelatedProducts); } [TestMethod] @@ -357,7 +357,7 @@ public async Task DeleteRelatedProductTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(0, result.RelatedProducts.Count); + Assert.IsEmpty(result.RelatedProducts); } [TestMethod] @@ -376,7 +376,7 @@ public async Task UpdateRelatedProductTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.RelatedProducts.Count); + Assert.HasCount(1, result.RelatedProducts); Assert.AreEqual(10, result.RelatedProducts.FirstOrDefault().DisplayOrder); } @@ -396,7 +396,7 @@ await _productService.InsertSimilarProduct(new SimilarProduct { //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.SimilarProducts.Count); + Assert.HasCount(1, result.SimilarProducts); } [TestMethod] @@ -415,7 +415,7 @@ public async Task UpdateSimilarProductTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.SimilarProducts.Count); + Assert.HasCount(1, result.SimilarProducts); Assert.AreEqual(10, result.SimilarProducts.FirstOrDefault().DisplayOrder); } @@ -434,7 +434,7 @@ public async Task DeleteSimilarProductTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(0, result.SimilarProducts.Count); + Assert.IsEmpty(result.SimilarProducts); } [TestMethod] @@ -452,7 +452,7 @@ await _productService.InsertBundleProduct(new BundleProduct { //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.BundleProducts.Count); + Assert.HasCount(1, result.BundleProducts); } [TestMethod] @@ -471,7 +471,7 @@ public async Task UpdateBundleProductTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.BundleProducts.Count); + Assert.HasCount(1, result.BundleProducts); Assert.AreEqual(10, result.BundleProducts.FirstOrDefault().Quantity); } @@ -490,7 +490,7 @@ public async Task DeleteBundleProductTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(0, result.BundleProducts.Count); + Assert.IsEmpty(result.BundleProducts); } [TestMethod] @@ -510,7 +510,7 @@ await _productService.InsertCrossSellProduct(new CrossSellProduct { //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.CrossSellProduct.Count); + Assert.HasCount(1, result.CrossSellProduct); } [TestMethod] @@ -532,7 +532,7 @@ public async Task DeleteCrossSellProductTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(0, result.CrossSellProduct.Count); + Assert.IsEmpty(result.CrossSellProduct); } [TestMethod] @@ -562,7 +562,7 @@ await _productService.GetCrossSellProductsByShoppingCart( //Assert Assert.IsNotNull(result); - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } [TestMethod] @@ -579,7 +579,7 @@ public async Task InsertRecommendedProductTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.RecommendedProduct.Count); + Assert.HasCount(1, result.RecommendedProduct); } [TestMethod] @@ -596,7 +596,7 @@ public async Task DeleteRecommendedProductTest() var result = await _productService.GetProductById(product.Id); //Assert - Assert.AreEqual(0, result.RecommendedProduct.Count); + Assert.IsEmpty(result.RecommendedProduct); } [TestMethod] @@ -613,7 +613,7 @@ public async Task InsertTierPriceTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.TierPrices.Count); + Assert.HasCount(1, result.TierPrices); } [TestMethod] @@ -632,7 +632,7 @@ public async Task UpdateTierPriceTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.TierPrices.Count); + Assert.HasCount(1, result.TierPrices); Assert.AreEqual(10, result.TierPrices.FirstOrDefault().Quantity); } @@ -651,7 +651,7 @@ public async Task DeleteTierPriceTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(0, result.TierPrices.Count); + Assert.IsEmpty(result.TierPrices); } [TestMethod] @@ -669,7 +669,7 @@ public async Task InsertProductPriceTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.ProductPrices.Count); + Assert.HasCount(1, result.ProductPrices); } [TestMethod] @@ -689,7 +689,7 @@ public async Task UpdateProductPriceTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.ProductPrices.Count); + Assert.HasCount(1, result.ProductPrices); Assert.AreEqual("EUR", result.ProductPrices.FirstOrDefault().CurrencyCode); } @@ -709,7 +709,7 @@ public async Task DeleteProductPriceTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(0, result.ProductPrices.Count); + Assert.IsEmpty(result.ProductPrices); } [TestMethod] @@ -727,7 +727,7 @@ public async Task InsertProductPictureTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.ProductPictures.Count); + Assert.HasCount(1, result.ProductPictures); } [TestMethod] @@ -747,7 +747,7 @@ public async Task UpdateProductPictureTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.ProductPictures.Count); + Assert.HasCount(1, result.ProductPictures); Assert.AreEqual("2", result.ProductPictures.FirstOrDefault().PictureId); } @@ -767,7 +767,7 @@ public async Task DeleteProductPictureTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(0, result.ProductPictures.Count); + Assert.IsEmpty(result.ProductPictures); } [TestMethod] @@ -785,7 +785,7 @@ public async Task InsertProductWarehouseInventoryTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.ProductWarehouseInventory.Count); + Assert.HasCount(1, result.ProductWarehouseInventory); } [TestMethod] @@ -805,7 +805,7 @@ public async Task UpdateProductWarehouseInventoryTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.ProductWarehouseInventory.Count); + Assert.HasCount(1, result.ProductWarehouseInventory); Assert.AreEqual("2", result.ProductWarehouseInventory.FirstOrDefault().WarehouseId); } @@ -825,7 +825,7 @@ public async Task DeleteProductWarehouseInventoryTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(0, result.ProductWarehouseInventory.Count); + Assert.IsEmpty(result.ProductWarehouseInventory); } [TestMethod] @@ -843,7 +843,7 @@ public async Task DeleteDiscountTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(0, result.AppliedDiscounts.Count); + Assert.IsEmpty(result.AppliedDiscounts); } [TestMethod] @@ -860,6 +860,6 @@ public async Task InsertDiscountTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.AppliedDiscounts.Count); + Assert.HasCount(1, result.AppliedDiscounts); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductTagServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductTagServiceTests.cs index f3fd767e5..5dbf11d26 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductTagServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductTagServiceTests.cs @@ -44,7 +44,7 @@ public async Task GetAllProductTagsTest() var result = await _productTagService.GetAllProductTags(); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } [TestMethod] diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/RecentlyViewedProductsServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/RecentlyViewedProductsServiceTests.cs index 67d3442d2..3403dd54b 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/RecentlyViewedProductsServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/RecentlyViewedProductsServiceTests.cs @@ -53,7 +53,7 @@ public async Task GetRecentlyViewedProductsTest() var result = await _service.GetRecentlyViewedProducts("1", 10); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } [TestMethod] diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/SpecificationAttributeServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/SpecificationAttributeServiceTests.cs index ceb434dc3..3b7422f54 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/SpecificationAttributeServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/SpecificationAttributeServiceTests.cs @@ -88,7 +88,7 @@ public async Task GetSpecificationAttributesTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } [TestMethod] @@ -179,9 +179,8 @@ public async Task DeleteSpecificationAttributeOptionTest() await service.DeleteSpecificationAttributeOption(attr); //Assert - Assert.AreEqual(0, - _repository.Table.FirstOrDefault(x => x.Id == specificationAttribute.Id).SpecificationAttributeOptions - .Count); + Assert.IsEmpty( + _repository.Table.FirstOrDefault(x => x.Id == specificationAttribute.Id).SpecificationAttributeOptions); } [TestMethod] @@ -197,8 +196,8 @@ public async Task InsertProductSpecificationAttributeTest() await service.InsertProductSpecificationAttribute(attr, product.Id); //Assert - Assert.AreEqual(1, - _repositoryProduct.Table.FirstOrDefault(x => x.Id == product.Id).ProductSpecificationAttributes.Count); + Assert.HasCount(1, + _repositoryProduct.Table.FirstOrDefault(x => x.Id == product.Id).ProductSpecificationAttributes); } [TestMethod] @@ -234,8 +233,8 @@ public async Task DeleteProductSpecificationAttributeTest() await service.DeleteProductSpecificationAttribute(attr, product.Id); //Assert - Assert.AreEqual(0, - _repositoryProduct.Table.FirstOrDefault(x => x.Id == product.Id).ProductSpecificationAttributes.Count); + Assert.IsEmpty( + _repositoryProduct.Table.FirstOrDefault(x => x.Id == product.Id).ProductSpecificationAttributes); } [TestMethod] diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/StockQuantityServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/StockQuantityServiceTests.cs index 2dd66f38e..a476c84b9 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/StockQuantityServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/StockQuantityServiceTests.cs @@ -177,7 +177,7 @@ public void FormatStockMessageTest_ManageStock_StockAvailability_InStock() //Act var result = _stockQuantityService.FormatStockMessage(product, "", new List()); //Assert - Assert.AreEqual(null, result.arg0); + Assert.IsNull(result.arg0); Assert.AreEqual("Products.Availability.InStock", result.resource); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Tax/TaxCategoryServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Tax/TaxCategoryServiceTests.cs index e30af4467..6da3c5893 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Tax/TaxCategoryServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Tax/TaxCategoryServiceTests.cs @@ -43,7 +43,7 @@ public async Task GetAllTaxCategoriesTest() var result = await _taxCategoryService.GetAllTaxCategories(); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } [TestMethod] @@ -68,7 +68,7 @@ public async Task InsertTaxCategoryTest() //Act await _taxCategoryService.InsertTaxCategory(new TaxCategory()); //Assert - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); } [TestMethod] @@ -102,6 +102,6 @@ public async Task DeleteTaxCategoryTest() //Assert Assert.IsNull(_repository.Table.FirstOrDefault(x => x.Name == "test")); - Assert.AreEqual(1, _repository.Table.Count()); + Assert.HasCount(1, _repository.Table); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Catalog.Tests/Startup/StartupApplicationTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Startup/StartupApplicationTests.cs index 22fb681d7..fc9be064a 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Startup/StartupApplicationTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Startup/StartupApplicationTests.cs @@ -26,6 +26,6 @@ public void ConfigureServicesTest() //Act _application.ConfigureServices(_serviceCollection, _configuration); //Assert - Assert.IsTrue(_serviceCollection.Count > 0); + Assert.IsGreaterThan(0, _serviceCollection.Count); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs index b3745854f..b683294ba 100644 --- a/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs +++ b/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs @@ -146,12 +146,12 @@ public void Can_add_checkoutAttributes() //custom text attributes = _checkoutAttributeParser.AddCheckoutAttribute(attributes, ca3, "absolutely any value").ToList(); - Assert.IsTrue(attributes.Count == 4); + Assert.HasCount(4, attributes); Assert.IsTrue(attributes.Any(c => c.Key.Equals(ca1.Id))); Assert.IsTrue(attributes.Any(c => c.Key.Equals(ca2.Id))); Assert.IsTrue(attributes.Any(c => c.Key.Equals(ca3.Id))); attributes = _checkoutAttributeParser.RemoveCheckoutAttribute(attributes, ca1); - Assert.IsTrue(attributes.Count == 3); + Assert.HasCount(3, attributes); Assert.IsFalse(attributes.Any(c => c.Key.Equals(ca1.Id))); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/LoyaltyPointsServiceTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/LoyaltyPointsServiceTests.cs index de472b712..8099a53c2 100644 --- a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/LoyaltyPointsServiceTests.cs +++ b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/LoyaltyPointsServiceTests.cs @@ -53,7 +53,7 @@ public async Task AddLoyaltyPointsHistoryTest() //Assert Assert.IsNotNull(result); Assert.AreEqual(10, result.Points); - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); } [TestMethod] @@ -69,6 +69,6 @@ await _repository.InsertAsync(new LoyaltyPointsHistory //Act var result = await _loyaltyPointsService.GetLoyaltyPointsHistory("1"); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/MerchandiseReturnServiceTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/MerchandiseReturnServiceTests.cs index 155a6dad3..070f0c08d 100644 --- a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/MerchandiseReturnServiceTests.cs +++ b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/MerchandiseReturnServiceTests.cs @@ -86,7 +86,7 @@ public async Task SearchMerchandiseReturnsTest() var result = await _merchandiseReturnService.SearchMerchandiseReturns(); //Assert - Assert.IsTrue(result.Any()); + Assert.IsNotEmpty(result); } [TestMethod] @@ -100,8 +100,8 @@ public async Task GetAllMerchandiseReturnActionsTest() var result = await _merchandiseReturnService.GetAllMerchandiseReturnActions(); //Assert - Assert.IsTrue(result.Any()); - Assert.AreEqual(2, result.Count); + Assert.IsNotEmpty(result); + Assert.HasCount(2, result); } [TestMethod] @@ -125,7 +125,7 @@ public async Task InsertMerchandiseReturnTest() await _merchandiseReturnService.InsertMerchandiseReturn(new MerchandiseReturn()); //Assert - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); } [TestMethod] @@ -140,7 +140,7 @@ public async Task UpdateMerchandiseReturnTest() await _merchandiseReturnService.UpdateMerchandiseReturn(merchandiseReturn); //Assert - Assert.IsTrue(_repository.Table.FirstOrDefault(x => x.Id == merchandiseReturn.Id).CustomerComments == "test"); + Assert.AreEqual("test", _repository.Table.FirstOrDefault(x => x.Id == merchandiseReturn.Id).CustomerComments); } [TestMethod] @@ -154,7 +154,7 @@ public async Task DeleteMerchandiseReturnTest() await _merchandiseReturnService.DeleteMerchandiseReturn(merchandiseReturn); //Assert - Assert.IsFalse(_repository.Table.Any()); + Assert.IsEmpty(_repository.Table); } [TestMethod] @@ -164,7 +164,7 @@ public async Task InsertMerchandiseReturnActionTest() await _merchandiseReturnService.InsertMerchandiseReturnAction(new MerchandiseReturnAction()); //Assert - Assert.IsTrue(_merchandiseReturnActionRepository.Table.Any()); + Assert.IsNotEmpty(_merchandiseReturnActionRepository.Table); } [TestMethod] @@ -179,8 +179,8 @@ public async Task UpdateMerchandiseReturnActionTest() await _merchandiseReturnService.UpdateMerchandiseReturnAction(merchandiseReturnAction); //Assert - Assert.IsTrue(_merchandiseReturnActionRepository.Table.FirstOrDefault(x => x.Id == merchandiseReturnAction.Id) - .Name == "test"); + Assert.AreEqual("test", _merchandiseReturnActionRepository.Table.FirstOrDefault(x => x.Id == merchandiseReturnAction.Id) + .Name); } [TestMethod] @@ -194,7 +194,7 @@ public async Task DeleteMerchandiseReturnActionTest() await _merchandiseReturnService.DeleteMerchandiseReturnAction(merchandiseReturnAction); //Assert - Assert.IsFalse(_merchandiseReturnActionRepository.Table.Any()); + Assert.IsEmpty(_merchandiseReturnActionRepository.Table); } [TestMethod] @@ -208,7 +208,7 @@ public async Task DeleteMerchandiseReturnReasonTest() await _merchandiseReturnService.DeleteMerchandiseReturnReason(merchandiseReturnReason); //Assert - Assert.IsFalse(_merchandiseReturnReasonRepository.Table.Any()); + Assert.IsEmpty(_merchandiseReturnReasonRepository.Table); } [TestMethod] @@ -222,7 +222,7 @@ public async Task GetAllMerchandiseReturnReasonsTest() var result = await _merchandiseReturnService.GetAllMerchandiseReturnReasons(); //Assert - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } [TestMethod] @@ -249,7 +249,7 @@ public async Task InsertMerchandiseReturnReasonTest() await _merchandiseReturnService.InsertMerchandiseReturnReason(merchandiseReturnReason); //Assert - Assert.IsTrue(_merchandiseReturnReasonRepository.Table.Any()); + Assert.IsNotEmpty(_merchandiseReturnReasonRepository.Table); } [TestMethod] @@ -263,8 +263,8 @@ public async Task UpdateMerchandiseReturnReasonTest() await _merchandiseReturnService.UpdateMerchandiseReturnReason(merchandiseReturnReason); //Assert - Assert.IsTrue(_merchandiseReturnReasonRepository.Table.FirstOrDefault(x => x.Id == merchandiseReturnReason.Id) - .Name == "test"); + Assert.AreEqual("test", _merchandiseReturnReasonRepository.Table.FirstOrDefault(x => x.Id == merchandiseReturnReason.Id) + .Name); } [TestMethod] @@ -278,7 +278,7 @@ public async Task DeleteMerchandiseReturnNoteTest() await _merchandiseReturnService.DeleteMerchandiseReturnNote(merchandiseReturnNote); //Assert - Assert.IsFalse(_merchandiseReturnNoteRepository.Table.Any()); + Assert.IsEmpty(_merchandiseReturnNoteRepository.Table); } [TestMethod] @@ -291,7 +291,7 @@ public async Task InsertMerchandiseReturnNoteTest() await _merchandiseReturnService.InsertMerchandiseReturnNote(merchandiseReturnNote); //Assert - Assert.IsTrue(_merchandiseReturnNoteRepository.Table.Any()); + Assert.IsNotEmpty(_merchandiseReturnNoteRepository.Table); } [TestMethod] @@ -305,7 +305,7 @@ public async Task GetMerchandiseReturnNotesTest() var result = await _merchandiseReturnService.GetMerchandiseReturnNotes("1"); //Assert - Assert.AreEqual(1, result.Count); + Assert.HasCount(1, result); } [TestMethod] diff --git a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/OrderTagServiceTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/OrderTagServiceTests.cs index bad79cf45..cdfd4c615 100644 --- a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/OrderTagServiceTests.cs +++ b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/OrderTagServiceTests.cs @@ -46,7 +46,7 @@ public async Task GetAllOrderTagsTest() var result = await _service.GetAllOrderTags(); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } [TestMethod] @@ -86,7 +86,7 @@ public async Task InsertOrderTagTest() await _service.InsertOrderTag(new OrderTag()); //Assert - Assert.IsTrue(_orderTagRepository.Table.Any()); + Assert.IsNotEmpty(_orderTagRepository.Table); } [TestMethod] @@ -101,7 +101,7 @@ public async Task UpdateOrderTagTest() await _service.UpdateOrderTag(orderTag); //Assert - Assert.IsTrue(_orderTagRepository.Table.FirstOrDefault(x => x.Id == orderTag.Id).Name == "test"); + Assert.AreEqual("test", _orderTagRepository.Table.FirstOrDefault(x => x.Id == orderTag.Id).Name); } [TestMethod] @@ -115,7 +115,7 @@ public async Task DeleteOrderTagTest() await _service.DeleteOrderTag(orderTag); //Assert - Assert.IsFalse(_orderTagRepository.Table.FirstOrDefault(x => x.Id == orderTag.Id)?.Name == "test"); + Assert.AreNotEqual("test", _orderTagRepository.Table.FirstOrDefault(x => x.Id == orderTag.Id)?.Name); } [TestMethod] @@ -133,7 +133,7 @@ public async Task AttachOrderTagTest() //Assert Assert.IsTrue(_orderRepository.Table.FirstOrDefault(x => x.Id == order.Id).OrderTags .Any(z => z == orderTag.Id)); - Assert.IsTrue(_orderTagRepository.Table.FirstOrDefault(x => x.Id == orderTag.Id).Count == 1); + Assert.AreEqual(1, _orderTagRepository.Table.FirstOrDefault(x => x.Id == orderTag.Id).Count); } [TestMethod] @@ -153,7 +153,7 @@ public async Task DetachOrderTagTest() //Assert Assert.IsFalse( _orderRepository.Table.FirstOrDefault(x => x.Id == order.Id).OrderTags.Any(z => z == orderTag.Id)); - Assert.IsTrue(_orderTagRepository.Table.FirstOrDefault(x => x.Id == orderTag.Id).Count == 0); + Assert.AreEqual(0, _orderTagRepository.Table.FirstOrDefault(x => x.Id == orderTag.Id).Count); } [TestMethod] diff --git a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/ShoppingCartServiceTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/ShoppingCartServiceTests.cs index 5034bb46e..a096302ef 100644 --- a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/ShoppingCartServiceTests.cs +++ b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/ShoppingCartServiceTests.cs @@ -65,7 +65,7 @@ public async Task GetShoppingCartTest() //Act var result = await _shoppingCartService.GetShoppingCart(); //Assert - Assert.IsTrue(result.Any()); + Assert.IsNotEmpty(result); } [TestMethod] @@ -138,7 +138,7 @@ public async Task AddToCartTest_Warning() var result = await _shoppingCartService.AddToCart(customer, "2", ShoppingCartType.ShoppingCart, ""); //Assert - Assert.AreEqual(1, result.warnings.Count); + Assert.HasCount(1, result.warnings); } [TestMethod] @@ -217,7 +217,7 @@ public async Task MigrateShoppingCartTest() //Act await _shoppingCartService.MigrateShoppingCart(customer, customer2, false); //Assert - Assert.IsTrue(customer2.ShoppingCartItems.Any()); - Assert.IsFalse(customer.ShoppingCartItems.Any()); + Assert.IsNotEmpty(customer2.ShoppingCartItems); + Assert.IsEmpty(customer.ShoppingCartItems); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Checkout.Tests/Services/Payments/PaymentServiceTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Services/Payments/PaymentServiceTests.cs index 4143dfad9..517e4a3b5 100644 --- a/src/Tests/Grand.Business.Checkout.Tests/Services/Payments/PaymentServiceTests.cs +++ b/src/Tests/Grand.Business.Checkout.Tests/Services/Payments/PaymentServiceTests.cs @@ -38,7 +38,7 @@ public void LoadPaymentMethodBySystemName_ReturnPeyment() _paymentProviderMock.Setup(c => c.SystemName).Returns("systemName"); var systemName = "systemName"; var result = _paymentService.LoadPaymentMethodBySystemName(systemName); - Assert.AreEqual(result, _paymentProviderMock.Object); + Assert.AreEqual(_paymentProviderMock.Object, result); } [TestMethod] @@ -64,7 +64,7 @@ public async Task GetRestrictedCountryIds_ReturnEmptyList() .Returns(() => Task.FromResult((PaymentRestrictedSettings)null)); var result = await _paymentService.GetRestrictedCountryIds(_paymentProviderMock.Object); - Assert.IsTrue(result.Count == 0); + Assert.IsEmpty(result); _settingService.Verify(s => s.GetSettingByKey(expectedKey, null, ""), Times.Once); } @@ -88,7 +88,7 @@ public async Task ProcessPayment_OrderTotalZero_ReturnPaidPaymentStatus() TransactionAmount = 0 }; var response = await _paymentService.ProcessPayment(request); - Assert.IsTrue(response.NewPaymentTransactionStatus == TransactionStatus.Paid); + Assert.AreEqual(TransactionStatus.Paid, response.NewPaymentTransactionStatus); } [TestMethod] diff --git a/src/Tests/Grand.Business.Checkout.Tests/Services/Shipping/ShippingServiceTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Services/Shipping/ShippingServiceTests.cs index 34486b9de..4c9031467 100644 --- a/src/Tests/Grand.Business.Checkout.Tests/Services/Shipping/ShippingServiceTests.cs +++ b/src/Tests/Grand.Business.Checkout.Tests/Services/Shipping/ShippingServiceTests.cs @@ -44,7 +44,7 @@ public async Task LoadActiveShippingRateCalculationProviders_IsLimitToStore_Retu _rateProviderMock.Setup(c => c.LimitedToStores).Returns(new List()); _rateProviderMock.Setup(c => c.LimitedToGroups).Returns(new List()); var result = await _service.LoadActiveShippingRateCalculationProviders(new Customer(), "storeId"); - Assert.IsTrue(result.Count == 0); + Assert.IsEmpty(result); } [TestMethod] @@ -54,7 +54,7 @@ public async Task LoadActiveShippingRateCalculationProviders_HideShipmentMethods _rateProviderMock.Setup(c => c.LimitedToGroups).Returns(new List()); _rateProviderMock.Setup(c => c.HideShipmentMethods(It.IsAny>())).ReturnsAsync(true); var result = await _service.LoadActiveShippingRateCalculationProviders(new Customer(), "storeId"); - Assert.IsTrue(result.Count == 0); + Assert.IsEmpty(result); } [TestMethod] @@ -66,7 +66,7 @@ public async Task LoadActiveShippingRateCalculationProviders_ReturnExpectedValue _rateProviderMock.Setup(c => c.SystemName).Returns("sysname"); _rateProviderMock.Setup(c => c.HideShipmentMethods(It.IsAny>())).ReturnsAsync(false); var result = await _service.LoadActiveShippingRateCalculationProviders(new Customer(), "storeId"); - Assert.IsTrue(result.Count == 1); + Assert.HasCount(1, result); Assert.AreEqual(result.First().SystemName, _rateProviderMock.Object.SystemName); } @@ -89,9 +89,9 @@ public async Task CreateShippingOptionRequests_ReturnExpectedResults() var result = await _service.CreateShippingOptionRequests(customer, cart, shippingAddress, store); - Assert.AreEqual(result.ShippingAddress, shippingAddress); - Assert.AreEqual(result.StoreId, "id"); - Assert.AreEqual(result.Customer, customer); + Assert.AreEqual(shippingAddress, result.ShippingAddress); + Assert.AreEqual("id", result.StoreId); + Assert.AreEqual(customer, result.Customer); } [TestMethod] @@ -112,6 +112,6 @@ public async Task CreateShippingOptionRequests_ShipNotEnable_ReturnEmptyList() }; var result = await _service.CreateShippingOptionRequests(customer, cart, shippingAddress, store); - Assert.IsTrue(result != null); + Assert.IsNotNull(result); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Checkout.Tests/Startup/StartupApplicationTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Startup/StartupApplicationTests.cs index 9f2f6f233..59cfb6535 100644 --- a/src/Tests/Grand.Business.Checkout.Tests/Startup/StartupApplicationTests.cs +++ b/src/Tests/Grand.Business.Checkout.Tests/Startup/StartupApplicationTests.cs @@ -26,6 +26,6 @@ public void ConfigureServicesTest() //Act _application.ConfigureServices(_serviceCollection, _configuration); //Assert - Assert.IsTrue(_serviceCollection.Count > 0); + Assert.IsGreaterThan(0, _serviceCollection.Count); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Cms.Tests/Extensions/BlogExtensionsTests.cs b/src/Tests/Grand.Business.Cms.Tests/Extensions/BlogExtensionsTests.cs index 5d52aef07..437b7b765 100644 --- a/src/Tests/Grand.Business.Cms.Tests/Extensions/BlogExtensionsTests.cs +++ b/src/Tests/Grand.Business.Cms.Tests/Extensions/BlogExtensionsTests.cs @@ -26,7 +26,7 @@ public void GetPostsByDate_BlogPostContainsInDateRange() var from = DateTime.Now; var to = DateTime.Now.AddDays(3); var result = _blogPosts.GetPostsByDate(from, to); - Assert.AreEqual(4, result.Count); + Assert.HasCount(4, result); Assert.IsTrue(result.Any(b => b.Id.Equals("1"))); Assert.IsTrue(result.Any(b => b.Id.Equals("2"))); Assert.IsTrue(result.Any(b => b.Id.Equals("3"))); @@ -39,6 +39,6 @@ public void GetPostsByDate_BlogPostsNotContainsInDateRange_ReturnEmptyList() var from = DateTime.Now.AddDays(-3); var to = DateTime.Now.AddDays(-1); var result = _blogPosts.GetPostsByDate(from, to); - Assert.AreEqual(0, result.Count); + Assert.IsEmpty(result); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Cms.Tests/Services/CookiePreferenceTests.cs b/src/Tests/Grand.Business.Cms.Tests/Services/CookiePreferenceTests.cs index fced4b31f..2bd21ac2b 100644 --- a/src/Tests/Grand.Business.Cms.Tests/Services/CookiePreferenceTests.cs +++ b/src/Tests/Grand.Business.Cms.Tests/Services/CookiePreferenceTests.cs @@ -33,8 +33,8 @@ public void Init() public void GetConsentCookies_ReturnCorectOrder() { var result = _cookiePreferences.GetConsentCookies(); - Assert.IsTrue(result.First().DisplayOrder == 1); - Assert.IsTrue(result.Last().DisplayOrder == 2); + Assert.AreEqual(1, result.First().DisplayOrder); + Assert.AreEqual(2, result.Last().DisplayOrder); } [TestMethod] diff --git a/src/Tests/Grand.Business.Cms.Tests/Services/KnowledgebaseServiceTests.cs b/src/Tests/Grand.Business.Cms.Tests/Services/KnowledgebaseServiceTests.cs index 558737df6..4f460672e 100644 --- a/src/Tests/Grand.Business.Cms.Tests/Services/KnowledgebaseServiceTests.cs +++ b/src/Tests/Grand.Business.Cms.Tests/Services/KnowledgebaseServiceTests.cs @@ -69,9 +69,9 @@ public async Task UpdateKnowledgebaseCategoryTest() knowledgebaseCategory.Name = "test"; await _knowledgebaseService.UpdateKnowledgebaseCategory(knowledgebaseCategory); //Assert - Assert.IsTrue( - _repositoryKnowledgebaseCategory.Table.FirstOrDefault(x => x.Id == knowledgebaseCategory.Id).Name == - "test"); + Assert.AreEqual( + "test", + _repositoryKnowledgebaseCategory.Table.FirstOrDefault(x => x.Id == knowledgebaseCategory.Id).Name); } [TestMethod] @@ -167,8 +167,7 @@ public async Task UpdateKnowledgebaseArticleTest() knowledgebaseArticle.Name = "test"; await _knowledgebaseService.UpdateKnowledgebaseArticle(knowledgebaseArticle); //Assert - Assert.IsTrue(_repositoryKnowledgebaseArticle.Table.FirstOrDefault(x => x.Id == knowledgebaseArticle.Id).Name == - "test"); + Assert.AreEqual("test", _repositoryKnowledgebaseArticle.Table.FirstOrDefault(x => x.Id == knowledgebaseArticle.Id).Name); } [TestMethod] diff --git a/src/Tests/Grand.Business.Cms.Tests/Services/NewsServiceTests.cs b/src/Tests/Grand.Business.Cms.Tests/Services/NewsServiceTests.cs index fc3cf2889..47528fcfd 100644 --- a/src/Tests/Grand.Business.Cms.Tests/Services/NewsServiceTests.cs +++ b/src/Tests/Grand.Business.Cms.Tests/Services/NewsServiceTests.cs @@ -81,7 +81,7 @@ public async Task UpdateNewsTest() newsItem.Title = "test"; await _newsService.UpdateNews(newsItem); //Assert - Assert.IsTrue(_repository.Table.FirstOrDefault(x => x.Id == newsItem.Id).Title == "test"); + Assert.AreEqual("test", _repository.Table.FirstOrDefault(x => x.Id == newsItem.Id).Title); } [TestMethod] diff --git a/src/Tests/Grand.Business.Cms.Tests/Services/PageLayoutServiceTests.cs b/src/Tests/Grand.Business.Cms.Tests/Services/PageLayoutServiceTests.cs index b174ba0b5..dac559341 100644 --- a/src/Tests/Grand.Business.Cms.Tests/Services/PageLayoutServiceTests.cs +++ b/src/Tests/Grand.Business.Cms.Tests/Services/PageLayoutServiceTests.cs @@ -87,7 +87,7 @@ public async Task UpdatePageLayoutTest() pageLayout.Name = "test"; await _pageLayoutService.UpdatePageLayout(pageLayout); //Assert - Assert.IsTrue(_repository.Table.FirstOrDefault(x => x.Id == pageLayout.Id).Name == "test"); + Assert.AreEqual("test", _repository.Table.FirstOrDefault(x => x.Id == pageLayout.Id).Name); } [TestMethod] diff --git a/src/Tests/Grand.Business.Cms.Tests/Services/PageServiceTests.cs b/src/Tests/Grand.Business.Cms.Tests/Services/PageServiceTests.cs index e2abc9e9e..5927a31ee 100644 --- a/src/Tests/Grand.Business.Cms.Tests/Services/PageServiceTests.cs +++ b/src/Tests/Grand.Business.Cms.Tests/Services/PageServiceTests.cs @@ -104,7 +104,7 @@ public async Task UpdatePageTest() page.SystemName = "test"; await _pageService.UpdatePage(page); //Assert - Assert.IsTrue(_repository.Table.FirstOrDefault(x => x.Id == page.Id).SystemName == "test"); + Assert.AreEqual("test", _repository.Table.FirstOrDefault(x => x.Id == page.Id).SystemName); } [TestMethod] diff --git a/src/Tests/Grand.Business.Cms.Tests/Services/RobotsTxtServiceTests.cs b/src/Tests/Grand.Business.Cms.Tests/Services/RobotsTxtServiceTests.cs index a4d4c02d8..c09e13f0f 100644 --- a/src/Tests/Grand.Business.Cms.Tests/Services/RobotsTxtServiceTests.cs +++ b/src/Tests/Grand.Business.Cms.Tests/Services/RobotsTxtServiceTests.cs @@ -75,7 +75,7 @@ public async Task UpdateRobotsTxtTest() robotsTxt.Text = "test"; await _robotsTxtService.UpdateRobotsTxt(robotsTxt); //Assert - Assert.IsTrue(_repository.Table.FirstOrDefault(x => x.Id == robotsTxt.Id).Text == "test"); + Assert.AreEqual("test", _repository.Table.FirstOrDefault(x => x.Id == robotsTxt.Id).Text); } [TestMethod] diff --git a/src/Tests/Grand.Business.Cms.Tests/Services/WidgetServiceTests.cs b/src/Tests/Grand.Business.Cms.Tests/Services/WidgetServiceTests.cs index 4c0172440..483b2990b 100644 --- a/src/Tests/Grand.Business.Cms.Tests/Services/WidgetServiceTests.cs +++ b/src/Tests/Grand.Business.Cms.Tests/Services/WidgetServiceTests.cs @@ -33,7 +33,7 @@ public void LoadActiveWidgets_SettingsNotContainsSystemName_ReturnEmptyList() { _settings.ActiveWidgetSystemNames = []; var result = _widgedService.LoadActiveWidgets(); - Assert.IsTrue(result.Count == 0); + Assert.IsEmpty(result); } [TestMethod] @@ -41,14 +41,14 @@ public void LoadActiveWidgets_SettingsContainsSystemName_ReturnList() { _settings.ActiveWidgetSystemNames = ["name1", "name2"]; var result = _widgedService.LoadActiveWidgets(); - Assert.IsTrue(result.Count == _settings.ActiveWidgetSystemNames.Count); + Assert.HasCount(_settings.ActiveWidgetSystemNames.Count, result); } [TestMethod] public async Task LoadActiveWidgetsByWidgetZone_EmptyWidgetZone_ReturnEmptyList() { var result = await _widgedService.LoadActiveWidgetsByWidgetZone(""); - Assert.IsTrue(result.Count == 0); + Assert.IsEmpty(result); } [TestMethod] @@ -56,7 +56,7 @@ public async Task LoadActiveWidgetsByWidgetZone() { _settings.ActiveWidgetSystemNames = ["name1", "name2"]; var result = await _widgedService.LoadActiveWidgetsByWidgetZone("widgetZone1"); - Assert.IsTrue(result.Count == 1); + Assert.HasCount(1, result); } [TestMethod] diff --git a/src/Tests/Grand.Business.Cms.Tests/Startup/StartupApplicationTests.cs b/src/Tests/Grand.Business.Cms.Tests/Startup/StartupApplicationTests.cs index 1f4a87f3b..f96692971 100644 --- a/src/Tests/Grand.Business.Cms.Tests/Startup/StartupApplicationTests.cs +++ b/src/Tests/Grand.Business.Cms.Tests/Startup/StartupApplicationTests.cs @@ -26,6 +26,6 @@ public void ConfigureServicesTest() //Act _application.ConfigureServices(_serviceCollection, _configuration); //Assert - Assert.IsTrue(_serviceCollection.Count > 0); + Assert.IsGreaterThan(0, _serviceCollection.Count); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Common.Tests/Extensions/SeoExtensionsTests.cs b/src/Tests/Grand.Business.Common.Tests/Extensions/SeoExtensionsTests.cs index b6a94da58..227e7a9f7 100644 --- a/src/Tests/Grand.Business.Common.Tests/Extensions/SeoExtensionsTests.cs +++ b/src/Tests/Grand.Business.Common.Tests/Extensions/SeoExtensionsTests.cs @@ -50,8 +50,8 @@ public void GetSeName_ReturnExpectedValue() [TestMethod] public void GenerateSlug_ReturnExpectedResult() { - Assert.AreEqual(SeoExtensions.GenerateSlug("iphone10plus", false, false, false), "iphone10plus"); - Assert.AreEqual(SeoExtensions.GenerateSlug("iphone 10 plus", false, false, false), "iphone-10-plus"); - Assert.AreEqual(SeoExtensions.GenerateSlug("iphOnE 10 Plus", false, false, false), "iphone-10-plus"); + Assert.AreEqual("iphone10plus", SeoExtensions.GenerateSlug("iphone10plus", false, false, false)); + Assert.AreEqual("iphone-10-plus", SeoExtensions.GenerateSlug("iphone 10 plus", false, false, false)); + Assert.AreEqual("iphone-10-plus", SeoExtensions.GenerateSlug("iphOnE 10 Plus", false, false, false)); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Common.Tests/Extensions/TranslateExtensionsTests.cs b/src/Tests/Grand.Business.Common.Tests/Extensions/TranslateExtensionsTests.cs index e9e60cb41..b11d21481 100644 --- a/src/Tests/Grand.Business.Common.Tests/Extensions/TranslateExtensionsTests.cs +++ b/src/Tests/Grand.Business.Common.Tests/Extensions/TranslateExtensionsTests.cs @@ -20,10 +20,10 @@ public void GetTranslation_ReturnExpectedValue() product.Locales.Add(new TranslationEntity { LanguageId = "PL", LocaleKey = "Name", LocaleValue = "PLName" }); product.Locales.Add(new TranslationEntity { LanguageId = "UK", LocaleKey = "Name", LocaleValue = "UKName" }); - Assert.AreEqual(product.GetTranslation(c => c.Name, "PL"), "PLName"); - Assert.AreEqual(product.GetTranslation(c => c.Name, "UK"), "UKName"); + Assert.AreEqual("PLName", product.GetTranslation(c => c.Name, "PL")); + Assert.AreEqual("UKName", product.GetTranslation(c => c.Name, "UK")); //if language dont exist return property value - Assert.AreEqual(product.GetTranslation(c => c.Name, "US"), "stname"); + Assert.AreEqual("stname", product.GetTranslation(c => c.Name, "US")); } [TestMethod] @@ -52,7 +52,7 @@ public void GetTranslationEnum_ReturnExpectedValue() ManageInventoryMethodId = ManageInventoryMethod.ManageStock }; var result = product.ManageInventoryMethodId.GetTranslationEnum(translationServiceMock.Object, "PL"); - Assert.AreEqual(result, "PLenum"); + Assert.AreEqual("PLenum", result); } [TestMethod] diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Addresses/AddressAttributeParserTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Addresses/AddressAttributeParserTests.cs index 6b132aa68..68dc5bebe 100644 --- a/src/Tests/Grand.Business.Common.Tests/Services/Addresses/AddressAttributeParserTests.cs +++ b/src/Tests/Grand.Business.Common.Tests/Services/Addresses/AddressAttributeParserTests.cs @@ -37,8 +37,8 @@ public async Task ParseAddressAttributes_ReturnExpectedValues() _atrService.Setup(c => c.GetAddressAttributeById("key2")) .Returns(Task.FromResult(new AddressAttribute { Id = "key2" })); var result = await _parser.ParseAddressAttributes(customAtr); - Assert.IsTrue(result.Count == 2); - Assert.IsTrue(result.First().Id.Equals("key1")); + Assert.HasCount(2, result); + Assert.AreEqual("key1", result.First().Id); } [TestMethod] @@ -46,7 +46,7 @@ public void AddAddressAttribute_ReturnExpectedValues() { var atr = new AddressAttribute { Id = "added" }; var result = _parser.AddAddressAttribute(customAtr, atr, "new-added-value"); - Assert.IsTrue(result.Count == 5); + Assert.HasCount(5, result); Assert.IsTrue(result.Any(c => c.Key.Equals("added"))); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Directory/CountryServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Directory/CountryServiceTests.cs index a775b3d31..c063279a0 100644 --- a/src/Tests/Grand.Business.Common.Tests/Services/Directory/CountryServiceTests.cs +++ b/src/Tests/Grand.Business.Common.Tests/Services/Directory/CountryServiceTests.cs @@ -40,7 +40,7 @@ public async Task GetAllCountriesTest() //Act var result = await _countryService.GetAllCountries(); //Assert - Assert.IsTrue(result.Count > 0); + Assert.IsNotEmpty(result); } [TestMethod] @@ -52,7 +52,7 @@ public async Task GetAllCountriesForBillingTest() //Act var result = await _countryService.GetAllCountriesForBilling(); //Assert - Assert.IsTrue(result.Count == 1); + Assert.HasCount(1, result); } [TestMethod] @@ -64,7 +64,7 @@ public async Task GetAllCountriesForShippingTest() //Act var result = await _countryService.GetAllCountriesForShipping(); //Assert - Assert.IsTrue(result.Count == 1); + Assert.HasCount(1, result); } [TestMethod] @@ -92,7 +92,7 @@ public async Task GetCountriesByIdsTest() //Act var result = await _countryService.GetCountriesByIds([country.Id]); //Assert - Assert.IsTrue(result.Count == 1); + Assert.HasCount(1, result); } [TestMethod] diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Directory/DateTimeServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Directory/DateTimeServiceTests.cs index e40359492..367a167e3 100644 --- a/src/Tests/Grand.Business.Common.Tests/Services/Directory/DateTimeServiceTests.cs +++ b/src/Tests/Grand.Business.Common.Tests/Services/Directory/DateTimeServiceTests.cs @@ -41,7 +41,7 @@ public void GetSystemTimeZonesTest() public void ConvertToUserTimeTest() { var usertime = _dateTimeService.ConvertToUserTime(new DateTime(01, 01, 01, 01, 00, 00, DateTimeKind.Utc)); - Assert.IsNotNull(usertime); + Assert.AreNotEqual(0, usertime.Ticks); //TODO Assert.AreEqual(new DateTime(01, 01, 01, 02, 00, 00), usertime); } @@ -50,7 +50,7 @@ public void ConvertToUserTimeTest() public void ConvertToUtcTimeTest() { var usertime = _dateTimeService.ConvertToUtcTime(new DateTime(01, 01, 01, 02, 00, 00), _timeZone); - Assert.IsNotNull(usertime); + Assert.AreNotEqual(0, usertime.Ticks); //TODO Assert.AreEqual(new DateTime(01, 01, 01, 01, 00, 00), usertime); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Directory/ExchangeRateServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Directory/ExchangeRateServiceTests.cs index 01ed8a007..a9b12830b 100644 --- a/src/Tests/Grand.Business.Common.Tests/Services/Directory/ExchangeRateServiceTests.cs +++ b/src/Tests/Grand.Business.Common.Tests/Services/Directory/ExchangeRateServiceTests.cs @@ -38,6 +38,6 @@ public void LoadBySystemName_ReturnExpectedValue() new ExchangeRateService(new List { provider.Object }, _settings); var result = exchangeRateService.LoadExchangeRateProviderBySystemName("sysname"); Assert.IsNotNull(result); - Assert.AreEqual(result.SystemName, "sysname"); + Assert.AreEqual("sysname", result.SystemName); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Directory/GroupServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Directory/GroupServiceTests.cs index a902531d1..0bd31e995 100644 --- a/src/Tests/Grand.Business.Common.Tests/Services/Directory/GroupServiceTests.cs +++ b/src/Tests/Grand.Business.Common.Tests/Services/Directory/GroupServiceTests.cs @@ -91,7 +91,7 @@ public async Task UpdateCustomerGroupTest() customerGroup.SystemName = systemName; await _groupService.UpdateCustomerGroup(customerGroup); //Assert - Assert.IsTrue(_repository.Table.FirstOrDefault(x => x.Id == customerGroup.Id).SystemName == systemName); + Assert.AreEqual(systemName, _repository.Table.FirstOrDefault(x => x.Id == customerGroup.Id).SystemName); } [TestMethod] @@ -216,6 +216,6 @@ public async Task GetAllByIdsTest() //Act var result = await _groupService.GetAllByIds([customerGroup.Id]); //Assert - Assert.AreEqual(1, result.Count); + Assert.HasCount(1, result); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Common.Tests/Services/ExportImport/CountryImportDataObjectTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/ExportImport/CountryImportDataObjectTests.cs index f0676c454..b07a6fa89 100644 --- a/src/Tests/Grand.Business.Common.Tests/Services/ExportImport/CountryImportDataObjectTests.cs +++ b/src/Tests/Grand.Business.Common.Tests/Services/ExportImport/CountryImportDataObjectTests.cs @@ -111,6 +111,6 @@ public async Task ExecuteTest_Import_Insert_Update_States() //Assert Assert.IsTrue(_repository.Table.FirstOrDefault(x => x.Id == country.Id).StateProvinces.Any(x => x.Published)); - Assert.IsTrue(_repository.Table.FirstOrDefault(x => x.Id == country.Id).StateProvinces.Count == 3); + Assert.HasCount(3, _repository.Table.FirstOrDefault(x => x.Id == country.Id).StateProvinces); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Localization/LanguageServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Localization/LanguageServiceTests.cs index 73822d204..d791134ef 100644 --- a/src/Tests/Grand.Business.Common.Tests/Services/Localization/LanguageServiceTests.cs +++ b/src/Tests/Grand.Business.Common.Tests/Services/Localization/LanguageServiceTests.cs @@ -41,7 +41,7 @@ public async Task GetAllLanguagesTest() //Act var result = await _languageService.GetAllLanguages(); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } [TestMethod] @@ -93,7 +93,7 @@ public async Task UpdateLanguageTest() language.FlagImageFileName = "en.png"; await _languageService.UpdateLanguage(language); //Assert - Assert.IsTrue(_repository.Table.FirstOrDefault(x => x.Id == language.Id).FlagImageFileName == "en.png"); + Assert.AreEqual("en.png", _repository.Table.FirstOrDefault(x => x.Id == language.Id).FlagImageFileName); } [TestMethod] diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Localization/TranslationServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Localization/TranslationServiceTests.cs index 1b125d686..99755b90a 100644 --- a/src/Tests/Grand.Business.Common.Tests/Services/Localization/TranslationServiceTests.cs +++ b/src/Tests/Grand.Business.Common.Tests/Services/Localization/TranslationServiceTests.cs @@ -79,7 +79,7 @@ await _translationService.InsertTranslateResource(new TranslationResource var result = _translationService.GetAllResources("1"); //Assert - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } [TestMethod] diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Seo/SlugServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Seo/SlugServiceTests.cs index 054d9095c..3a52d1db6 100644 --- a/src/Tests/Grand.Business.Common.Tests/Services/Seo/SlugServiceTests.cs +++ b/src/Tests/Grand.Business.Common.Tests/Services/Seo/SlugServiceTests.cs @@ -65,7 +65,7 @@ public async Task UpdateEntityUrlTest() entity.Slug = "slug2"; await _slugService.UpdateEntityUrl(entity); //Assert - Assert.IsTrue(_repository.Table.FirstOrDefault(x => x.Id == entity.Id).Slug == entity.Slug); + Assert.AreEqual(entity.Slug, _repository.Table.FirstOrDefault(x => x.Id == entity.Id).Slug); } [TestMethod] diff --git a/src/Tests/Grand.Business.Common.Tests/Startup/StartupApplicationTests.cs b/src/Tests/Grand.Business.Common.Tests/Startup/StartupApplicationTests.cs index 6f88ad794..191d0832f 100644 --- a/src/Tests/Grand.Business.Common.Tests/Startup/StartupApplicationTests.cs +++ b/src/Tests/Grand.Business.Common.Tests/Startup/StartupApplicationTests.cs @@ -26,6 +26,6 @@ public void ConfigureServicesTest() //Act _application.ConfigureServices(_serviceCollection, _configuration); //Assert - Assert.IsTrue(_serviceCollection.Count > 0); + Assert.IsGreaterThan(0, _serviceCollection.Count); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Customers.Tests/Handler/CustomerLoggedInNotificationHandlerTests.cs b/src/Tests/Grand.Business.Customers.Tests/Handler/CustomerLoggedInNotificationHandlerTests.cs index 4159f5642..9df29753d 100644 --- a/src/Tests/Grand.Business.Customers.Tests/Handler/CustomerLoggedInNotificationHandlerTests.cs +++ b/src/Tests/Grand.Business.Customers.Tests/Handler/CustomerLoggedInNotificationHandlerTests.cs @@ -32,8 +32,8 @@ public async Task HandleTest() await _handler.Handle(new CustomerLoggedInEvent(customer), CancellationToken.None); //Assert - Assert.IsTrue(customer.FailedLoginAttempts == 0); - Assert.IsTrue(customer.CannotLoginUntilDateUtc == null); + Assert.AreEqual(0, customer.FailedLoginAttempts); + Assert.IsNull(customer.CannotLoginUntilDateUtc); _cumstomerServiceMock.Verify(c => c.UpdateCustomerLastLoginDate(customer), Times.Once); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Customers.Tests/Handler/CustomerLoginFailedNotificationHandlerTests.cs b/src/Tests/Grand.Business.Customers.Tests/Handler/CustomerLoginFailedNotificationHandlerTests.cs index a8f2ebe05..8ff489222 100644 --- a/src/Tests/Grand.Business.Customers.Tests/Handler/CustomerLoginFailedNotificationHandlerTests.cs +++ b/src/Tests/Grand.Business.Customers.Tests/Handler/CustomerLoginFailedNotificationHandlerTests.cs @@ -34,7 +34,7 @@ public async Task HandleTest_FailedLoginAttempts_Inc() await _handler.Handle(new CustomerLoginFailedEvent(customer), CancellationToken.None); //Assert - Assert.IsTrue(customer.FailedLoginAttempts == 2); + Assert.AreEqual(2, customer.FailedLoginAttempts); _customerServiceMock.Verify(c => c.UpdateCustomerLastLoginDate(customer), Times.Once); } @@ -50,7 +50,7 @@ public async Task HandleTest_CannotLoginUntilDate_Set() await _handler.Handle(new CustomerLoginFailedEvent(customer), CancellationToken.None); //Assert - Assert.IsTrue(customer.CannotLoginUntilDateUtc != null); + Assert.IsNotNull(customer.CannotLoginUntilDateUtc); _customerServiceMock.Verify(c => c.UpdateCustomerLastLoginDate(customer), Times.Once); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerAttributeParserTests.cs b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerAttributeParserTests.cs index 3f249cfeb..1af4f1a29 100644 --- a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerAttributeParserTests.cs +++ b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerAttributeParserTests.cs @@ -54,7 +54,7 @@ public async Task ParseCustomerAttributes_ReturnExpectedValues() _customerAtrServiceMock.Setup(c => c.GetCustomerAttributeById(It.IsAny())).Returns((string w) => Task.FromResult(_customerAtr.FirstOrDefault(a => a.Id.Equals(w)))); var result = await _parser.ParseCustomerAttributes(customAtr); - Assert.IsTrue(result.Count == 4); + Assert.HasCount(4, result); Assert.IsTrue(result.Any(c => c.Id.Equals("key1"))); Assert.IsTrue(result.Any(c => c.Id.Equals("key2"))); Assert.IsTrue(result.Any(c => c.Id.Equals("key3"))); @@ -69,7 +69,7 @@ public async Task ParseCustomerAttributes_ReturnEmptyList() _customerAtrServiceMock.Setup(c => c.GetCustomerAttributeById(It.IsAny())) .Returns(() => Task.FromResult(null)); var result = await _parser.ParseCustomerAttributes(customAtr); - Assert.IsTrue(result.Count == 0); + Assert.IsEmpty(result); } [TestMethod] @@ -78,7 +78,7 @@ public async Task ParseCustomer0AttributeValues_ReturnExpectedValues() _customerAtrServiceMock.Setup(c => c.GetCustomerAttributeById(It.IsAny())).Returns((string w) => Task.FromResult(_customerAtr.FirstOrDefault(a => a.Id.Equals(w)))); var result = await _parser.ParseCustomerAttributeValues(customAtr); - Assert.IsTrue(result.Count == 3); + Assert.HasCount(3, result); Assert.IsTrue(result.Any(c => c.Id.Equals("value2"))); Assert.IsTrue(result.Any(c => c.Id.Equals("value3"))); Assert.IsTrue(result.Any(c => c.Id.Equals("value4"))); @@ -92,7 +92,7 @@ public void AddCustomerAttribute_ReturnExpectedValues() //not exist var result = _parser.AddCustomerAttribute(customAtr, new CustomerAttribute { Id = "key7" }, "value7"); - Assert.IsTrue(result.Count == 5); + Assert.HasCount(5, result); Assert.IsTrue(result.Any(c => c.Key.Equals("key7"))); } @@ -104,7 +104,7 @@ public async Task GetAttributeWarnings_Return_NoWarning() _customerAtrServiceMock.Setup(c => c.GetCustomerAttributeById(It.IsAny())).Returns((string w) => Task.FromResult(_customerAtr.FirstOrDefault(a => a.Id.Equals(w)))); var result = await _parser.GetAttributeWarnings(customAtr); - Assert.IsTrue(result.Count == 0); + Assert.IsEmpty(result); } [TestMethod] @@ -116,7 +116,7 @@ public async Task GetAttributeWarnings_Return_WithWarning() _customerAtrServiceMock.Setup(c => c.GetCustomerAttributeById(It.IsAny())).Returns((string w) => Task.FromResult(_customerAtr.FirstOrDefault(a => a.Id.Equals(w)))); var result = await _parser.GetAttributeWarnings(customAtr); - Assert.IsTrue(result.Count == 1); + Assert.HasCount(1, result); } [TestMethod] @@ -130,6 +130,6 @@ public async Task FormatAttributes_Return_string() new List { new() { Key = "key1", Value = "value1" } }); - Assert.IsTrue(result == "name1: value1"); + Assert.AreEqual("name1: value1", result); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerHistoryPasswordServiceTests.cs b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerHistoryPasswordServiceTests.cs index 5e0a1c682..98b129c34 100644 --- a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerHistoryPasswordServiceTests.cs +++ b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerHistoryPasswordServiceTests.cs @@ -30,7 +30,7 @@ public async Task InsertCustomerPasswordTest() //Act await _customerHistoryPasswordService.InsertCustomerPassword(new Customer()); //Asser - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); } [TestMethod] @@ -44,6 +44,6 @@ public async Task GetPasswordsTest() //Act var result = await _customerHistoryPasswordService.GetPasswords("1", 1); //Asser - Assert.IsTrue(result.Count == 1); + Assert.HasCount(1, result); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerServiceTests.cs b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerServiceTests.cs index 1cbc17783..86ec7f3d8 100644 --- a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerServiceTests.cs +++ b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerServiceTests.cs @@ -44,7 +44,7 @@ public async Task GetOnlineCustomersTest() //Act var result = await _customerService.GetOnlineCustomers(DateTime.UtcNow.AddMinutes(-1), null); //Assert - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } [TestMethod] @@ -84,7 +84,7 @@ public async Task GetCustomersByIdsTest() //Act var result = await _customerService.GetCustomersByIds(["1", "2"]); //Assert - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } [TestMethod] @@ -153,7 +153,7 @@ public async Task InsertGuestCustomerTest() //Act await _customerService.InsertGuestCustomer(customer); //Assert - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); Assert.IsTrue(_repository.Table.Any(x => x.StoreId == "1")); } @@ -163,7 +163,7 @@ public async Task InsertCustomerTest() //Act await _customerService.InsertCustomer(new Customer()); //Assert - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); } [TestMethod] @@ -305,7 +305,7 @@ public async Task UpdateActiveTest() customer.Active = false; await _customerService.UpdateActive(customer); //Assert - Assert.AreEqual(false, _repository.Table.FirstOrDefault(x => x.Id == customer.Id).Active); + Assert.IsFalse(_repository.Table.FirstOrDefault(x => x.Id == customer.Id).Active); } [TestMethod] @@ -318,7 +318,7 @@ public async Task UpdateContributionsTest() customer.Active = false; await _customerService.UpdateContributions(customer); //Assert - Assert.AreEqual(true, _repository.Table.FirstOrDefault(x => x.Id == customer.Id).HasContributions); + Assert.IsTrue(_repository.Table.FirstOrDefault(x => x.Id == customer.Id).HasContributions); } [TestMethod] @@ -352,7 +352,7 @@ public async Task DeleteCustomerGroupInCustomerTest() //Act await _customerService.DeleteCustomerGroupInCustomer(cg, customer.Id); //Assert - Assert.AreEqual(0, _repository.Table.FirstOrDefault(x => x.Id == customer.Id).Groups.Count); + Assert.IsEmpty(_repository.Table.FirstOrDefault(x => x.Id == customer.Id).Groups); } [TestMethod] @@ -365,7 +365,7 @@ public async Task InsertCustomerGroupInCustomerTest() //Act await _customerService.InsertCustomerGroupInCustomer(cg, customer.Id); //Assert - Assert.AreEqual(1, _repository.Table.FirstOrDefault(x => x.Id == customer.Id).Groups.Count); + Assert.HasCount(1, _repository.Table.FirstOrDefault(x => x.Id == customer.Id).Groups); } [TestMethod] @@ -379,7 +379,7 @@ public async Task DeleteAddressTest() //Act await _customerService.DeleteAddress(address, customer.Id); //Assert - Assert.AreEqual(0, _repository.Table.FirstOrDefault(x => x.Id == customer.Id).Addresses.Count); + Assert.IsEmpty(_repository.Table.FirstOrDefault(x => x.Id == customer.Id).Addresses); } [TestMethod] @@ -392,7 +392,7 @@ public async Task InsertAddressTest() var address = new Address(); await _customerService.InsertAddress(address, customer.Id); //Assert - Assert.AreEqual(1, _repository.Table.FirstOrDefault(x => x.Id == customer.Id).Addresses.Count); + Assert.HasCount(1, _repository.Table.FirstOrDefault(x => x.Id == customer.Id).Addresses); } [TestMethod] @@ -407,7 +407,7 @@ public async Task UpdateAddressTest() address.Name = "sample"; await _customerService.UpdateAddress(address, customer.Id); //Assert - Assert.AreEqual(1, _repository.Table.FirstOrDefault(x => x.Id == customer.Id).Addresses.Count); + Assert.HasCount(1, _repository.Table.FirstOrDefault(x => x.Id == customer.Id).Addresses); Assert.AreEqual("sample", _repository.Table.FirstOrDefault(x => x.Id == customer.Id).Addresses.FirstOrDefault(x => x.Id == address.Id) .Name); @@ -456,7 +456,7 @@ public async Task DeleteShoppingCartItemTest() //Act await _customerService.DeleteShoppingCartItem(customer.Id, cart); //Assert - Assert.AreEqual(0, _repository.Table.FirstOrDefault(x => x.Id == customer.Id).ShoppingCartItems.Count); + Assert.IsEmpty(_repository.Table.FirstOrDefault(x => x.Id == customer.Id).ShoppingCartItems); } [TestMethod] @@ -472,7 +472,7 @@ public async Task ClearShoppingCartItemTest() //Act await _customerService.ClearShoppingCartItem(customer.Id, new List { cart }); //Assert - Assert.AreEqual(1, _repository.Table.FirstOrDefault(x => x.Id == customer.Id).ShoppingCartItems.Count); + Assert.HasCount(1, _repository.Table.FirstOrDefault(x => x.Id == customer.Id).ShoppingCartItems); } [TestMethod] @@ -485,7 +485,7 @@ public async Task InsertShoppingCartItemTest() var cart = new ShoppingCartItem(); await _customerService.InsertShoppingCartItem(customer.Id, cart); //Assert - Assert.AreEqual(1, _repository.Table.FirstOrDefault(x => x.Id == customer.Id).ShoppingCartItems.Count); + Assert.HasCount(1, _repository.Table.FirstOrDefault(x => x.Id == customer.Id).ShoppingCartItems); } [TestMethod] diff --git a/src/Tests/Grand.Business.Customers.Tests/Services/SalesEmployeeServiceTests.cs b/src/Tests/Grand.Business.Customers.Tests/Services/SalesEmployeeServiceTests.cs index ef3874e13..48d3ee5e3 100644 --- a/src/Tests/Grand.Business.Customers.Tests/Services/SalesEmployeeServiceTests.cs +++ b/src/Tests/Grand.Business.Customers.Tests/Services/SalesEmployeeServiceTests.cs @@ -53,7 +53,7 @@ public async Task GetAllTest() //Act var result = await _salesEmployeeService.GetAll(); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } [TestMethod] @@ -62,7 +62,7 @@ public async Task InsertSalesEmployeeTest() //Act await _salesEmployeeService.InsertSalesEmployee(new SalesEmployee()); //Assert - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); } [TestMethod] @@ -87,6 +87,6 @@ public async Task DeleteSalesEmployeeTest() //Act await _salesEmployeeService.DeleteSalesEmployee(salesEmployee); //Assert - Assert.IsFalse(_repository.Table.Any()); + Assert.IsEmpty(_repository.Table); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Customers.Tests/Startup/StartupApplicationTests.cs b/src/Tests/Grand.Business.Customers.Tests/Startup/StartupApplicationTests.cs index 5040226a7..d38ba5626 100644 --- a/src/Tests/Grand.Business.Customers.Tests/Startup/StartupApplicationTests.cs +++ b/src/Tests/Grand.Business.Customers.Tests/Startup/StartupApplicationTests.cs @@ -26,6 +26,6 @@ public void ConfigureServicesTest() //Act _application.ConfigureServices(_serviceCollection, _configuration); //Assert - Assert.IsTrue(_serviceCollection.Count > 0); + Assert.IsGreaterThan(0, _serviceCollection.Count); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Marketing.Tests/Extensions/ContactAttributeExtensionsTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Extensions/ContactAttributeExtensionsTests.cs index ad92ea4fa..d7c02f78b 100644 --- a/src/Tests/Grand.Business.Marketing.Tests/Extensions/ContactAttributeExtensionsTests.cs +++ b/src/Tests/Grand.Business.Marketing.Tests/Extensions/ContactAttributeExtensionsTests.cs @@ -16,12 +16,12 @@ public void ShouldHaveValues_ReturnExpentedResult() var ca4 = new ContactAttribute { AttributeControlType = AttributeControlType.FileUpload }; var ca5 = new ContactAttribute { AttributeControlType = AttributeControlType.DropdownList }; ContactAttribute ca6 = null; - Assert.AreEqual(false, ca.ShouldHaveValues()); - Assert.AreEqual(false, ca6.ShouldHaveValues()); - Assert.AreEqual(false, ca2.ShouldHaveValues()); - Assert.AreEqual(false, ca4.ShouldHaveValues()); - Assert.AreEqual(false, ca3.ShouldHaveValues()); - Assert.AreEqual(true, ca5.ShouldHaveValues()); + Assert.IsFalse(ca.ShouldHaveValues()); + Assert.IsFalse(ca6.ShouldHaveValues()); + Assert.IsFalse(ca2.ShouldHaveValues()); + Assert.IsFalse(ca4.ShouldHaveValues()); + Assert.IsFalse(ca3.ShouldHaveValues()); + Assert.IsTrue(ca5.ShouldHaveValues()); } [TestMethod] @@ -33,11 +33,11 @@ public void CanBeUsedAsCondition_ReturnExpentedResult() var ca4 = new ContactAttribute { AttributeControlType = AttributeControlType.FileUpload }; var ca5 = new ContactAttribute { AttributeControlType = AttributeControlType.DropdownList }; ContactAttribute ca6 = null; - Assert.AreEqual(false, ca.CanBeUsedAsCondition()); - Assert.AreEqual(false, ca6.CanBeUsedAsCondition()); - Assert.AreEqual(false, ca2.CanBeUsedAsCondition()); - Assert.AreEqual(false, ca4.CanBeUsedAsCondition()); - Assert.AreEqual(false, ca3.CanBeUsedAsCondition()); - Assert.AreEqual(true, ca5.CanBeUsedAsCondition()); + Assert.IsFalse(ca.CanBeUsedAsCondition()); + Assert.IsFalse(ca6.CanBeUsedAsCondition()); + Assert.IsFalse(ca2.CanBeUsedAsCondition()); + Assert.IsFalse(ca4.CanBeUsedAsCondition()); + Assert.IsFalse(ca3.CanBeUsedAsCondition()); + Assert.IsTrue(ca5.CanBeUsedAsCondition()); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/Campaigns/CampaignServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/Campaigns/CampaignServiceTests.cs index 3041d9f3c..b49efd4ee 100644 --- a/src/Tests/Grand.Business.Marketing.Tests/Services/Campaigns/CampaignServiceTests.cs +++ b/src/Tests/Grand.Business.Marketing.Tests/Services/Campaigns/CampaignServiceTests.cs @@ -57,7 +57,7 @@ public async Task InsertCampaignTest() await _campaignService.InsertCampaign(new Campaign()); //Assert _mediatorMock.Verify(c => c.Publish(It.IsAny>(), default), Times.Once); - Assert.IsTrue(_campaignRepository.Table.Any()); + Assert.IsNotEmpty(_campaignRepository.Table); } [TestMethod] @@ -66,7 +66,7 @@ public async Task InsertCampaignHistoryTest() //Act await _campaignService.InsertCampaignHistory(new CampaignHistory()); //Assert - Assert.IsTrue(_campaignHistoryRepository.Table.Any()); + Assert.IsNotEmpty(_campaignHistoryRepository.Table); } [TestMethod] @@ -81,7 +81,7 @@ public async Task UpdateCampaignTest() await _campaignService.UpdateCampaign(campaign); //Assert _mediatorMock.Verify(c => c.Publish(It.IsAny>(), default), Times.Once); - Assert.IsTrue(_campaignRepository.Table.FirstOrDefault(x => x.Id == campaign.Id).Subject == "test"); + Assert.AreEqual("test", _campaignRepository.Table.FirstOrDefault(x => x.Id == campaign.Id).Subject); } [TestMethod] @@ -95,7 +95,7 @@ public async Task DeleteCampaignTest() await _campaignService.DeleteCampaign(campaign); //Assert _mediatorMock.Verify(c => c.Publish(It.IsAny>(), default), Times.Once); - Assert.IsFalse(_campaignRepository.Table.Any()); + Assert.IsEmpty(_campaignRepository.Table); } [TestMethod] @@ -127,7 +127,7 @@ public async Task GetAllCampaignsTest() var result = await _campaignService.GetAllCampaigns(); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } [TestMethod] @@ -145,7 +145,7 @@ public async Task GetCampaignHistoryTest() var result = await _campaignService.GetCampaignHistory(campaign); //Assert - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } [TestMethod] @@ -163,7 +163,7 @@ await _newsLetterSubscriptionRepository.InsertAsync(new NewsLetterSubscription var result = await _campaignService.CustomerSubscriptions(campaign); //Assert - Assert.AreEqual(1, result.Count); + Assert.HasCount(1, result); } [TestMethod] diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeParserTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeParserTests.cs index bc4f60938..2a1579470 100644 --- a/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeParserTests.cs +++ b/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeParserTests.cs @@ -56,7 +56,7 @@ public async Task ParseContactAttributes_ReturnExpectedValues() _contactAttributeServiceMock.Setup(c => c.GetContactAttributeById(It.IsAny())).Returns((string w) => Task.FromResult(_contactAtr.FirstOrDefault(a => a.Id.Equals(w)))); var result = await _parser.ParseContactAttributes(customAtr); - Assert.IsTrue(result.Count == 4); + Assert.HasCount(4, result); Assert.IsTrue(result.Any(c => c.Id.Equals("key1"))); Assert.IsTrue(result.Any(c => c.Id.Equals("key2"))); Assert.IsTrue(result.Any(c => c.Id.Equals("key3"))); @@ -70,7 +70,7 @@ public async Task ParseCustomer0AttributeValues_ReturnExpectedValues() _contactAttributeServiceMock.Setup(c => c.GetContactAttributeById(It.IsAny())).Returns((string w) => Task.FromResult(_contactAtr.FirstOrDefault(a => a.Id.Equals(w)))); var result = await _parser.ParseContactAttributeValues(customAtr); - Assert.IsTrue(result.Count == 3); + Assert.HasCount(3, result); Assert.IsTrue(result.Any(c => c.Id.Equals("value2"))); Assert.IsTrue(result.Any(c => c.Id.Equals("value3"))); Assert.IsTrue(result.Any(c => c.Id.Equals("value4"))); @@ -81,7 +81,7 @@ public async Task ParseCustomer0AttributeValues_ReturnExpectedValues() public void AddContactAttributeTest() { var result = _parser.AddContactAttribute(customAtr, new ContactAttribute { Id = "key7" }, "value7"); - Assert.IsTrue(result.Count == 5); + Assert.HasCount(5, result); Assert.IsTrue(result.Any(c => c.Key.Equals("key7"))); } @@ -113,7 +113,7 @@ public async Task IsConditionMetTest_IsConditionMet_False() public void RemoveContactAttributeTest() { var result = _parser.RemoveContactAttribute(customAtr, new ContactAttribute { Id = "key1" }); - Assert.IsTrue(result.Count == 3); + Assert.HasCount(3, result); Assert.IsFalse(result.Any(c => c.Key.Equals("key1"))); } @@ -128,6 +128,6 @@ public async Task FormatAttributesTest() new List { new() { Key = "key1", Value = "value1" } }, new Customer()); - Assert.IsTrue(result == "name1: value1"); + Assert.AreEqual("name1: value1", result); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeServiceTests.cs index 7f38cb21d..9d78b46e4 100644 --- a/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeServiceTests.cs +++ b/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeServiceTests.cs @@ -52,7 +52,7 @@ public async Task DeleteContactAttributeTest() //Assert Assert.IsNull(_repository.Table.FirstOrDefault(x => x.Name == "test")); - Assert.AreEqual(0, _repository.Table.Count()); + Assert.IsEmpty(_repository.Table); } [TestMethod] @@ -67,7 +67,7 @@ public async Task GetAllContactAttributesTest() var result = await _contactAttributeService.GetAllContactAttributes(); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } [TestMethod] @@ -97,7 +97,7 @@ public async Task InsertContactAttributeTest() await _contactAttributeService.InsertContactAttribute(contactAttribute); //Assert - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); } [TestMethod] diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactUsServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactUsServiceTests.cs index bbb58bb8a..321290ae4 100644 --- a/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactUsServiceTests.cs +++ b/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactUsServiceTests.cs @@ -37,7 +37,7 @@ public async Task DeleteContactUsTest() //Assert Assert.IsNull(_repository.Table.FirstOrDefault(x => x.FullName == "test")); - Assert.AreEqual(0, _repository.Table.Count()); + Assert.IsEmpty(_repository.Table); } [TestMethod] @@ -52,7 +52,7 @@ public async Task ClearTableTest() await _contactUsService.ClearTable(); //Assert - Assert.AreEqual(0, _repository.Table.Count()); + Assert.IsEmpty(_repository.Table); } [TestMethod] @@ -67,7 +67,7 @@ public async Task GetAllContactUsTest() var result = await _contactUsService.GetAllContactUs(); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } [TestMethod] @@ -97,6 +97,6 @@ public async Task InsertContactUsTest() await _contactUsService.InsertContactUs(contactUs); //Assert - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CourseLessonServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CourseLessonServiceTests.cs index c42b30282..14fd9a22d 100644 --- a/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CourseLessonServiceTests.cs +++ b/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CourseLessonServiceTests.cs @@ -37,7 +37,7 @@ public async Task DeleteTest() //Assert Assert.IsNull(_repository.Table.FirstOrDefault(x => x.Name == "test")); - Assert.AreEqual(0, _repository.Table.Count()); + Assert.IsEmpty(_repository.Table); } [TestMethod] @@ -55,7 +55,7 @@ public async Task GetByCourseIdTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.Count); + Assert.HasCount(1, result); } [TestMethod] @@ -85,7 +85,7 @@ public async Task InsertTest() await _courseLessonService.Insert(courseLesson); //Assert - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); } [TestMethod] diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CourseLevelServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CourseLevelServiceTests.cs index 5ed491eef..1acf1c878 100644 --- a/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CourseLevelServiceTests.cs +++ b/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CourseLevelServiceTests.cs @@ -37,7 +37,7 @@ public async Task DeleteTest() //Assert Assert.IsNull(_repository.Table.FirstOrDefault(x => x.Name == "test")); - Assert.AreEqual(0, _repository.Table.Count()); + Assert.IsEmpty(_repository.Table); } [TestMethod] @@ -52,7 +52,7 @@ public async Task GetAllTest() var result = await _courseLevelService.GetAll(); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } [TestMethod] @@ -82,7 +82,7 @@ public async Task InsertTest() await _courseLevelService.Insert(courseLevel); //Assert - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); } [TestMethod] diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CourseSubjectServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CourseSubjectServiceTests.cs index 3e8a137f5..428dceb6d 100644 --- a/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CourseSubjectServiceTests.cs +++ b/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CourseSubjectServiceTests.cs @@ -37,7 +37,7 @@ public async Task DeleteTest() //Assert Assert.IsNull(_repository.Table.FirstOrDefault(x => x.Name == "test")); - Assert.AreEqual(0, _repository.Table.Count()); + Assert.IsEmpty(_repository.Table); } [TestMethod] @@ -55,7 +55,7 @@ public async Task GetByCourseIdTest() //Assert Assert.IsNotNull(result); - Assert.AreEqual(1, result.Count); + Assert.HasCount(1, result); } [TestMethod] @@ -85,7 +85,7 @@ public async Task InsertTest() await _courseSubjectService.Insert(courseSubject); //Assert - Assert.IsTrue(_repository.Table.Any()); + Assert.IsNotEmpty(_repository.Table); } [TestMethod] diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerProductServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerProductServiceTests.cs index eea27298e..05c10f096 100644 --- a/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerProductServiceTests.cs +++ b/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerProductServiceTests.cs @@ -73,7 +73,7 @@ public async Task InsertCustomerProductPriceTest() await _customerProductService.InsertCustomerProductPrice(customerProductPrice); //Assert - Assert.IsTrue(_repositoryCustomerProductPrice.Table.Any()); + Assert.IsNotEmpty(_repositoryCustomerProductPrice.Table); } [TestMethod] @@ -122,7 +122,7 @@ public async Task GetProductsPriceByCustomerTest() var result = await _customerProductService.GetProductsPriceByCustomer("1"); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } [TestMethod] @@ -165,7 +165,7 @@ public async Task InsertCustomerProductTest() await _customerProductService.InsertCustomerProduct(customerProduct); //Assert - Assert.IsTrue(_repositoryCustomerProduct.Table.Any()); + Assert.IsNotEmpty(_repositoryCustomerProduct.Table); } [TestMethod] @@ -214,6 +214,6 @@ public async Task GetProductsByCustomerTest() var result = await _customerProductService.GetProductsByCustomer("1"); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerTagServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerTagServiceTests.cs index fbba03e88..c800be1a4 100644 --- a/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerTagServiceTests.cs +++ b/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerTagServiceTests.cs @@ -53,8 +53,8 @@ public async Task GetCustomersByTagTest() var result = await _customerTagService.GetCustomersByTag("1"); //Assert - Assert.IsTrue(result.Any()); - Assert.AreEqual(2, result.Count); + Assert.IsNotEmpty(result); + Assert.HasCount(2, result); } [TestMethod] @@ -79,9 +79,8 @@ public async Task DeleteCustomerTagTest() var result = await _customerTagService.GetCustomersByTag("1"); //Assert - Assert.IsFalse(result.Any()); - Assert.AreEqual(0, result.Count); - Assert.AreEqual(0, _repositoryCustomerTag.Table.Count()); + Assert.IsEmpty(result); + Assert.IsEmpty(_repositoryCustomerTag.Table); } [TestMethod] @@ -96,8 +95,8 @@ public async Task GetAllCustomerTagsTest() var result = await _customerTagService.GetAllCustomerTags(); //Assert - Assert.IsTrue(result.Any()); - Assert.AreEqual(3, result.Count); + Assert.IsNotEmpty(result); + Assert.HasCount(3, result); } [TestMethod] @@ -150,7 +149,7 @@ public async Task GetCustomerTagsByNameTest() var result = await _customerTagService.GetCustomerTagsByName("test"); //Assert - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } [TestMethod] @@ -163,7 +162,7 @@ public async Task InsertCustomerTagTest() await _customerTagService.InsertCustomerTag(customerTag); //Assert - Assert.IsTrue(_repositoryCustomerTag.Table.Any()); + Assert.IsNotEmpty(_repositoryCustomerTag.Table); } [TestMethod] @@ -215,7 +214,7 @@ public async Task UpdateCustomerTagTest() await _customerTagService.UpdateCustomerTag(customerTag); //Assert - Assert.IsTrue(_repositoryCustomerTag.Table.FirstOrDefault(x => x.Id == customerTag.Id).Name == "test2"); + Assert.AreEqual("test2", _repositoryCustomerTag.Table.FirstOrDefault(x => x.Id == customerTag.Id).Name); } [TestMethod] @@ -251,7 +250,7 @@ public async Task GetCustomerTagProductsTest() var result = await _customerTagService.GetCustomerTagProducts("1"); //Assert - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } [TestMethod] @@ -294,7 +293,7 @@ public async Task InsertCustomerTagProductTest() await _customerTagService.InsertCustomerTagProduct(new CustomerTagProduct()); //Assert - Assert.IsTrue(_repositoryCustomerTagProduct.Table.Any()); + Assert.IsNotEmpty(_repositoryCustomerTagProduct.Table); } [TestMethod] @@ -309,8 +308,7 @@ public async Task UpdateCustomerTagProductTest() await _customerTagService.UpdateCustomerTagProduct(customerTagProduct); //Assert - Assert.IsTrue(_repositoryCustomerTagProduct.Table.FirstOrDefault(x => x.Id == customerTagProduct.Id) - .DisplayOrder == 10); + Assert.AreEqual(10, _repositoryCustomerTagProduct.Table.FirstOrDefault(x => x.Id == customerTagProduct.Id).DisplayOrder); } [TestMethod] @@ -324,6 +322,6 @@ public async Task DeleteCustomerTagProductTest() await _customerTagService.DeleteCustomerTagProduct(customerTagProduct); //Assert - Assert.IsFalse(_repositoryCustomerTag.Table.Any()); + Assert.IsEmpty(_repositoryCustomerTag.Table); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/PushNotifications/PushNotificationsServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/PushNotifications/PushNotificationsServiceTests.cs index 1b4c1f976..a3177b1e1 100644 --- a/src/Tests/Grand.Business.Marketing.Tests/Services/PushNotifications/PushNotificationsServiceTests.cs +++ b/src/Tests/Grand.Business.Marketing.Tests/Services/PushNotifications/PushNotificationsServiceTests.cs @@ -55,7 +55,7 @@ public async Task InsertPushReceiverTest() //Act await _pushNotificationsService.InsertPushReceiver(new PushRegistration()); //Assert - Assert.IsTrue(_repositoryPushRegistration.Table.Any()); + Assert.IsNotEmpty(_repositoryPushRegistration.Table); } [TestMethod] @@ -69,7 +69,7 @@ public async Task DeletePushReceiverTest() await _pushNotificationsService.DeletePushReceiver(pushRegistration); //Assert - Assert.IsFalse(_repositoryPushRegistration.Table.Any()); + Assert.IsEmpty(_repositoryPushRegistration.Table); } [TestMethod] @@ -113,7 +113,7 @@ public async Task GetPushReceiversTest() var result = await _pushNotificationsService.GetAllowedPushReceivers(); //Assert - Assert.AreEqual(2, result.Count); + Assert.HasCount(2, result); } [TestMethod] @@ -150,7 +150,7 @@ public async Task InsertPushMessageTest() //Act await _pushNotificationsService.InsertPushMessage(new PushMessage()); //Assert - Assert.IsFalse(_repositoryPushRegistration.Table.Any()); + Assert.IsEmpty(_repositoryPushRegistration.Table); } [TestMethod] @@ -165,7 +165,7 @@ public async Task GetPushMessagesTest() var result = await _pushNotificationsService.GetPushMessages(); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } [TestMethod] @@ -180,7 +180,7 @@ public async Task GetPushReceiversTest1() var result = await _pushNotificationsService.GetAllowedPushReceivers(); //Assert - Assert.AreEqual(3, result.Count); + Assert.HasCount(3, result); } [TestMethod] diff --git a/src/Tests/Grand.Business.Marketing.Tests/Startup/StartupApplicationTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Startup/StartupApplicationTests.cs index ff5aa29c4..412ead30c 100644 --- a/src/Tests/Grand.Business.Marketing.Tests/Startup/StartupApplicationTests.cs +++ b/src/Tests/Grand.Business.Marketing.Tests/Startup/StartupApplicationTests.cs @@ -26,6 +26,6 @@ public void ConfigureServicesTest() //Act _application.ConfigureServices(_serviceCollection, _configuration); //Assert - Assert.IsTrue(_serviceCollection.Count > 0); + Assert.IsGreaterThan(0, _serviceCollection.Count); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Messages.Tests/Services/LiquidObjectBuilderTests.cs b/src/Tests/Grand.Business.Messages.Tests/Services/LiquidObjectBuilderTests.cs index fcd6e87f0..657121713 100644 --- a/src/Tests/Grand.Business.Messages.Tests/Services/LiquidObjectBuilderTests.cs +++ b/src/Tests/Grand.Business.Messages.Tests/Services/LiquidObjectBuilderTests.cs @@ -38,7 +38,7 @@ public async Task BuilderTest() .BuildAsync(); - Assert.IsTrue(liquidObject.Vendor != null); + Assert.IsNotNull(liquidObject.Vendor); Assert.IsTrue((liquidObject.Vendor as LiquidVendor).Name.Equals(vendor.Name)); Assert.IsNotNull(liquidObject.VendorReview as LiquidVendorReview); Assert.IsTrue((liquidObject.VendorReview as LiquidVendorReview).VendorName.Equals(vendor.Name)); diff --git a/src/Tests/Grand.Business.Messages.Tests/Services/MessageProviderServiceTest.cs b/src/Tests/Grand.Business.Messages.Tests/Services/MessageProviderServiceTest.cs index cc9a025f4..aba38a5bb 100644 --- a/src/Tests/Grand.Business.Messages.Tests/Services/MessageProviderServiceTest.cs +++ b/src/Tests/Grand.Business.Messages.Tests/Services/MessageProviderServiceTest.cs @@ -96,7 +96,7 @@ public async Task CallInsertQueuedEmailMethod() public async Task SendOutBidCustomerNotificationMethodReturnCorrectResult() { var result = await _messageService.SendOutBidCustomerMessage(new Product(), "123", new Bid()); - Assert.AreEqual(result, 1); + Assert.AreEqual(1, result); } [TestMethod] @@ -104,7 +104,7 @@ public async Task SendNewVendorAccountApplyStoreOwnerNotificationRetunsCorrectRe { var result = await _messageService.SendNewVendorAccountApplyStoreOwnerMessage(new Customer(), new Vendor(), new Store { Url = "https://localhost:44350/" }, "123"); - Assert.AreEqual(result, 1); + Assert.AreEqual(1, result); } [TestMethod] @@ -117,6 +117,6 @@ public async Task SendNotificationMethodToEmailIsNull() toName: "The God", toEmailAddress: null); - Assert.AreEqual(result, 0); + Assert.AreEqual(0, result); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Messages.Tests/Startup/StartupApplicationTests.cs b/src/Tests/Grand.Business.Messages.Tests/Startup/StartupApplicationTests.cs index 377e69e72..59d60df5a 100644 --- a/src/Tests/Grand.Business.Messages.Tests/Startup/StartupApplicationTests.cs +++ b/src/Tests/Grand.Business.Messages.Tests/Startup/StartupApplicationTests.cs @@ -26,6 +26,6 @@ public void ConfigureServicesTest() //Act _application.ConfigureServices(_serviceCollection, _configuration); //Assert - Assert.IsTrue(_serviceCollection.Count > 0); + Assert.IsGreaterThan(0, _serviceCollection.Count); } } \ No newline at end of file diff --git a/src/Tests/Grand.Business.Storage.Tests/Services/DefaultMediaFileStoreTests.cs b/src/Tests/Grand.Business.Storage.Tests/Services/DefaultMediaFileStoreTests.cs index 1f65055a0..79b57f26f 100644 --- a/src/Tests/Grand.Business.Storage.Tests/Services/DefaultMediaFileStoreTests.cs +++ b/src/Tests/Grand.Business.Storage.Tests/Services/DefaultMediaFileStoreTests.cs @@ -25,7 +25,7 @@ public async Task GetFileInfoTest() var result = await _defaultMediaFileStore.GetFileInfo(myFile); //Assert Assert.IsNotNull(result); - Assert.AreEqual(result.Name, myFile); + Assert.AreEqual(myFile, result.Name); } [TestMethod] @@ -35,7 +35,7 @@ public void GetDirectoryInfoTest() var result = _defaultMediaFileStore.GetDirectoryInfo("Upload"); //Assert Assert.IsNotNull(result); - Assert.AreEqual(result.Name, "Upload"); + Assert.AreEqual("Upload", result.Name); } [TestMethod] @@ -45,7 +45,7 @@ public async Task GetPhysicalDirectoryInfoTest() var result = await _defaultMediaFileStore.GetPhysicalDirectoryInfo("Upload"); //Assert Assert.IsNotNull(result); - Assert.AreEqual(result.Name, "Upload"); + Assert.AreEqual("Upload", result.Name); Assert.IsTrue(result.IsDirectory); } @@ -55,8 +55,8 @@ public void GetDirectoryContentTest() //Act var result = _defaultMediaFileStore.GetDirectoryContent("Upload"); //Assert - Assert.AreEqual(1, result.Count); - Assert.IsTrue(result.Any()); + Assert.HasCount(1, result); + Assert.IsNotEmpty(result); } [TestMethod] diff --git a/src/Tests/Grand.Business.Storage.Tests/Services/FileSystemStoreTests.cs b/src/Tests/Grand.Business.Storage.Tests/Services/FileSystemStoreTests.cs index f46121fb7..085d8fbbe 100644 --- a/src/Tests/Grand.Business.Storage.Tests/Services/FileSystemStoreTests.cs +++ b/src/Tests/Grand.Business.Storage.Tests/Services/FileSystemStoreTests.cs @@ -24,7 +24,7 @@ public async Task GetFileInfoTest() var result = await _store.GetFileInfo(myFile); //Assert Assert.IsNotNull(result); - Assert.AreEqual(result.Name, myFile); + Assert.AreEqual(myFile, result.Name); } [TestMethod] @@ -34,7 +34,7 @@ public void GetDirectoryInfoTest() var result = _store.GetDirectoryInfo("Upload"); //Assert Assert.IsNotNull(result); - Assert.AreEqual(result.Name, "Upload"); + Assert.AreEqual("Upload", result.Name); } [TestMethod] @@ -44,7 +44,7 @@ public async Task GetPhysicalDirectoryInfoTest() var result = await _store.GetPhysicalDirectoryInfo("Upload"); //Assert Assert.IsNotNull(result); - Assert.AreEqual(result.Name, "Upload"); + Assert.AreEqual("Upload", result.Name); Assert.IsTrue(result.IsDirectory); } @@ -54,8 +54,8 @@ public void GetDirectoryContentTest() //Act var result = _store.GetDirectoryContent("Upload"); //Assert - Assert.AreEqual(1, result.Count); - Assert.IsTrue(result.Any()); + Assert.HasCount(1, result); + Assert.IsNotEmpty(result); } [TestMethod] diff --git a/src/Tests/Grand.Business.Storage.Tests/Services/PictureServiceTests.cs b/src/Tests/Grand.Business.Storage.Tests/Services/PictureServiceTests.cs index 92894d858..86c1a7206 100644 --- a/src/Tests/Grand.Business.Storage.Tests/Services/PictureServiceTests.cs +++ b/src/Tests/Grand.Business.Storage.Tests/Services/PictureServiceTests.cs @@ -81,7 +81,7 @@ public async Task LoadPictureBinary_FromFile_ReturnEmptyBytes() _webHostMock.Setup(c => c.WebRootPath).Returns("~root/"); var result = await _service.LoadPictureBinary(new Picture { Id = "id", MimeType = "image/jpeg" }, false); //we can't mock static class like File.Exist so, should return empty array - Assert.IsTrue(result.Length == 0); + Assert.IsEmpty(result); } [TestMethod] diff --git a/src/Tests/Grand.Business.Storage.Tests/Startup/StartupApplicationTests.cs b/src/Tests/Grand.Business.Storage.Tests/Startup/StartupApplicationTests.cs index 26c8ea06c..6a9e5b5ef 100644 --- a/src/Tests/Grand.Business.Storage.Tests/Startup/StartupApplicationTests.cs +++ b/src/Tests/Grand.Business.Storage.Tests/Startup/StartupApplicationTests.cs @@ -26,6 +26,6 @@ public void ConfigureServicesTest() //Act _application.ConfigureServices(_serviceCollection, _configuration); //Assert - Assert.IsTrue(_serviceCollection.Count > 0); + Assert.IsGreaterThan(0, _serviceCollection.Count); } } \ No newline at end of file diff --git a/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.cs b/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.cs index 84ba7396c..e5faa9ae4 100644 --- a/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.cs +++ b/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.cs @@ -23,7 +23,7 @@ public void Insert_LiteRepository_Success() myRepository.Insert(product); //Assert Assert.AreEqual(1, myRepository.Table.Count()); - Assert.IsTrue(myRepository.Table.FirstOrDefault(x => x.Id == "1")!.CreatedBy == "user"); + Assert.AreEqual("user", myRepository.Table.FirstOrDefault(x => x.Id == "1")!.CreatedBy); } [TestMethod] @@ -38,7 +38,7 @@ public async Task InsertAsync_LiteRepository_Success() //Assert Assert.IsNotNull(p); Assert.AreEqual(1, myRepository.Table.Count()); - Assert.IsTrue(p.CreatedBy == "user"); + Assert.AreEqual("user", p.CreatedBy); } [TestMethod] @@ -98,7 +98,7 @@ public async Task ClearAsync_LiteRepository_Success() await myRepository.ClearAsync(); - Assert.IsTrue(myRepository.Table.Count() == 0); + Assert.IsEmpty(myRepository.Table); } [TestMethod] @@ -118,9 +118,9 @@ await myRepository.AddToSet("1", x => x.UserFields, var p = myRepository.GetById("1"); //Assert - Assert.IsTrue(p.UserFields.Count == 2); + Assert.HasCount(2, p.UserFields); Assert.IsTrue(p.UpdatedOnUtc.HasValue); - Assert.IsTrue(p.UpdatedBy == "user"); + Assert.AreEqual("user", p.UpdatedBy); } [TestMethod] @@ -162,7 +162,7 @@ public async Task DeleteManyAsync_LiteRepository_Success() await myRepository.DeleteManyAsync(x => x.Name == "Test"); - Assert.IsTrue(myRepository.Table.Count() == 1); + Assert.AreEqual(1, myRepository.Table.Count()); } [TestMethod] @@ -187,9 +187,9 @@ public async Task Pull_LiteRepository_Success() var p = myRepository.GetById("1"); //Assert - Assert.IsTrue(p.Phones.Count == 2); + Assert.HasCount(2, p.Phones); Assert.IsTrue(p.UpdatedOnUtc.HasValue); - Assert.IsTrue(p.UpdatedBy == "user"); + Assert.AreEqual("user", p.UpdatedBy); } [TestMethod] @@ -218,9 +218,11 @@ public async Task Pull_Many_LiteRepository_Success() var p3 = myRepository.GetById("3"); //Assert - Assert.IsTrue(p1.Phones.Count == 2 && p2.Phones.Count == 2 && p3.Phones.Count == 0); + Assert.HasCount(2, p1.Phones); + Assert.HasCount(2, p2.Phones); + Assert.IsEmpty(p3.Phones); Assert.IsTrue(p1.UpdatedOnUtc.HasValue); - Assert.IsTrue(p1.UpdatedBy == "user"); + Assert.AreEqual("user", p1.UpdatedBy); } [TestMethod] @@ -247,9 +249,9 @@ public async Task PullFilter_1_LiteRepository_Success() var p1 = myRepository.GetById("1"); //Assert - Assert.IsTrue(p1.UserFields.Count == 2); + Assert.HasCount(2, p1.UserFields); Assert.IsTrue(p1.UpdatedOnUtc.HasValue); - Assert.IsTrue(p1.UpdatedBy == "user"); + Assert.AreEqual("user", p1.UpdatedBy); } [TestMethod] @@ -277,9 +279,9 @@ public async Task PullFilter_2_LiteRepository_Success() var p1 = myRepository.GetById("1"); //Assert - Assert.IsTrue(p1.UserFields.Count == 1); + Assert.HasCount(1, p1.UserFields); Assert.IsTrue(p1.UpdatedOnUtc.HasValue); - Assert.IsTrue(p1.UpdatedBy == "user"); + Assert.AreEqual("user", p1.UpdatedBy); } [TestMethod] @@ -315,9 +317,10 @@ public async Task PullFilter_2_Many_LiteRepository_Success() var p2 = myRepository.GetById("2"); //Assert - Assert.IsTrue(p1.UserFields.Count == 1 && p2.UserFields.Count == 2); + Assert.HasCount(1, p1.UserFields); + Assert.HasCount(2, p2.UserFields); Assert.IsTrue(p1.UpdatedOnUtc.HasValue); - Assert.IsTrue(p1.UpdatedBy == "user"); + Assert.AreEqual("user", p1.UpdatedBy); } @@ -349,9 +352,9 @@ public void Update_LiteRepository_Success() var p1 = myRepository.GetById("1"); //Assert - Assert.IsTrue(p1.Name == "update"); + Assert.AreEqual("update", p1.Name); Assert.IsTrue(p1.UpdatedOnUtc.HasValue); - Assert.IsTrue(p1.UpdatedBy == "user"); + Assert.AreEqual("user", p1.UpdatedBy); } [TestMethod] @@ -380,9 +383,9 @@ public async Task UpdateAsync_LiteRepository_Success() var p1 = myRepository.GetById("1"); //Assert - Assert.IsTrue(p1.Name == "update"); + Assert.AreEqual("update", p1.Name); Assert.IsTrue(p1.UpdatedOnUtc.HasValue); - Assert.IsTrue(p1.UpdatedBy == "user"); + Assert.AreEqual("user", p1.UpdatedBy); } [TestMethod] @@ -409,9 +412,9 @@ public async Task UpdateField_LiteRepository_Success() var p1 = myRepository.GetById("1"); //Assert - Assert.IsTrue(p1.Name == "update"); + Assert.AreEqual("update", p1.Name); Assert.IsTrue(p1.UpdatedOnUtc.HasValue); - Assert.IsTrue(p1.UpdatedBy == "user"); + Assert.AreEqual("user", p1.UpdatedBy); } [TestMethod] @@ -427,7 +430,7 @@ public async Task IncField_MongoRepository_Success() var p1 = myRepository.GetById("1"); - Assert.IsTrue(p1.Count == 3); + Assert.AreEqual(3, p1.Count); } [TestMethod] @@ -456,9 +459,9 @@ await myRepository.UpdateManyAsync(x => x.Name == "Test", var pUpdated = myRepository.Table.Where(x => x.Name == "UpdateTest"); //Asser - Assert.IsTrue(pUpdated.Count() == 2); + Assert.AreEqual(2, pUpdated.Count()); Assert.IsTrue(pUpdated.FirstOrDefault()!.UpdatedOnUtc.HasValue); - Assert.IsTrue(pUpdated.FirstOrDefault()!.UpdatedBy == "user"); + Assert.AreEqual("user", pUpdated.FirstOrDefault()!.UpdatedBy); } [TestMethod] @@ -486,9 +489,9 @@ await myRepository.UpdateOneAsync(x => x.Name == "Test", var pUpdated = myRepository.Table.Where(x => x.Name == "UpdateTest"); //Assert - Assert.IsTrue(pUpdated.Count() == 1); + Assert.AreEqual(1, pUpdated.Count()); Assert.IsTrue(pUpdated.FirstOrDefault()!.UpdatedOnUtc.HasValue); - Assert.IsTrue(pUpdated.FirstOrDefault()!.UpdatedBy == "user"); + Assert.AreEqual("user", pUpdated.FirstOrDefault()!.UpdatedBy); } [TestMethod] @@ -516,9 +519,9 @@ await myRepository.UpdateToSet("1", x => x.UserFields, z => z.Key, "key", var p = myRepository.GetById("1"); //Assert - Assert.IsTrue(p.UserFields!.FirstOrDefault(x => x.Key == "key")!.Value == "update"); + Assert.AreEqual("update", p.UserFields!.FirstOrDefault(x => x.Key == "key")!.Value); Assert.IsTrue(p.UpdatedOnUtc.HasValue); - Assert.IsTrue(p.UpdatedBy == "user"); + Assert.AreEqual("user", p.UpdatedBy); } [TestMethod] @@ -546,8 +549,8 @@ await myRepository.UpdateToSet("1", x => x.UserFields, z => z.Key == "key", var p = myRepository.GetById("1"); //Assert - Assert.IsTrue(p.UserFields!.FirstOrDefault(x => x.Key == "key")!.Value == "update"); + Assert.AreEqual("update", p.UserFields!.FirstOrDefault(x => x.Key == "key")!.Value); Assert.IsTrue(p.UpdatedOnUtc.HasValue); - Assert.IsTrue(p.UpdatedBy == "user"); + Assert.AreEqual("user", p.UpdatedBy); } } \ No newline at end of file diff --git a/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.cs b/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.cs index 9c576f54c..f9188e33b 100644 --- a/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.cs +++ b/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.cs @@ -23,10 +23,10 @@ public void Insert_MongoRepository_Success() _myRepository.Insert(product); //Assert Assert.AreEqual(1, _myRepository.Table.Count()); - Assert.IsTrue(_myRepository.Table.FirstOrDefault()!.CreatedBy == "user"); - Assert.IsTrue(_myRepository.Table.FirstOrDefault()!.CreatedOnUtc.Year == DateTime.UtcNow.Year); - Assert.IsTrue(_myRepository.Table.FirstOrDefault()!.CreatedOnUtc.Month == DateTime.UtcNow.Month); - Assert.IsTrue(_myRepository.Table.FirstOrDefault()!.CreatedOnUtc.Day == DateTime.UtcNow.Day); + Assert.AreEqual("user", _myRepository.Table.FirstOrDefault()!.CreatedBy); + Assert.AreEqual(DateTime.UtcNow.Year, _myRepository.Table.FirstOrDefault()!.CreatedOnUtc.Year); + Assert.AreEqual(DateTime.UtcNow.Month, _myRepository.Table.FirstOrDefault()!.CreatedOnUtc.Month); + Assert.AreEqual(DateTime.UtcNow.Day, _myRepository.Table.FirstOrDefault()!.CreatedOnUtc.Day); } @@ -54,8 +54,8 @@ public async Task GetByIdAsync_MongoRepository_Success() var p = await _myRepository.GetByIdAsync("1"); //Assert Assert.IsNotNull(p); - Assert.IsTrue(p!.CreatedBy == "user"); - Assert.IsTrue(p!.CreatedOnUtc.Year == DateTime.UtcNow.Year); + Assert.AreEqual("user", p!.CreatedBy); + Assert.AreEqual(DateTime.UtcNow.Year, p!.CreatedOnUtc.Year); } [TestMethod] @@ -68,8 +68,8 @@ public async Task GetOneAsync_MongoRepository_Success() var p = await _myRepository.GetOneAsync(x => x.Id == "1"); //Assert Assert.IsNotNull(p); - Assert.IsTrue(p!.CreatedBy == "user"); - Assert.IsTrue(p!.CreatedOnUtc.Year == DateTime.UtcNow.Year); + Assert.AreEqual("user", p!.CreatedBy); + Assert.AreEqual(DateTime.UtcNow.Year, p!.CreatedOnUtc.Year); } [TestMethod] @@ -80,7 +80,7 @@ public async Task ClearAsync_MongoRepository_Success() await _myRepository.ClearAsync(); - Assert.IsTrue(_myRepository.Table.Count() == 0); + Assert.IsEmpty(_myRepository.Table); } [TestMethod] @@ -100,10 +100,10 @@ await _myRepository.AddToSet("1", x => x.UserFields, var p = _myRepository.GetById("1"); //Assert - Assert.IsTrue(p.UserFields.Count == 2); - Assert.IsTrue(p!.CreatedBy == "user"); - Assert.IsTrue(p!.CreatedOnUtc.Year == DateTime.UtcNow.Year); - Assert.IsTrue(p!.UpdatedBy == "user"); + Assert.HasCount(2, p.UserFields); + Assert.AreEqual("user", p!.CreatedBy); + Assert.AreEqual(DateTime.UtcNow.Year, p!.CreatedOnUtc.Year); + Assert.AreEqual("user", p!.UpdatedBy); Assert.IsTrue(p!.UpdatedOnUtc.HasValue); } @@ -152,7 +152,7 @@ public async Task DeleteManyAsync_MongoRepository_Success() await _myRepository.DeleteManyAsync(x => x.Name == "Test"); //Assert - Assert.IsTrue(_myRepository.Table.Count() == 1); + Assert.AreEqual(1, _myRepository.Table.Count()); } [TestMethod] @@ -178,10 +178,10 @@ public async Task Pull_MongoRepository_Success() var p = _myRepository.GetById("1"); //Assert - Assert.IsTrue(p.Phones.Count == 2); - Assert.IsTrue(p!.CreatedBy == "user"); - Assert.IsTrue(p!.CreatedOnUtc.Year == DateTime.UtcNow.Year); - Assert.IsTrue(p!.UpdatedBy == "user"); + Assert.HasCount(2, p.Phones); + Assert.AreEqual("user", p!.CreatedBy); + Assert.AreEqual(DateTime.UtcNow.Year, p!.CreatedOnUtc.Year); + Assert.AreEqual("user", p!.UpdatedBy); Assert.IsTrue(p!.UpdatedOnUtc.HasValue); } @@ -210,10 +210,12 @@ public async Task Pull_Many_MongoRepository_Success() var p3 = _myRepository.GetById("3"); //Assert - Assert.IsTrue(p1.Phones.Count == 2 && p2.Phones.Count == 2 && p3.Phones.Count == 0); - Assert.IsTrue(p1!.CreatedBy == "user"); - Assert.IsTrue(p1!.CreatedOnUtc.Year == DateTime.UtcNow.Year); - Assert.IsTrue(p1!.UpdatedBy == "user"); + Assert.HasCount(2, p1.Phones); + Assert.HasCount(2, p2.Phones); + Assert.IsEmpty(p3.Phones); + Assert.AreEqual("user", p1!.CreatedBy); + Assert.AreEqual(DateTime.UtcNow.Year, p1!.CreatedOnUtc.Year); + Assert.AreEqual("user", p1!.UpdatedBy); Assert.IsTrue(p1!.UpdatedOnUtc.HasValue); } @@ -241,10 +243,10 @@ public async Task PullFilter_1_MongoRepository_Success() var p1 = _myRepository.GetById("1"); //Assert - Assert.IsTrue(p1.UserFields.Count == 1); - Assert.IsTrue(p1!.CreatedBy == "user"); - Assert.IsTrue(p1!.CreatedOnUtc.Year == DateTime.UtcNow.Year); - Assert.IsTrue(p1!.UpdatedBy == "user"); + Assert.HasCount(1, p1.UserFields); + Assert.AreEqual("user", p1!.CreatedBy); + Assert.AreEqual(DateTime.UtcNow.Year, p1!.CreatedOnUtc.Year); + Assert.AreEqual("user", p1!.UpdatedBy); Assert.IsTrue(p1!.UpdatedOnUtc.HasValue); } @@ -272,10 +274,10 @@ public async Task PullFilter_2_MongoRepository_Success() var p1 = _myRepository.GetById("1"); //Assert - Assert.IsTrue(p1.UserFields.Count == 1); - Assert.IsTrue(p1!.CreatedBy == "user"); - Assert.IsTrue(p1!.CreatedOnUtc.Year == DateTime.UtcNow.Year); - Assert.IsTrue(p1!.UpdatedBy == "user"); + Assert.HasCount(1, p1.UserFields); + Assert.AreEqual("user", p1!.CreatedBy); + Assert.AreEqual(DateTime.UtcNow.Year, p1!.CreatedOnUtc.Year); + Assert.AreEqual("user", p1!.UpdatedBy); Assert.IsTrue(p1!.UpdatedOnUtc.HasValue); } @@ -311,10 +313,11 @@ public async Task PullFilter_2_Many_MongoRepository_Success() var p2 = _myRepository.GetById("2"); //Assert - Assert.IsTrue(p1.UserFields.Count == 1 && p2.UserFields.Count == 2); - Assert.IsTrue(p1!.CreatedBy == "user"); - Assert.IsTrue(p1!.CreatedOnUtc.Year == DateTime.UtcNow.Year); - Assert.IsTrue(p1!.UpdatedBy == "user"); + Assert.HasCount(1, p1.UserFields); + Assert.HasCount(2, p2.UserFields); + Assert.AreEqual("user", p1!.CreatedBy); + Assert.AreEqual(DateTime.UtcNow.Year, p1!.CreatedOnUtc.Year); + Assert.AreEqual("user", p1!.UpdatedBy); Assert.IsTrue(p1!.UpdatedOnUtc.HasValue); } @@ -345,8 +348,8 @@ public void Update_MongoRepository_Success() var p1 = _myRepository.GetById("1"); //Assert - Assert.IsTrue(p1.Name == "update"); - Assert.IsTrue(p1!.UpdatedBy == "user"); + Assert.AreEqual("update", p1.Name); + Assert.AreEqual("user", p1!.UpdatedBy); Assert.IsTrue(p1!.UpdatedOnUtc.HasValue); } @@ -375,8 +378,8 @@ public async Task UpdateAsync_MongoRepository_Success() var p1 = _myRepository.GetById("1"); //Assert - Assert.IsTrue(p1.Name == "update"); - Assert.IsTrue(p1!.UpdatedBy == "user"); + Assert.AreEqual("update", p1.Name); + Assert.AreEqual("user", p1!.UpdatedBy); Assert.IsTrue(p1!.UpdatedOnUtc.HasValue); } @@ -403,8 +406,8 @@ public async Task UpdateField_MongoRepository_Success() var p1 = _myRepository.GetById("1"); //Assert - Assert.IsTrue(p1.Name == "update"); - Assert.IsTrue(p1!.UpdatedBy == "user"); + Assert.AreEqual("update", p1.Name); + Assert.AreEqual("user", p1!.UpdatedBy); Assert.IsTrue(p1!.UpdatedOnUtc.HasValue); } @@ -420,7 +423,7 @@ public async Task IncField_MongoRepository_Success() var p1 = _myRepository.GetById("1"); - Assert.IsTrue(p1.Count == 3); + Assert.AreEqual(3, p1.Count); } [TestMethod] @@ -446,8 +449,8 @@ await _myRepository.UpdateManyAsync(x => x.Name == "Test", var pUpdated = _myRepository.Table.Where(x => x.Name == "UpdateTest"); var p1 = pUpdated.FirstOrDefault(); //Assert - Assert.IsTrue(pUpdated.Count() == 2); - Assert.IsTrue(p1!.UpdatedBy == "user"); + Assert.AreEqual(2, pUpdated.Count()); + Assert.AreEqual("user", p1!.UpdatedBy); Assert.IsTrue(p1!.UpdatedOnUtc.HasValue); } @@ -476,8 +479,8 @@ await _myRepository.UpdateOneAsync(x => x.Name == "Test", var pUpdated = _myRepository.Table.Where(x => x.Name == "UpdateTest"); var p1 = pUpdated.FirstOrDefault(); //Assert - Assert.IsTrue(pUpdated.Count() == 1); - Assert.IsTrue(p1!.UpdatedBy == "user"); + Assert.AreEqual(1, pUpdated.Count()); + Assert.AreEqual("user", p1!.UpdatedBy); Assert.IsTrue(p1!.UpdatedOnUtc.HasValue); } @@ -504,8 +507,8 @@ await _myRepository.UpdateToSet("1", x => x.UserFields, z => z.Key, "key", var p = _myRepository.GetById("1"); //Assert - Assert.IsTrue(p.UserFields.FirstOrDefault(x => x.Key == "key")!.Value == "update"); - Assert.IsTrue(p!.UpdatedBy == "user"); + Assert.AreEqual("update", p.UserFields.FirstOrDefault(x => x.Key == "key")!.Value); + Assert.AreEqual("user", p!.UpdatedBy); Assert.IsTrue(p!.UpdatedOnUtc.HasValue); } } \ No newline at end of file diff --git a/src/Tests/Grand.Domain.Tests/Blogs/BlogExtensionsTests.cs b/src/Tests/Grand.Domain.Tests/Blogs/BlogExtensionsTests.cs index d6be275c9..a0d2a7058 100644 --- a/src/Tests/Grand.Domain.Tests/Blogs/BlogExtensionsTests.cs +++ b/src/Tests/Grand.Domain.Tests/Blogs/BlogExtensionsTests.cs @@ -13,7 +13,7 @@ public void ParseTagsTest() Tags = "e-commerce, blog, moey" }; - Assert.AreEqual(3, blogPost.ParseTags().Length); + Assert.HasCount(3, blogPost.ParseTags()); } [TestMethod] @@ -24,6 +24,6 @@ public void GetPostsByDateTest() new() { StartDateUtc = new DateTime(2010, 02, 01) }, new() { StartDateUtc = new DateTime(2010, 03, 01) } }; - Assert.AreEqual(2, blogPosts.GetPostsByDate(new DateTime(2010, 01, 01), new DateTime(2010, 02, 28)).Count); + Assert.HasCount(2, blogPosts.GetPostsByDate(new DateTime(2010, 01, 01), new DateTime(2010, 02, 28))); } } \ No newline at end of file diff --git a/src/Tests/Grand.Domain.Tests/Common/UserFieldExtensionsTests.cs b/src/Tests/Grand.Domain.Tests/Common/UserFieldExtensionsTests.cs index 4f57f336e..34fca18bc 100644 --- a/src/Tests/Grand.Domain.Tests/Common/UserFieldExtensionsTests.cs +++ b/src/Tests/Grand.Domain.Tests/Common/UserFieldExtensionsTests.cs @@ -22,7 +22,7 @@ public void GetUserFieldFromEntityTest_FirstName_NotNull() { var userField = entity.GetUserFieldFromEntity("FirstName"); Assert.IsNotNull(userField); - Assert.AreEqual(userField, "Sara"); + Assert.AreEqual("Sara", userField); } [TestMethod] @@ -37,7 +37,7 @@ public void GetUserFieldFromEntityTest_Registered_Store_NotNull() { var userField = entity.GetUserFieldFromEntity("Registered", "1"); Assert.IsNotNull(userField); - Assert.AreEqual(userField, "1"); + Assert.AreEqual("1", userField); } [TestMethod] diff --git a/src/Tests/Grand.Domain.Tests/Orders/GiftVoucherExtensionsTests.cs b/src/Tests/Grand.Domain.Tests/Orders/GiftVoucherExtensionsTests.cs index afec12bdc..7cee1b702 100644 --- a/src/Tests/Grand.Domain.Tests/Orders/GiftVoucherExtensionsTests.cs +++ b/src/Tests/Grand.Domain.Tests/Orders/GiftVoucherExtensionsTests.cs @@ -27,11 +27,11 @@ public void AddGiftVoucherAttributeTest() out var giftVoucherRecipientEmail, out var giftVoucherSenderName, out var giftVoucherSenderEmail, out var giftVoucherMessage); - Assert.IsTrue(giftVoucherRecipientName == "Johny"); - Assert.IsTrue(giftVoucherRecipientEmail == "test@test.com"); - Assert.IsTrue(giftVoucherSenderName == "My name"); - Assert.IsTrue(giftVoucherSenderEmail == "name@name.com"); - Assert.IsTrue(giftVoucherMessage == "my sample message"); + Assert.AreEqual("Johny", giftVoucherRecipientName); + Assert.AreEqual("test@test.com", giftVoucherRecipientEmail); + Assert.AreEqual("My name", giftVoucherSenderName); + Assert.AreEqual("name@name.com", giftVoucherSenderEmail); + Assert.AreEqual("my sample message", giftVoucherMessage); } [TestMethod] @@ -49,11 +49,11 @@ public void GetGiftVoucherAttributeTest() out var giftVoucherRecipientEmail, out var giftVoucherSenderName, out var giftVoucherSenderEmail, out var giftVoucherMessage); - Assert.IsTrue(giftVoucherRecipientName == "Johny"); - Assert.IsTrue(giftVoucherRecipientEmail == "test@test.com"); - Assert.IsTrue(giftVoucherSenderName == "My name"); - Assert.IsTrue(giftVoucherSenderEmail == "name@name.com"); - Assert.IsTrue(giftVoucherMessage == "my sample message"); + Assert.AreEqual("Johny", giftVoucherRecipientName); + Assert.AreEqual("test@test.com", giftVoucherRecipientEmail); + Assert.AreEqual("My name", giftVoucherSenderName); + Assert.AreEqual("name@name.com", giftVoucherSenderEmail); + Assert.AreEqual("my sample message", giftVoucherMessage); } [TestMethod] @@ -61,7 +61,7 @@ public void GetGiftVoucherRemainingAmountTest() { giftVoucher.GiftVoucherUsageHistory.Add(new GiftVoucherUsageHistory { UsedValue = 3 }); giftVoucher.GiftVoucherUsageHistory.Add(new GiftVoucherUsageHistory { UsedValue = 4 }); - Assert.IsTrue(giftVoucher.GetGiftVoucherRemainingAmount() == 3); + Assert.AreEqual(3, giftVoucher.GetGiftVoucherRemainingAmount()); } [TestMethod] diff --git a/src/Tests/Grand.Domain.Tests/Orders/ShoppingCartExtensionsTests.cs b/src/Tests/Grand.Domain.Tests/Orders/ShoppingCartExtensionsTests.cs index 44f41255a..79df53c56 100644 --- a/src/Tests/Grand.Domain.Tests/Orders/ShoppingCartExtensionsTests.cs +++ b/src/Tests/Grand.Domain.Tests/Orders/ShoppingCartExtensionsTests.cs @@ -26,10 +26,10 @@ public void LimitPerStore_ReturnExpectedResults() new() { IsShipEnabled = false }, new() { IsShipEnabled = false } }; - Assert.IsTrue(shoppingCartItems.LimitPerStore(false, "id").ToList().Count == 0); + Assert.IsEmpty(shoppingCartItems.LimitPerStore(false, "id").ToList()); shoppingCartItems.Add(new ShoppingCartItem { StoreId = "id" }); var result = shoppingCartItems.LimitPerStore(false, "id").ToList(); - Assert.IsTrue(result.Count == 1); - Assert.IsTrue(result.First().StoreId.Equals("id")); + Assert.HasCount(1, result); + Assert.AreEqual("id", result.First().StoreId); } } \ No newline at end of file diff --git a/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheBaseTests.cs b/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheBaseTests.cs index 3b0afff2e..08b4f626c 100644 --- a/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheBaseTests.cs +++ b/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheBaseTests.cs @@ -33,28 +33,28 @@ public void Init() public void GetTest() { var result = _service.Get("key", () => { return "test"; }); - Assert.AreEqual(result, "test"); + Assert.AreEqual("test", result); } [TestMethod] public void GetTest_CacheTimeMinutes() { var result = _service.Get("key", () => { return "test"; }, 1); - Assert.AreEqual(result, "test"); + Assert.AreEqual("test", result); } [TestMethod] public async Task GetAsyncTest() { var result = await _service.GetAsync("key", () => { return Task.FromResult("test"); }); - Assert.AreEqual(result, "test"); + Assert.AreEqual("test", result); } [TestMethod] public async Task GetAsyncTest_CacheTimeMinutes() { var result = await _service.GetAsync("key", () => { return Task.FromResult("test"); }, 1); - Assert.AreEqual(result, "test"); + Assert.AreEqual("test", result); } [TestMethod] diff --git a/src/Tests/Grand.Infrastructure.Tests/Migrations/DbVersionTests.cs b/src/Tests/Grand.Infrastructure.Tests/Migrations/DbVersionTests.cs index 1e4d5e907..25db4a1e3 100644 --- a/src/Tests/Grand.Infrastructure.Tests/Migrations/DbVersionTests.cs +++ b/src/Tests/Grand.Infrastructure.Tests/Migrations/DbVersionTests.cs @@ -12,7 +12,7 @@ public void CompareToTest_Greater_Major() var dbVersion1 = new DbVersion(1, 0); var dbVersion2 = new DbVersion(2, 0); var result = dbVersion2.CompareTo(dbVersion1); - Assert.AreEqual(result, 1); + Assert.AreEqual(1, result); } [TestMethod] @@ -21,7 +21,7 @@ public void CompareToTest_Lower_Major() var dbVersion1 = new DbVersion(1, 0); var dbVersion2 = new DbVersion(2, 0); var result = dbVersion1.CompareTo(dbVersion2); - Assert.AreEqual(result, -1); + Assert.AreEqual(-1, result); } [TestMethod] @@ -30,7 +30,7 @@ public void CompareToTest_Greater_Minor() var dbVersion1 = new DbVersion(2, 0); var dbVersion2 = new DbVersion(2, 1); var result = dbVersion2.CompareTo(dbVersion1); - Assert.AreEqual(result, 1); + Assert.AreEqual(1, result); } [TestMethod] @@ -39,7 +39,7 @@ public void CompareToTest_Lower_Minor() var dbVersion1 = new DbVersion(2, 0); var dbVersion2 = new DbVersion(2, 1); var result = dbVersion1.CompareTo(dbVersion2); - Assert.AreEqual(result, -1); + Assert.AreEqual(-1, result); } [TestMethod] @@ -48,6 +48,6 @@ public void CompareToTest_Eq() var dbVersion1 = new DbVersion(2, 0); var dbVersion2 = new DbVersion(2, 0); var result = dbVersion1.CompareTo(dbVersion2); - Assert.AreEqual(result, 0); + Assert.AreEqual(0, result); } } \ No newline at end of file diff --git a/src/Tests/Grand.Infrastructure.Tests/Migrations/MigrationManagerTests.cs b/src/Tests/Grand.Infrastructure.Tests/Migrations/MigrationManagerTests.cs index e0e659537..2e1ba91b8 100644 --- a/src/Tests/Grand.Infrastructure.Tests/Migrations/MigrationManagerTests.cs +++ b/src/Tests/Grand.Infrastructure.Tests/Migrations/MigrationManagerTests.cs @@ -12,13 +12,13 @@ public class MigrationManagerTests public void GetAllMigrationsTest() { var result = migrationManager.GetAllMigrations(); - Assert.IsTrue(result.Count() == 2); + Assert.AreEqual(2, result.Count()); } [TestMethod] public void GetCurrentMigrationsTest() { var result = migrationManager.GetCurrentMigrations(new DbVersion(2,3)); - Assert.IsTrue(result.Count() == 1); + Assert.AreEqual(1, result.Count()); } } \ No newline at end of file diff --git a/src/Tests/Grand.Infrastructure.Tests/Plugins/BasePluginTests.cs b/src/Tests/Grand.Infrastructure.Tests/Plugins/BasePluginTests.cs index d4a8a9811..d117f1e24 100644 --- a/src/Tests/Grand.Infrastructure.Tests/Plugins/BasePluginTests.cs +++ b/src/Tests/Grand.Infrastructure.Tests/Plugins/BasePluginTests.cs @@ -43,7 +43,7 @@ public async Task UninstallTest_WithInstall() await sampleBasePlugin.Install(); await sampleBasePlugin.Uninstall(); var plugins = PluginExtensions.ParseInstalledPluginsFile(PluginPaths.Instance.InstalledPluginsFile); - Assert.AreEqual(0, plugins.Count); + Assert.IsEmpty(plugins); } [TestMethod] @@ -51,6 +51,6 @@ public async Task UninstallTest() { await sampleBasePlugin.Uninstall(); var plugins = PluginExtensions.ParseInstalledPluginsFile(PluginPaths.Instance.InstalledPluginsFile); - Assert.AreEqual(0, plugins.Count); + Assert.IsEmpty(plugins); } } \ No newline at end of file diff --git a/src/Tests/Grand.Infrastructure.Tests/Plugins/PluginExtensionsTests.cs b/src/Tests/Grand.Infrastructure.Tests/Plugins/PluginExtensionsTests.cs index de903c61f..d9a3e373d 100644 --- a/src/Tests/Grand.Infrastructure.Tests/Plugins/PluginExtensionsTests.cs +++ b/src/Tests/Grand.Infrastructure.Tests/Plugins/PluginExtensionsTests.cs @@ -32,7 +32,7 @@ public async Task MarkPluginAsInstalledTest() await PluginExtensions.MarkPluginAsInstalled("plugin1"); //Assert var plugins = PluginExtensions.ParseInstalledPluginsFile(PluginPaths.Instance.InstalledPluginsFile); - Assert.AreEqual(1, plugins.Count); + Assert.HasCount(1, plugins); } [TestMethod] @@ -45,6 +45,6 @@ public async Task MarkPluginAsUninstalled() await PluginExtensions.MarkPluginAsUninstalled("plugin1"); //Assert var plugins = PluginExtensions.ParseInstalledPluginsFile(PluginPaths.Instance.InstalledPluginsFile); - Assert.AreEqual(1, plugins.Count); + Assert.HasCount(1, plugins); } } \ No newline at end of file diff --git a/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/GenericListTypeConverterTests.cs b/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/GenericListTypeConverterTests.cs index 1db01a53d..6256237c0 100644 --- a/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/GenericListTypeConverterTests.cs +++ b/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/GenericListTypeConverterTests.cs @@ -31,7 +31,7 @@ public void ConvertFromTest_List_string() { var mylist = (List)_stringconverter.ConvertFrom("str1, str2"); Assert.IsNotNull(mylist); - Assert.IsTrue(mylist.Count > 0); + Assert.IsNotEmpty(mylist); } [TestMethod] @@ -39,7 +39,7 @@ public void ConvertFromTest_List_int() { var mylist = (List)_intconverter.ConvertFrom("1, 2"); Assert.IsNotNull(mylist); - Assert.IsTrue(mylist.Count > 0); + Assert.IsNotEmpty(mylist); } [TestMethod] @@ -47,7 +47,7 @@ public void ConvertFromTest_list_double() { var mylist = (List)_doubleconverter.ConvertFrom("1.1, 2"); Assert.IsNotNull(mylist); - Assert.IsTrue(mylist.Count == 2); + Assert.HasCount(2, mylist); } [TestMethod] diff --git a/src/Tests/Grand.Modules.Tests/Services/Migrations/MigrationManagerTests.cs b/src/Tests/Grand.Modules.Tests/Services/Migrations/MigrationManagerTests.cs index 0bde0c4a1..a0139e364 100644 --- a/src/Tests/Grand.Modules.Tests/Services/Migrations/MigrationManagerTests.cs +++ b/src/Tests/Grand.Modules.Tests/Services/Migrations/MigrationManagerTests.cs @@ -18,6 +18,6 @@ public void Init() public void GetCurrentMigrations_Exists() { var migrations = _migrationManager.GetCurrentMigrations(new DbVersion(2, 2)); - Assert.IsTrue(migrations.Count() > 0); + Assert.IsNotEmpty(migrations); } } \ No newline at end of file diff --git a/src/Tests/Grand.SharedKernel.Tests/Extensions/CommonHelperTests.cs b/src/Tests/Grand.SharedKernel.Tests/Extensions/CommonHelperTests.cs index 84e879e61..dac9e4a27 100644 --- a/src/Tests/Grand.SharedKernel.Tests/Extensions/CommonHelperTests.cs +++ b/src/Tests/Grand.SharedKernel.Tests/Extensions/CommonHelperTests.cs @@ -21,7 +21,7 @@ public void EnsureSubscriberEmailOrThrowTest_ThrowException(string email) [DataRow("sample.email@sample.com")] public void EnsureSubscriberEmailOrThrowTest_Success(string email) { - Assert.IsTrue(CommonHelper.EnsureSubscriberEmailOrThrow(email) == email); + Assert.AreEqual(email, CommonHelper.EnsureSubscriberEmailOrThrow(email)); } [TestMethod] @@ -49,7 +49,7 @@ public void GenerateRandomDigitCodeTest(int length) var result = CommonHelper.GenerateRandomDigitCode(length); Assert.IsNotNull(result); - Assert.IsTrue(result.Length == length); + Assert.AreEqual(length, result.Length); } [TestMethod] @@ -59,8 +59,8 @@ public void GenerateRandomIntegerTest_True(int min, int max) { var result = CommonHelper.GenerateRandomInteger(min, max); - Assert.IsTrue(result >= min); - Assert.IsTrue(result <= max); + Assert.IsGreaterThanOrEqualTo(min, result); + Assert.IsLessThanOrEqualTo(max, result); } [TestMethod] @@ -76,7 +76,7 @@ public void EnsureMaximumLengthTest_Value_3_True() var str = "value"; var max = 3; string post = null; - Assert.IsTrue(CommonHelper.EnsureMaximumLength(str, max, post) == "val"); + Assert.AreEqual("val", CommonHelper.EnsureMaximumLength(str, max, post)); } [TestMethod] @@ -85,7 +85,7 @@ public void EnsureMaximumLengthTest_Value_10_True() var str = "value"; var max = 10; string post = null; - Assert.IsTrue(CommonHelper.EnsureMaximumLength(str, max, post) == "value"); + Assert.AreEqual("value", CommonHelper.EnsureMaximumLength(str, max, post)); } [TestMethod] @@ -94,7 +94,7 @@ public void EnsureMaximumLengthTest_Value_2_Post_True() var str = "0123456789000"; var max = 10; var post = "..."; - Assert.IsTrue(CommonHelper.EnsureMaximumLength(str, max, post) == "0123456..."); + Assert.AreEqual("0123456...", CommonHelper.EnsureMaximumLength(str, max, post)); } [TestMethod] @@ -120,7 +120,7 @@ public void ArraysEqualTest_False() public void ToTest_True() { object obj = "sample"; - Assert.IsTrue(obj == CommonHelper.To(obj, typeof(string))); + Assert.AreEqual(obj, CommonHelper.To(obj, typeof(string))); } [TestMethod] @@ -134,29 +134,29 @@ public void ToTest_ThrowException() public void ConvertEnumTest() { var value = SampleEnum.Test0; - Assert.IsTrue(CommonHelper.ConvertEnum(value) == "Test0"); + Assert.AreEqual("Test0", CommonHelper.ConvertEnum(value)); } [TestMethod] public void GetDifferenceInYearsTest() { - Assert.IsTrue(CommonHelper.GetDifferenceInYears(new DateTime(2010, 01, 01), new DateTime(2020, 01, 01)) == 10); - Assert.IsTrue(CommonHelper.GetDifferenceInYears(new DateTime(2010, 02, 01), new DateTime(2020, 01, 01)) == 9); - Assert.IsTrue(CommonHelper.GetDifferenceInYears(new DateTime(2011, 01, 02), new DateTime(2020, 01, 01)) == 8); + Assert.AreEqual(10, CommonHelper.GetDifferenceInYears(new DateTime(2010, 01, 01), new DateTime(2020, 01, 01))); + Assert.AreEqual(9, CommonHelper.GetDifferenceInYears(new DateTime(2010, 02, 01), new DateTime(2020, 01, 01))); + Assert.AreEqual(8, CommonHelper.GetDifferenceInYears(new DateTime(2011, 01, 02), new DateTime(2020, 01, 01))); } [TestMethod] public void ToTest_T() { object obj = "sample"; - Assert.IsTrue(obj.ToString() == CommonHelper.To(obj)); + Assert.AreEqual(obj.ToString(), CommonHelper.To(obj)); } [TestMethod] public void ToCultureInfoTest() { object obj = "sample"; - Assert.IsTrue(obj == CommonHelper.To(obj, typeof(string), CultureInfo.InvariantCulture)); + Assert.AreEqual(obj, CommonHelper.To(obj, typeof(string), CultureInfo.InvariantCulture)); } [TestMethod] diff --git a/src/Tests/Grand.SharedKernel.Tests/Extensions/ExtendedLinqTests.cs b/src/Tests/Grand.SharedKernel.Tests/Extensions/ExtendedLinqTests.cs index f62d9d3f4..fbbd7b4b3 100644 --- a/src/Tests/Grand.SharedKernel.Tests/Extensions/ExtendedLinqTests.cs +++ b/src/Tests/Grand.SharedKernel.Tests/Extensions/ExtendedLinqTests.cs @@ -16,7 +16,7 @@ public void CartesianProductTest() }; var cartesianProduct = sampleList.GroupBy(x => x.Id).CartesianProduct().ToList(); - Assert.AreEqual(2, cartesianProduct.Count); + Assert.HasCount(2, cartesianProduct); } [TestMethod] diff --git a/src/Tests/Grand.SharedKernel.Tests/Extensions/FormatTextTests.cs b/src/Tests/Grand.SharedKernel.Tests/Extensions/FormatTextTests.cs index 2884348ec..e1966bd78 100644 --- a/src/Tests/Grand.SharedKernel.Tests/Extensions/FormatTextTests.cs +++ b/src/Tests/Grand.SharedKernel.Tests/Extensions/FormatTextTests.cs @@ -11,7 +11,7 @@ public class FormatTextTests [DataRow("   sample
sample   ")] public void ConvertTextTest(string text) { - Assert.IsFalse(FormatText.ConvertText(text).Contains(" false false + _content/$(MSBuildProjectName) @@ -17,8 +18,7 @@ - - + diff --git a/src/Web/Grand.Web.AdminShared/Grand.Web.AdminShared.csproj b/src/Web/Grand.Web.AdminShared/Grand.Web.AdminShared.csproj index ecc940b4e..93edf2ba1 100644 --- a/src/Web/Grand.Web.AdminShared/Grand.Web.AdminShared.csproj +++ b/src/Web/Grand.Web.AdminShared/Grand.Web.AdminShared.csproj @@ -1,8 +1,7 @@  - + - net9.0 - enable + enable diff --git a/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs b/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs index aa71f90b5..a27be6707 100644 --- a/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs +++ b/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs @@ -121,8 +121,10 @@ public static void AddGrandDataProtection(this IServiceCollection services, ICon { var securityConfig = new SecurityConfig(); configuration.GetSection("Security").Bind(securityConfig); + var defaultKeyPath = Path.Combine(AppContext.BaseDirectory, "App_Data", "DataProtectionKeys"); var keyPersistenceLocation = string.IsNullOrEmpty(securityConfig.KeyPersistenceLocation) - ? "/App_Data/DataProtectionKeys" : securityConfig.KeyPersistenceLocation; + ? defaultKeyPath + : securityConfig.KeyPersistenceLocation; var dataProtectionKeysFolder = new DirectoryInfo(keyPersistenceLocation); //configure the data protection system to persist keys to the specified directory services.AddDataProtection().PersistKeysToFileSystem(dataProtectionKeysFolder); @@ -209,8 +211,6 @@ public static IMvcBuilder AddGrandMvc(this IServiceCollection services, IConfigu var securityConfig = new SecurityConfig(); configuration.GetSection("Security").Bind(securityConfig); - if (securityConfig.EnableRuntimeCompilation) mvcBuilder.AddRazorRuntimeCompilation(); - if (securityConfig.UseHsts) services.AddHsts(options => { diff --git a/src/Web/Grand.Web.Store/App_Data/appsettings.json b/src/Web/Grand.Web.Store/App_Data/appsettings.json index 267f7ee1b..d0d8805b5 100644 --- a/src/Web/Grand.Web.Store/App_Data/appsettings.json +++ b/src/Web/Grand.Web.Store/App_Data/appsettings.json @@ -50,15 +50,13 @@ "UseDefaultSecurityHeaders": false, //HTTP Strict Transport Security Protocol "UseHsts": false, - //When enabled, allow Razor files to be updated if they're edited. - "EnableRuntimeCompilation": false, //We recommend all ASP.NET Core web apps call HTTPS Redirection Middleware to redirect all HTTP requests to HTTPS "UseHttpsRedirection": false, "HttpsRedirectionRedirect": 308, "HttpsRedirectionHttpsPort": 443, //Key persistence location you can point to a directory on the local machine, or it can point to a folder on a network share. //if is null it will use the default directory path - ApplicationPath\App_Data\DataProtectionKeys - "KeyPersistenceLocation": "/App_Data/DataProtectionKeys", + "KeyPersistenceLocation": "", //Gets or sets a value indicating for cookie auth expires in hours - default 24 * 365 = 8760 "CookieAuthExpires": 8760, //Gets or sets a value for cookie prefix - any changes will log out all of the customers diff --git a/src/Web/Grand.Web.Store/Grand.Web.Store.csproj b/src/Web/Grand.Web.Store/Grand.Web.Store.csproj index 91d032643..3031821f6 100644 --- a/src/Web/Grand.Web.Store/Grand.Web.Store.csproj +++ b/src/Web/Grand.Web.Store/Grand.Web.Store.csproj @@ -10,6 +10,7 @@ false false + _content/$(MSBuildProjectName) diff --git a/src/Web/Grand.Web.Vendor/App_Data/appsettings.json b/src/Web/Grand.Web.Vendor/App_Data/appsettings.json index 5f9915119..e32f347f7 100644 --- a/src/Web/Grand.Web.Vendor/App_Data/appsettings.json +++ b/src/Web/Grand.Web.Vendor/App_Data/appsettings.json @@ -50,15 +50,13 @@ "UseDefaultSecurityHeaders": false, //HTTP Strict Transport Security Protocol "UseHsts": false, - //When enabled, allow Razor files to be updated if they're edited. - "EnableRuntimeCompilation": false, //We recommend all ASP.NET Core web apps call HTTPS Redirection Middleware to redirect all HTTP requests to HTTPS "UseHttpsRedirection": false, "HttpsRedirectionRedirect": 308, "HttpsRedirectionHttpsPort": 443, //Key persistence location you can point to a directory on the local machine, or it can point to a folder on a network share. //if is null it will use the default directory path - ApplicationPath\App_Data\DataProtectionKeys - "KeyPersistenceLocation": "/App_Data/DataProtectionKeys", + "KeyPersistenceLocation": "", //Gets or sets a value indicating for cookie auth expires in hours - default 24 * 365 = 8760 "CookieAuthExpires": 8760, //Gets or sets a value for cookie prefix - any changes will log out all of the customers diff --git a/src/Web/Grand.Web.Vendor/Grand.Web.Vendor.csproj b/src/Web/Grand.Web.Vendor/Grand.Web.Vendor.csproj index aa2c86140..0e082d854 100644 --- a/src/Web/Grand.Web.Vendor/Grand.Web.Vendor.csproj +++ b/src/Web/Grand.Web.Vendor/Grand.Web.Vendor.csproj @@ -8,6 +8,7 @@ false false + _content/$(MSBuildProjectName) diff --git a/src/Web/Grand.Web/App_Data/appsettings.json b/src/Web/Grand.Web/App_Data/appsettings.json index eff42ca59..cb55d2d4a 100644 --- a/src/Web/Grand.Web/App_Data/appsettings.json +++ b/src/Web/Grand.Web/App_Data/appsettings.json @@ -50,15 +50,13 @@ "UseDefaultSecurityHeaders": false, //HTTP Strict Transport Security Protocol "UseHsts": false, - //When enabled, allow Razor files to be updated if they're edited. - "EnableRuntimeCompilation": false, //We recommend all ASP.NET Core web apps call HTTPS Redirection Middleware to redirect all HTTP requests to HTTPS "UseHttpsRedirection": false, "HttpsRedirectionRedirect": 308, "HttpsRedirectionHttpsPort": 443, //Key persistence location you can point to a directory on the local machine, or it can point to a folder on a network share. //if is null it will use the default directory path - ApplicationPath\App_Data\DataProtectionKeys - "KeyPersistenceLocation": "/App_Data/DataProtectionKeys", + "KeyPersistenceLocation": "", //Gets or sets a value indicating for cookie auth expires in hours - default 24 * 365 = 8760 "CookieAuthExpires": 8760, //Gets or sets a value for cookie prefix - any changes will log out all of the customers