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
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public enum ParameterType
GREATER_THAN
}

private static Regex RANGE_PATTERN = new Regex(@"([0-9]+[\\.0-9]*)\\-([0-9]+[\\.0-9]*)");
private static Regex LESS_THAN_PATTERN = new Regex(@"<([0-9]+[\\.0-9]*)");
private static Regex GREATER_THAN_PATTERN = new Regex(@">([0-9]+[\\.0-9]*)");
private static Regex RANGE_PATTERN = new Regex(@"(?'min'[0-9]+[\.0-9]*)-(?'max'[0-9]+[\.0-9]*)", RegexOptions.Compiled);
private static Regex LESS_THAN_PATTERN = new Regex(@"<(?'lt'[0-9]+[\\.0-9]*)", RegexOptions.Compiled);
private static Regex GREATER_THAN_PATTERN = new Regex(@">(?'gt'[0-9]+[\\.0-9]*)", RegexOptions.Compiled);

private string _name;
private List<string> _values = new List<string>();
Expand Down Expand Up @@ -66,22 +66,21 @@ public FacetParameter(string name, string strValue)
else if ( rangeMatcher.Success )
{
this.type = ParameterType.RANGE;
String min = rangeMatcher.Value;
rangeMatcher = rangeMatcher.NextMatch();
String max = rangeMatcher.Value;
String min = rangeMatcher.Groups["min"].Value;
String max = rangeMatcher.Groups["max"].Value;
this._values.Add(min);
this._values.Add(max);
}
else if ( lessThanMatcher.Success )
{
this.type = ParameterType.LESS_THAN;
String value = lessThanMatcher.Value;
String value = lessThanMatcher.Groups["lt"].Value;
this._values.Add(value);
}
else if (greaterThanMatcher.Success )
{
this.type = ParameterType.GREATER_THAN;
String value = greaterThanMatcher.Value;
String value = greaterThanMatcher.Groups["gt"].Value;
this._values.Add(value);
}
else
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;

using Xunit;

using SDL.ECommerce.Api;

namespace SDL.ECommerce.UnitTests.Api
{
using System.Linq;

public class FacetParameter_Test
{
[InlineData("10", FacetParameter.ParameterType.MULTISELECT, "10")]
[InlineData("10|20|30", FacetParameter.ParameterType.MULTISELECT, "10", "20", "30")]
[InlineData(">10", FacetParameter.ParameterType.GREATER_THAN, "10")]
[InlineData("<10", FacetParameter.ParameterType.LESS_THAN, "10")]
[InlineData("10-20", FacetParameter.ParameterType.RANGE, "10","20")]
[InlineData("blue", FacetParameter.ParameterType.MULTISELECT, "blue")]
[InlineData("blue|red", FacetParameter.ParameterType.MULTISELECT, "blue", "red")]
[Theory]
public void FacetParameterShouldBeMapped(string facetValue, FacetParameter.ParameterType expectedType, params string[] expectedValue)
{
var facetParameter = new FacetParameter("testParam", facetValue);

Assert.Equal(expectedValue.ToList(), facetParameter.Values);
Assert.Equal(expectedType, facetParameter.Type);
}

[InlineData("color_val", "80", FacetParameter.ParameterType.SINGLEVALUE, "color", "80")]
[InlineData("color_val2", "80", FacetParameter.ParameterType.MULTISELECT, "color_val2", "80")]
[Theory]
public void WhenFacetNameEndsWith_val_ThenFacetTypeShouldBeSingleValue(string facetName, string facetValue, FacetParameter.ParameterType expectedType, string expectedName, params string[] expectedValue)
{
var facetParameter = new FacetParameter(facetName, facetValue);

Assert.Equal(expectedValue, facetParameter.Values);
Assert.Equal(expectedType, facetParameter.Type);
}

[Fact]
public void TestFacetParameter()
{
var facet = new FacetParameter("brand", "adidas|dkny");
Console.WriteLine("Facet: " + facet.Name + ", type: " + facet.Type);
Console.WriteLine("Contains 'adidas': " + facet.ContainsValue("adidas"));
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\xunit.core.2.4.1\build\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.4.1\build\xunit.core.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand Down Expand Up @@ -190,20 +191,16 @@
<HintPath>..\..\packages\Sdl.Web.Delivery.10.1.0\lib\net452\Tridion.ContentDelivery.UGC.dll</HintPath>
</Reference>
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
<HintPath>..\..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll</HintPath>
</Reference>
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll</HintPath>
<Private>True</Private>
<Reference Include="xunit.assert, Version=2.4.1.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll</HintPath>
</Reference>
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath>
<Private>True</Private>
<Reference Include="xunit.core, Version=2.4.1.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll</HintPath>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
<Private>True</Private>
<Reference Include="xunit.execution.desktop, Version=2.4.1.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll</HintPath>
</Reference>
</ItemGroup>
<Choose>
Expand All @@ -215,7 +212,7 @@
<Otherwise />
</Choose>
<ItemGroup>
<Compile Include="Api\UnitTests.cs" />
<Compile Include="Api\FacetParameter_Test.cs" />
<Compile Include="Customizations\MvcCustomization.cs" />
<Compile Include="DependencyTestProvider.cs" />
<Compile Include="Dxa\Controllers\BaseEComWidgetController_Test.cs" />
Expand Down Expand Up @@ -263,6 +260,9 @@
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\..\packages\xunit.analyzers.0.10.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand All @@ -289,7 +289,10 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Sdl.Dxa.Framework.Web8.2.0.0\build\net452\Sdl.Dxa.Framework.Web8.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Sdl.Dxa.Framework.Web8.2.0.0\build\net452\Sdl.Dxa.Framework.Web8.targets'))" />
<Error Condition="!Exists('..\..\packages\xunit.core.2.4.1\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.4.1\build\xunit.core.props'))" />
<Error Condition="!Exists('..\..\packages\xunit.core.2.4.1\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.4.1\build\xunit.core.targets'))" />
</Target>
<Import Project="..\..\packages\xunit.core.2.4.1\build\xunit.core.targets" Condition="Exists('..\..\packages\xunit.core.2.4.1\build\xunit.core.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net452" />
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net452" />
<package id="Unity" version="3.5.1404.0" targetFramework="net452" />
<package id="xunit" version="2.1.0" targetFramework="net452" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net452" />
<package id="xunit.assert" version="2.1.0" targetFramework="net452" />
<package id="xunit.core" version="2.1.0" targetFramework="net452" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net452" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net452" />
<package id="xunit" version="2.4.1" targetFramework="net452" />
<package id="xunit.abstractions" version="2.0.3" targetFramework="net452" />
<package id="xunit.analyzers" version="0.10.0" targetFramework="net452" />
<package id="xunit.assert" version="2.4.1" targetFramework="net452" />
<package id="xunit.core" version="2.4.1" targetFramework="net452" />
<package id="xunit.extensibility.core" version="2.4.1" targetFramework="net452" />
<package id="xunit.extensibility.execution" version="2.4.1" targetFramework="net452" />
</packages>