Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -380,5 +380,6 @@ src/Web/Grand.Web.Store/App_Data/Settings.cfg
src/Web/Grand.Web.Store/Plugins/*
src/Web/Grand.Web.Store/Modules/*
src/Web/Grand.Web.Store/App_Data/DataProtectionKeys/*
src/Web/Grand.Web.Store/wwwroot/assets/images/thumbs/*.**.worktrees/
src/Web/Grand.Web.Store/wwwroot/assets/images/thumbs/*.*
.worktrees/
docs/superpowers/

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using Grand.Domain.Catalog;
using Grand.Web.AdminShared.Interfaces;
using Grand.Web.AdminShared.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

namespace Grand.Web.Admin.Tests.Controllers;

[TestClass]
public class RoutedCategoryDataScopeTests
{
private static RoutedCategoryDataScope Build(string area, out Mock<IAdminDataScope<Category>> globalMock, out Mock<IAdminDataScope<Category>> storeMock)
{
var httpContext = new DefaultHttpContext();
if (area != null)
httpContext.Request.RouteValues = new RouteValueDictionary { ["area"] = area };

var httpContextAccessorMock = new Mock<IHttpContextAccessor>();
httpContextAccessorMock.Setup(a => a.HttpContext).Returns(httpContext);

var global = new GlobalAdminDataScope<Category>();
var store = new StoreAdminDataScope<Category>(BuildContextAccessor());
globalMock = null;
storeMock = null;
return new RoutedCategoryDataScope(httpContextAccessorMock.Object, global, store);
}

private static Grand.Infrastructure.IContextAccessor BuildContextAccessor()
{
var workContext = new Mock<Grand.Infrastructure.IWorkContext>();
workContext.Setup(w => w.CurrentCustomer).Returns(new Grand.Domain.Customers.Customer { StaffStoreId = "store-1" });
var contextAccessorMock = new Mock<Grand.Infrastructure.IContextAccessor>();
contextAccessorMock.Setup(c => c.WorkContext).Returns(workContext.Object);
return contextAccessorMock.Object;
}

[TestMethod]
public void DefaultStoreId_AdminArea_ResolvesToGlobalScope()
{
var routed = Build("Admin", out _, out _);
Assert.IsNull(routed.DefaultStoreId);
}

[TestMethod]
public void DefaultStoreId_StoreArea_ResolvesToStoreScope()
{
var routed = Build("Store", out _, out _);
Assert.AreEqual("store-1", routed.DefaultStoreId);
}

[TestMethod]
public void DefaultStoreId_VendorArea_ThrowsFailClosed()
{
var routed = Build("Vendor", out _, out _);
Assert.ThrowsExactly<InvalidOperationException>(() => _ = routed.DefaultStoreId);
}

[TestMethod]
public void DefaultStoreId_MissingArea_ThrowsFailClosed()
{
var routed = Build(null, out _, out _);
Assert.ThrowsExactly<InvalidOperationException>(() => _ = routed.DefaultStoreId);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CategoryModel
<vc:admin-widget widget-zone="category_details_buttons" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CategoryModel
<vc:admin-widget widget-zone="category_details_discounts_bottom" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CategoryModel
<vc:admin-widget widget-zone="category_details_discounts_top" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CategoryModel
<vc:admin-widget widget-zone="category_details_documents_bottom" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CategoryModel
<vc:admin-widget widget-zone="category_details_documents_top" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CategoryModel
<vc:admin-widget widget-zone="category_details_products_bottom" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CategoryModel
<vc:admin-widget widget-zone="category_details_products_top" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CategoryModel
<vc:admin-widget widget-zone="category_details_seo_bottom" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CategoryModel
<vc:admin-widget widget-zone="category_details_seo_top" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CategoryModel
<vc:admin-widget widget-zone="category_details_tabs" additional-data="Model"/>
Loading
Loading