diff --git a/EPiServer.Marketing.Testing.sln b/EPiServer.Marketing.Testing.sln index 6d22d8e7c..011fdf3b0 100644 --- a/EPiServer.Marketing.Testing.sln +++ b/EPiServer.Marketing.Testing.sln @@ -14,7 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{00563401 README.md = README.md setup.cmd = setup.cmd Build\test.props = Build\test.props - src\EPiServer.Marketing.KPI\version.props = src\EPiServer.Marketing.KPI\version.props + build\version.props = build\version.props EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{4DCCE100-6879-491C-BCC9-85A6DA6B0EE7}" diff --git a/src/EPiServer.Marketing.KPI/Common/ContentComparatorKPI.cs b/src/EPiServer.Marketing.KPI/Common/ContentComparatorKPI.cs index 9f1bcde76..2b13d9570 100644 --- a/src/EPiServer.Marketing.KPI/Common/ContentComparatorKPI.cs +++ b/src/EPiServer.Marketing.KPI/Common/ContentComparatorKPI.cs @@ -1,21 +1,17 @@ using EPiServer.Core; +using EPiServer.Framework.Localization; using EPiServer.Marketing.KPI.Common.Attributes; +using EPiServer.Marketing.KPI.Common.Helpers; +using EPiServer.Marketing.KPI.Exceptions; using EPiServer.Marketing.KPI.Manager.DataClass; +using EPiServer.Marketing.KPI.Results; using EPiServer.ServiceLocation; +using EPiServer.Web.Routing; using System; using System.Collections.Generic; -using System.Runtime.Serialization; -using Microsoft.AspNetCore.Mvc.Routing; -using EPiServer.Framework.Localization; -using EPiServer.Marketing.KPI.Exceptions; -using EPiServer.Web.Mvc.Html; -using EPiServer.Marketing.KPI.Results; -using EPiServer.Web.Routing; -using System.Web; -using System.Runtime.Caching; -using EPiServer.Marketing.KPI.Common.Helpers; using System.Linq; -using EPiServer.Web.Mvc; +using System.Runtime.Caching; +using System.Runtime.Serialization; namespace EPiServer.Marketing.KPI.Common { @@ -138,8 +134,9 @@ public override IKpiResult Evaluate(object sender, EventArgs e) // if the target content is the start page, we also need to check // the path to make sure its not just a request for some other static // resources such as css or jscript - retval = (_startpagepaths.Contains(_kpiHelper.Service.GetRequestPath(), StringComparer.OrdinalIgnoreCase) - && ContentGuid.Equals(ea.Content.ContentGuid)); + retval = _startpagepaths.Any(path => path.Trim('/') + .Equals(_kpiHelper.Service.GetRequestPath().Trim('/'), StringComparison.OrdinalIgnoreCase)) + && ContentGuid.Equals(ea.Content.ContentGuid); } else { diff --git a/test/EPiServer.Marketing.KPI.Test/Common/ContentComparatorKPITests.cs b/test/EPiServer.Marketing.KPI.Test/Common/ContentComparatorKPITests.cs index 1fb2c6857..3ba7455ff 100644 --- a/test/EPiServer.Marketing.KPI.Test/Common/ContentComparatorKPITests.cs +++ b/test/EPiServer.Marketing.KPI.Test/Common/ContentComparatorKPITests.cs @@ -1,20 +1,19 @@ using EPiServer.Core; -using EPiServer.Marketing.KPI.Common; -using EPiServer.Marketing.KPI.Results; -using Moq; -using System; -using System.Collections.Generic; -using System.Threading; using EPiServer.DataAbstraction; using EPiServer.Framework.Localization; +using EPiServer.Marketing.KPI.Common; +using EPiServer.Marketing.KPI.Common.Helpers; using EPiServer.Marketing.KPI.Exceptions; using EPiServer.Marketing.KPI.Manager.DataClass; using EPiServer.Marketing.KPI.Test.Fakes; using EPiServer.ServiceLocation; using EPiServer.Web.Routing; -using Xunit; -using EPiServer.Marketing.KPI.Common.Helpers; using Microsoft.Extensions.DependencyInjection; +using Moq; +using System; +using System.Collections.Generic; +using System.Threading; +using Xunit; namespace EPiServer.Marketing.KPI.Test.Common { @@ -256,6 +255,23 @@ public void Kpi_Converts_IfContentPathEqualsRequestedPath_IgnoringRequestedConte Assert.True(retVal.HasConverted); } + [Fact] + public void Kpi_Converts_IfRequestedPathEqualsStartPagePath_IgnoringUrlTrailingSlash_AndGuidsAreEqual() + { + var content3 = new Mock(); + content3.SetupGet(get => get.ContentLink).Returns(ContentReference.StartPage); + content3.SetupGet(get => get.ContentGuid).Returns(LandingPageGuid); + var arg = new ContentEventArgs(new ContentReference()) { Content = content3.Object }; + + var kpi = GetUnitUnderTest(); + _contentRepo.Setup(c => c.Get(It.Is(g => g == LandingPageGuid))).Returns(content3.Object); + _kpiHelper.Setup(call => call.GetUrl(It.Is(c => c == ContentReference.StartPage))).Returns("/en/"); + _kpiHelper.Setup(call => call.GetRequestPath()).Returns("/en"); + + var retVal = kpi.Evaluate(new object(), arg); + Assert.True(retVal.HasConverted); + } + [Fact] public void Kpi_DoesNotConvert_IfContentPathEqualsRequestedPath_AndGuidsAreNotEqual() {