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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
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 RoutedCollectionDataScopeTests
{
private static RoutedCollectionDataScope Build(string area)
{
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<Collection>();
var store = new StoreAdminDataScope<Collection>(BuildContextAccessor());
return new RoutedCollectionDataScope(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");
Assert.IsNull(routed.DefaultStoreId);
}

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

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

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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CollectionModel
<vc:admin-widget widget-zone="collection_details_buttons" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CollectionModel
<vc:admin-widget widget-zone="collection_discounts_bottom" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CollectionModel
<vc:admin-widget widget-zone="collection_discounts_top" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CollectionModel
<vc:admin-widget widget-zone="collection_details_documents_bottom" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CollectionModel
<vc:admin-widget widget-zone="collection_details_documents_top" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CollectionModel
<vc:admin-widget widget-zone="collection_details_products_bottom" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CollectionModel
<vc:admin-widget widget-zone="collection_details_products_top" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CollectionModel
<vc:admin-widget widget-zone="collection_details_seo_top" additional-data="Model"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model CollectionModel
<vc:admin-widget widget-zone="collection_details_tabs" additional-data="Model"/>
Loading
Loading