Skip to content

Commit

Permalink
[Test] Update testing framework to MSTest
Browse files Browse the repository at this point in the history
  • Loading branch information
support committed Mar 24, 2024
1 parent 9b9338a commit f86529f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\..\Build\Grand.Common.props" />
<PropertyGroup>
Expand Down
20 changes: 10 additions & 10 deletions src/Tests/Grand.Web.Admin.Tests/MenuViewModelServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
using Grand.Web.Admin.Mapper;
using Grand.Web.Admin.Models.Menu;
using Grand.Web.Admin.Services;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using NUnit.Framework;
using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert;

namespace Grand.Web.Admin.Tests;

[TestFixture]
[TestClass]
public class MenuViewModelServiceTests
{
private MenuViewModelService _menuViewModelService;
private Mock<IAdminSiteMapService> _adminSiteMapServiceMock;
private IMapper _mapper;

[SetUp]
[TestInitialize]
public void SetUp()
{
_adminSiteMapServiceMock = new Mock<IAdminSiteMapService>();
Expand All @@ -31,7 +31,7 @@ public void SetUp()
AutoMapperConfig.Init(mapperConfig);
}

[Test]
[TestMethod]
public async Task MenuItems_ReturnsMenuItems()
{
// Arrange
Expand All @@ -56,7 +56,7 @@ public async Task MenuItems_ReturnsMenuItems()
Assert.AreEqual(2, result[1].DisplayOrder);
}

[Test]
[TestMethod]
public async Task GetMenuById_ReturnsMenuById()
{
// Arrange
Expand All @@ -75,7 +75,7 @@ public async Task GetMenuById_ReturnsMenuById()
Assert.AreEqual("2", result.Id);
Assert.AreEqual("Item 2", result.SystemName);
}
[Test]
[TestMethod]
public async Task InsertMenuModel_AddsNewMenuModel()
{
// Arrange
Expand All @@ -95,7 +95,7 @@ public async Task InsertMenuModel_AddsNewMenuModel()
Assert.AreEqual(1, parentEntity.ChildNodes.Count);
}

[Test]
[TestMethod]
public async Task UpdateMenuModel_UpdatesMenuModel()
{
// Arrange
Expand All @@ -116,7 +116,7 @@ public async Task UpdateMenuModel_UpdatesMenuModel()
Assert.AreEqual("2", result.Id);
Assert.AreEqual("Updated Item 2", result.SystemName);
}
[Test]
[TestMethod]
public async Task UpdateMenuModel_UpdatesSubMenuModel()
{
// Arrange
Expand All @@ -138,7 +138,7 @@ public async Task UpdateMenuModel_UpdatesSubMenuModel()
Assert.AreEqual("3", result.Id);
Assert.AreEqual("Updated Item 3", result.SystemName);
}
[Test]
[TestMethod]
public async Task DeleteMenu_CallsDeleteSiteMap()
{
// Arrange
Expand All @@ -157,7 +157,7 @@ public async Task DeleteMenu_CallsDeleteSiteMap()
// Assert
_adminSiteMapServiceMock.Verify(x => x.DeleteSiteMap(It.IsAny<AdminSiteMap>()), Times.Once);
}
[Test]
[TestMethod]
public async Task DeleteMenu_CallsUpdate()
{
// Arrange
Expand Down
12 changes: 0 additions & 12 deletions src/Tests/Grand.Web.Admin.Tests/Properties/launchSettings.json

This file was deleted.

18 changes: 9 additions & 9 deletions src/Tests/Grand.Web.Common.Tests/AuthorizeMenuAttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Routing;
using Moq;
using NUnit.Framework;
using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Grand.Web.Common.Tests;

[TestFixture]
[TestClass]
public class AuthorizeMenuAttributeTests
{
private Mock<IPermissionService> _mockPermissionService;
Expand All @@ -27,7 +27,7 @@ public class AuthorizeMenuAttributeTests
private SecurityConfig _securityConfig;
private AuthorizationFilterContext _mockFilterContext;

[SetUp]
[TestInitialize]
public void Setup()
{
CommonPath.BaseDirectory = "";
Expand Down Expand Up @@ -75,7 +75,7 @@ private AuthorizationFilterContext GetMockedAuthorizationFilterContext()

return authorizationFilterContext;
}
[Test]
[TestMethod]
public async Task TestAuthorizeMenuAttribute_WithoutIgnoreFilter_DatabaseNotInstalled()
{
// Arrange
Expand All @@ -96,7 +96,7 @@ public async Task TestAuthorizeMenuAttribute_WithoutIgnoreFilter_DatabaseNotInst
Assert.IsNull(_mockFilterContext.Result);
}

[Test]
[TestMethod]
public async Task TestAuthorizeMenuAttribute_WithoutIgnoreFilter_AuthorizeAdminMenuDisabled()
{
// Arrange
Expand All @@ -118,7 +118,7 @@ public async Task TestAuthorizeMenuAttribute_WithoutIgnoreFilter_AuthorizeAdminM
Assert.IsNull(_mockFilterContext.Result);
}

[Test]
[TestMethod]
public async Task TestAuthorizeMenuAttribute_WithValidSiteMap_AllPermissions()
{
// Arrange
Expand All @@ -142,7 +142,7 @@ public async Task TestAuthorizeMenuAttribute_WithValidSiteMap_AllPermissions()
Assert.IsInstanceOfType(_mockFilterContext.Result, typeof(ForbidResult));
}

[Test]
[TestMethod]
public async Task TestAuthorizeMenuAttribute_NoPermissionsInSiteMap()
{
// Arrange
Expand All @@ -168,7 +168,7 @@ public async Task TestAuthorizeMenuAttribute_NoPermissionsInSiteMap()
Assert.IsNull(_mockFilterContext.Result);
}

[Test]
[TestMethod]
public async Task TestAuthorizeMenuAttribute_WithoutAllPermissions_Authorized()
{
// Arrange
Expand All @@ -194,7 +194,7 @@ public async Task TestAuthorizeMenuAttribute_WithoutAllPermissions_Authorized()
Assert.IsNull(_mockFilterContext.Result);
}

[Test]
[TestMethod]
public async Task TestAuthorizeMenuAttribute_WithoutAllPermissions_NotAuthorized()
{
// Arrange
Expand Down
14 changes: 2 additions & 12 deletions src/Tests/Grand.Web.Common.Tests/Grand.Web.Common.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\..\Build\Grand.Common.props" />
<PropertyGroup>
Expand All @@ -21,15 +21,5 @@
<ProjectReference Include="..\..\Core\Grand.SharedKernel\Grand.SharedKernel.csproj" />
<ProjectReference Include="..\..\Web\Grand.Web.Common\Grand.Web.Common.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>

<ItemGroup>
<None Remove="Properties\launchSettings.json" />
<None Update="App_Data\index.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
12 changes: 0 additions & 12 deletions src/Tests/Grand.Web.Common.Tests/Properties/launchSettings.json

This file was deleted.

0 comments on commit f86529f

Please sign in to comment.