Skip to content

Commit

Permalink
Merge pull request 6710 from hotfix/v4.3.16 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Project Collection Build Service (51degrees) authored and Project Collection Build Service (51degrees) committed Feb 28, 2022
2 parents 5800829 + 8896779 commit 6639ece
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public override IEnumerable<IValueMetaData> Values
/// The tier of the data that is currently being used by this engine.
/// For example, 'Lite' or 'Enterprise'
/// </summary>
public override string DataSourceTier => _engine.getType();
public override string DataSourceTier => _engine.getProduct();

/// <summary>
/// True if the data used by this engine will automatically be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public string getType()
return _object.getType();
}

public string getProduct()
{
return _object.getProduct();
}

public IDateSwigWrapper getUpdateAvailableTime()
{
return new DateSwigWrapper(_object.getUpdateAvailableTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ internal interface IEngineSwigWrapper : IDisposable

string getType();

string getProduct();

void refreshData();

void refreshData(byte[] data, int dataSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
namespace FiftyOne.DeviceDetection.Hash.Tests.Core.FlowElements
{
[TestClass]
public class EngineAndBuilderTests
public class EngineBuilderTests
{
DeviceDetectionHashEngineBuilder _builder;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
* Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
*
* This Original Work is licensed under the European Union Public Licence (EUPL)
* v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
* ********************************************************************* */

using TestHelpers = FiftyOne.DeviceDetection.TestHelpers;
using FiftyOne.Pipeline.Engines;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace FiftyOne.DeviceDetection.Hash.Tests.Core.FlowElements
{
[TestClass]
[TestCategory("Core")]
[TestCategory("Process")]
public class EngineTests : TestsBase
{

[TestMethod]
public void Engine_DataDownloadType()
{
TestInitialize(PerformanceProfiles.MaxPerformance);
Assert.AreEqual(
"HashV41",
Wrapper.Engine.GetDataDownloadType("None"));
}

[TestMethod]
public void Engine_DataSourceTier_Lite()
{
TestInitialize(PerformanceProfiles.MaxPerformance,
TestHelpers.Constants.LITE_HASH_DATA_FILE_NAME);
Assert.AreEqual(
"Lite",
Wrapper.Engine.DataSourceTier);
}

[TestMethod]
public void Engine_DataSourceTier_Enterprise()
{
TestInitialize(PerformanceProfiles.MaxPerformance,
TestHelpers.Constants.ENTERPRISE_HASH_DATA_FILE_NAME);
Assert.AreEqual(
"Enterprise",
Wrapper.Engine.DataSourceTier);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ public virtual void Cleanup()
}
}

protected void TestInitialize(PerformanceProfiles profile)
protected void TestInitialize(
PerformanceProfiles profile, String dataFileName = Constants.LITE_HASH_DATA_FILE_NAME)
{
Wrapper = new WrapperHash(
TestHelpers.Utils.GetFilePath(Constants.HASH_DATA_FILE_NAME),
TestHelpers.Utils.GetFilePath(dataFileName),
profile);
UserAgents = new UserAgentGenerator(
TestHelpers.Utils.GetFilePath(Constants.UA_FILE_NAME));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ namespace FiftyOne.DeviceDetection.TestHelpers
public static class Constants
{
public const int UAS_TO_TEST = 10;
public const string HASH_DATA_FILE_NAME = "51Degrees-LiteV4.1.hash";
public const string ENTERPRISE_HASH_DATA_FILE_NAME = "Enterprise-HashV41.hash";
public const string LITE_HASH_DATA_FILE_NAME = "51Degrees-LiteV4.1.hash";
public const string UA_FILE_NAME = "20000 User Agents.csv";

public static string[] ExcludedProperties = { "JavascriptImageOptimiser" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ public class DeviceDetectionPipelineBuilderTests
/// The license key to use when performing automatic update.
/// </param>
[DataTestMethod]
[DataRow(TestHelpers.Constants.HASH_DATA_FILE_NAME, true, false, null)]
[DataRow(TestHelpers.Constants.HASH_DATA_FILE_NAME, false, false, null)]
[DataRow(TestHelpers.Constants.HASH_DATA_FILE_NAME, true, true, null)]
[DataRow(TestHelpers.Constants.HASH_DATA_FILE_NAME, false, true, null)]
[DataRow(TestHelpers.Constants.HASH_DATA_FILE_NAME, true, false, "key1")]
[DataRow(TestHelpers.Constants.HASH_DATA_FILE_NAME, true, true, "key1")]
[DataRow(TestHelpers.Constants.LITE_HASH_DATA_FILE_NAME, true, false, null)]
[DataRow(TestHelpers.Constants.LITE_HASH_DATA_FILE_NAME, false, false, null)]
[DataRow(TestHelpers.Constants.LITE_HASH_DATA_FILE_NAME, true, true, null)]
[DataRow(TestHelpers.Constants.LITE_HASH_DATA_FILE_NAME, false, true, null)]
[DataRow(TestHelpers.Constants.LITE_HASH_DATA_FILE_NAME, true, false, "key1")]
[DataRow(TestHelpers.Constants.LITE_HASH_DATA_FILE_NAME, true, true, "key1")]
public void DeviceDetectionPipelineBuilder_CheckConfiguration(
string datafilename, bool autoUpdate, bool shareUsage, string licenseKey)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,27 @@ public class DeviceDetectionTests

[DataTestMethod]
// ******** Hash with a single thread *********
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.MaxPerformance, false, false, DisplayName = "Hash-MaxPerformance-NoLazyLoad-SingleThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.HighPerformance, false, false, DisplayName = "Hash-HighPerformance-NoLazyLoad-SingleThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.LowMemory, false, false, DisplayName = "Hash-LowMemory-NoLazyLoad-SingleThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.Balanced, false, false, DisplayName = "Hash-Balanced-NoLazyLoad-SingleThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.BalancedTemp, false, false, DisplayName = "Hash-BalancedTemp-NoLazyLoad-SingleThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.MaxPerformance, true, false, DisplayName = "Hash-MaxPerformance-LazyLoad-SingleThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.HighPerformance, true, false, DisplayName = "Hash-HighPerformance-LazyLoad-SingleThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.LowMemory, true, false, DisplayName = "Hash-LowMemory-LazyLoad-SingleThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.Balanced, true, false, DisplayName = "Hash-Balanced-LazyLoad-SingleThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.BalancedTemp, true, false, DisplayName = "Hash-BalancedTemp-LazyLoad-SingleThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.MaxPerformance, false, false, DisplayName = "Hash-MaxPerformance-NoLazyLoad-SingleThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.HighPerformance, false, false, DisplayName = "Hash-HighPerformance-NoLazyLoad-SingleThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.LowMemory, false, false, DisplayName = "Hash-LowMemory-NoLazyLoad-SingleThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.Balanced, false, false, DisplayName = "Hash-Balanced-NoLazyLoad-SingleThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.BalancedTemp, false, false, DisplayName = "Hash-BalancedTemp-NoLazyLoad-SingleThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.MaxPerformance, true, false, DisplayName = "Hash-MaxPerformance-LazyLoad-SingleThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.HighPerformance, true, false, DisplayName = "Hash-HighPerformance-LazyLoad-SingleThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.LowMemory, true, false, DisplayName = "Hash-LowMemory-LazyLoad-SingleThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.Balanced, true, false, DisplayName = "Hash-Balanced-LazyLoad-SingleThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.BalancedTemp, true, false, DisplayName = "Hash-BalancedTemp-LazyLoad-SingleThread")]
// ******** Hash with multiple threads *********
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.MaxPerformance, false, true, DisplayName = "Hash-MaxPerformance-NoLazyLoad-MultiThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.HighPerformance, false, true, DisplayName = "Hash-HighPerformance-NoLazyLoad-MultiThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.LowMemory, false, true, DisplayName = "Hash-LowMemory-NoLazyLoad-MultiThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.Balanced, false, true, DisplayName = "Hash-Balanced-NoLazyLoad-MultiThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.BalancedTemp, false, true, DisplayName = "Hash-BalancedTemp-NoLazyLoad-MultiThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.MaxPerformance, true, true, DisplayName = "Hash-MaxPerformance-LazyLoad-MultiThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.HighPerformance, true, true, DisplayName = "Hash-HighPerformance-LazyLoad-MultiThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.LowMemory, true, true, DisplayName = "Hash-LowMemory-LazyLoad-MultiThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.Balanced, true, true, DisplayName = "Hash-Balanced-LazyLoad-MultiThread")]
[DataRow(Constants.HASH_DATA_FILE_NAME, PerformanceProfiles.BalancedTemp, true, true, DisplayName = "Hash-BalancedTemp-LazyLoad-MultiThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.MaxPerformance, false, true, DisplayName = "Hash-MaxPerformance-NoLazyLoad-MultiThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.HighPerformance, false, true, DisplayName = "Hash-HighPerformance-NoLazyLoad-MultiThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.LowMemory, false, true, DisplayName = "Hash-LowMemory-NoLazyLoad-MultiThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.Balanced, false, true, DisplayName = "Hash-Balanced-NoLazyLoad-MultiThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.BalancedTemp, false, true, DisplayName = "Hash-BalancedTemp-NoLazyLoad-MultiThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.MaxPerformance, true, true, DisplayName = "Hash-MaxPerformance-LazyLoad-MultiThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.HighPerformance, true, true, DisplayName = "Hash-HighPerformance-LazyLoad-MultiThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.LowMemory, true, true, DisplayName = "Hash-LowMemory-LazyLoad-MultiThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.Balanced, true, true, DisplayName = "Hash-Balanced-LazyLoad-MultiThread")]
[DataRow(Constants.LITE_HASH_DATA_FILE_NAME, PerformanceProfiles.BalancedTemp, true, true, DisplayName = "Hash-BalancedTemp-LazyLoad-MultiThread")]
public void Hash_AllConfigurations_100_UserAgents(
string datafileName,
PerformanceProfiles performanceProfile,
Expand Down

0 comments on commit 6639ece

Please sign in to comment.