diff --git a/51degrees 4.sln b/51degrees 4.sln index dd9ae53..70b2cf5 100644 --- a/51degrees 4.sln +++ b/51degrees 4.sln @@ -10,10 +10,6 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{403E28D4-A922-40D4-822B-4FA005B595AD}" ProjectSection(SolutionItems) = preProject data\20000 User Agents.csv = data\20000 User Agents.csv - data\51Degrees-LiteV3.0.trie = data\51Degrees-LiteV3.0.trie - data\51Degrees-LiteV3.1.dat = data\51Degrees-LiteV3.1.dat - data\51Degrees-LiteV3.2.dat = data\51Degrees-LiteV3.2.dat - data\51Degrees-LiteV3.2.trie = data\51Degrees-LiteV3.2.trie data\README.md = data\README.md EndProjectSection EndProject diff --git a/FoundationV3/FiftyOne.Foundation 4.csproj b/FoundationV3/FiftyOne.Foundation 4.csproj index 2796770..2e164c2 100644 --- a/FoundationV3/FiftyOne.Foundation 4.csproj +++ b/FoundationV3/FiftyOne.Foundation 4.csproj @@ -189,15 +189,12 @@ - Code - - @@ -225,9 +222,6 @@ - - Code - diff --git a/FoundationV3/FiftyOne.Foundation 4.project.lock.json b/FoundationV3/FiftyOne.Foundation 4.project.lock.json index 8db745c..c2707bb 100644 --- a/FoundationV3/FiftyOne.Foundation 4.project.lock.json +++ b/FoundationV3/FiftyOne.Foundation 4.project.lock.json @@ -1,5 +1,4 @@ { - "locked": false, "version": 2, "targets": { ".NETFramework,Version=v4.0": {}, @@ -11,5 +10,8 @@ ".NETFramework,Version=v4.0": [] }, "tools": {}, - "projectFileToolGroups": {} + "projectFileToolGroups": {}, + "packageFolders": { + "C:\\Users\\Stephen\\.nuget\\packages\\": {} + } } \ No newline at end of file diff --git a/FoundationV3/FiftyOne.Foundation SQL.sqlproj b/FoundationV3/FiftyOne.Foundation SQL.sqlproj index dfba3d3..ccc54c9 100644 --- a/FoundationV3/FiftyOne.Foundation SQL.sqlproj +++ b/FoundationV3/FiftyOne.Foundation SQL.sqlproj @@ -139,11 +139,8 @@ - - - @@ -153,9 +150,6 @@ - - Code - diff --git a/FoundationV3/Mobile/Detection/Factories/TrieFactory.cs b/FoundationV3/Mobile/Detection/Factories/TrieFactory.cs deleted file mode 100644 index 7c47141..0000000 --- a/FoundationV3/Mobile/Detection/Factories/TrieFactory.cs +++ /dev/null @@ -1,144 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ - -using System; -using System.Linq; -using System.Text; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection.Entities.Stream; -using FiftyOne.Foundation.Mobile.Detection.Readers; - -namespace FiftyOne.Foundation.Mobile.Detection.Factories -{ - /// - /// Reader used to create a provider from data structured in a decision - /// tree format. - /// - public static class TrieFactory - { - /// - /// Creates a new provider from the byte array supplied. - /// - /// - /// - public static TrieProvider Create(byte[] array) - { - return Create(new Pool(new SourceMemory(array))); - } - - /// - /// Creates a new provider from the binary file supplied. - /// - /// Binary file to use to create the provider. - /// A new provider initialised with data from the file provided. - public static TrieProvider Create(string file) - { - return Create(file, false); - } - - /// - /// Creates a new provider from the binary file supplied. - /// - /// Binary file to use to create the provider. - /// True if the file should be deleted when the source is disposed - /// A new provider initialised with data from the file provided. - public static TrieProvider Create(string file, bool isTempFile) - { - FileInfo fileInfo = new FileInfo(file); - if (fileInfo.Exists) - { - return Create(new Pool(new SourceFile(file, isTempFile))); - } - return null; - } - - private static TrieProvider Create(Pool pool) - { - var reader = pool.GetReader(); - try - { - // Check the version number is correct for this API. - var version = reader.ReadUInt16(); - - // Construct the right provider. - switch(version) - { - case 3: - return new TrieProviderV3( - Encoding.ASCII.GetString(reader.ReadBytes((int)reader.ReadUInt32())), - ReadStrings(reader), - ReadProperties(reader), - ReadDevices(reader), - ReadLookupList(reader), - reader.ReadInt64(), - reader.BaseStream.Position, - pool); - case 32: - return new TrieProviderV32( - Encoding.ASCII.GetString(reader.ReadBytes((int)reader.ReadUInt32())), - ReadStrings(reader), - ReadHeaders(reader), - ReadProperties(reader), - ReadDevices(reader), - ReadLookupList(reader), - reader.ReadInt64(), - reader.BaseStream.Position, - pool); - default: - throw new MobileException(String.Format( - "Version mismatch. Data is version '{0}' for '{1}' reader", - version, - String.Join(",", BinaryConstants.SupportedTrieFormatVersions.Select(i => i.Value.ToString())))); - } - } - finally - { - // Return the reader back to the pool. - pool.Release(reader); - } - } - - private static byte[] ReadLookupList(BinaryReader reader) - { - return reader.ReadBytes((int)reader.ReadUInt32()); - } - - private static byte[] ReadStrings(BinaryReader reader) - { - return reader.ReadBytes((int)reader.ReadUInt32()); - } - - private static byte[] ReadProperties(BinaryReader reader) - { - return reader.ReadBytes((int)reader.ReadUInt32()); - } - - private static byte[] ReadHeaders(BinaryReader reader) - { - return reader.ReadBytes((int)reader.ReadUInt32()); - } - - private static byte[] ReadDevices(BinaryReader reader) - { - return reader.ReadBytes((int)reader.ReadUInt32()); - } - } -} diff --git a/FoundationV3/project.json b/FoundationV3/project.json index 131a91d..7f48792 100644 --- a/FoundationV3/project.json +++ b/FoundationV3/project.json @@ -89,7 +89,6 @@ "Mobile/Detection/Factories/EntityLoaderFactory.cs", "Mobile/Detection/Factories/MemoryFactory.cs", "Mobile/Detection/Factories/StreamFactory.cs", - "Mobile/Detection/Factories/TrieFactory.cs", "Mobile/Detection/Readers/Reader.cs", "Mobile/Detection/Readers/Source.cs", "Mobile/Detection/Controller.cs", @@ -107,9 +106,6 @@ "Mobile/Detection/Provider.cs", "Mobile/Detection/Search.cs", "Mobile/Detection/StreamList.cs", - "Mobile/Detection/TrieProvider.cs", - "Mobile/Detection/TrieProviderV3.cs", - "Mobile/Detection/TrieProviderV32.cs", "Mobile/MobileException.cs", "SerializableAttribute.cs" ] diff --git a/Integration Tests/API/Lite/V30APITrie.cs b/Integration Tests/API/Lite/V30APITrie.cs deleted file mode 100644 index 594828d..0000000 --- a/Integration Tests/API/Lite/V30APITrie.cs +++ /dev/null @@ -1,34 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ - -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace FiftyOne.Tests.Integration.API.Lite -{ - [TestClass] - public class V30APITrie : TrieBase - { - protected override string DataFile - { - get { return Utils.GetDataFile(Constants.LITE_TRIE_V30); } - } - } -} diff --git a/Integration Tests/API/Lite/V32APITrie.cs b/Integration Tests/API/Lite/V32APITrie.cs deleted file mode 100644 index 8cad3fe..0000000 --- a/Integration Tests/API/Lite/V32APITrie.cs +++ /dev/null @@ -1,34 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ - -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace FiftyOne.Tests.Integration.API.Lite -{ - [TestClass] - public class V32APITrie : TrieBase - { - protected override string DataFile - { - get { return Utils.GetDataFile(Constants.LITE_TRIE_V32); } - } - } -} diff --git a/Integration Tests/API/TrieBase.cs b/Integration Tests/API/TrieBase.cs deleted file mode 100644 index b6efbe3..0000000 --- a/Integration Tests/API/TrieBase.cs +++ /dev/null @@ -1,184 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ - -using System; -using System.Text; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Entities; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using FiftyOne.Foundation.Mobile.Detection; -using System.Collections.Specialized; - -namespace FiftyOne.Tests.Integration.API -{ - /// - /// Tests the APIs with different combinations of good and bad inputs. - /// - public abstract class TrieBase : IDisposable - { - private TrieProvider _provider; - - /// - /// The name of the data file to use with the test. - /// - protected abstract string DataFile { get; } - - [TestInitialize()] - public void CreateDataSet() - { - Utils.CheckFileExists(DataFile); - _provider = TrieFactory.Create(DataFile, false); - } - - [TestMethod] - public void API_Trie_NullUserAgent() - { - FetchAllProperties(_provider.GetDeviceIndex((string)null)); - } - - [TestMethod] - public void API_Trie_EmptyUserAgent() - { - FetchAllProperties(_provider.GetDeviceIndex(String.Empty)); - } - - [TestMethod] - public void API_Trie_LongUserAgent() - { - var userAgent = String.Join(" ", UserAgentGenerator.GetEnumerable(10, 10)); - FetchAllProperties(_provider.GetDeviceIndex(userAgent)); - } - - [TestMethod] - public void API_Trie_NullHeaders() - { - FetchAllProperties(_provider.GetDeviceIndexes((NameValueCollection)null)); - } - - [TestMethod] - public void API_Trie_EmptyHeaders() - { - var headers = new NameValueCollection(); - FetchAllProperties(_provider.GetDeviceIndexes(headers)); - } - - [TestMethod] - public void API_Trie_AllHeaders() - { - var headers = new NameValueCollection(); - foreach (var header in _provider.HttpHeaders) - { - headers.Add(header, UserAgentGenerator.GetRandomUserAgent(0)); - } - FetchAllProperties(_provider.GetDeviceIndexes(headers)); - } - - [TestMethod] - public void API_Trie_AllHeadersNull() - { - var headers = new NameValueCollection(); - foreach (var header in _provider.HttpHeaders) - { - headers.Add(header, null); - } - FetchAllProperties(_provider.GetDeviceIndexes(headers)); - } - - [TestMethod] - public void API_Trie_DuplicateHeaders() - { - var headers = new NameValueCollection(); - for(var i = 0; i < 5; i++) - { - foreach (var header in _provider.HttpHeaders) - { - headers.Add(header, UserAgentGenerator.GetRandomUserAgent(0)); - } - } - FetchAllProperties(_provider.GetDeviceIndexes(headers)); - } - - [TestMethod] - public void API_Trie_DuplicateHeadersNull() - { - var headers = new NameValueCollection(); - for (var i = 0; i < 5; i++) - { - foreach (var header in _provider.HttpHeaders) - { - headers.Add(header, null); - } - } - FetchAllProperties(_provider.GetDeviceIndexes(headers)); - } - - [TestCleanup] - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (_provider != null) - { - _provider.Dispose(); - } - } - - private void FetchAllProperties(IDictionary deviceIndexes) - { - var checkSum = 0; - foreach (var propertyName in _provider.PropertyNames) - { - var value = _provider.GetPropertyValue(deviceIndexes, propertyName); - Console.WriteLine("Property: {0} with value {1}", - propertyName, - value); - if (value != null) - { - checkSum += _provider.GetPropertyValue(deviceIndexes, propertyName).GetHashCode(); - } - } - Console.WriteLine("Check sum: {0}", checkSum); - } - - private void FetchAllProperties(int deviceIndex) - { - var checkSum = 0; - foreach(var propertyName in _provider.PropertyNames) - { - var value = _provider.GetPropertyValue(deviceIndex, propertyName); - Console.WriteLine("Property: {0} with value {1}", - propertyName, - value); - if (value != null) - { - checkSum += _provider.GetPropertyValue(deviceIndex, propertyName).GetHashCode(); - } - } - Console.WriteLine("Check sum: {0}", checkSum); - } - } -} diff --git a/Integration Tests/Common/Utils.cs b/Integration Tests/Common/Utils.cs index ae5bf2c..feb37a4 100644 --- a/Integration Tests/Common/Utils.cs +++ b/Integration Tests/Common/Utils.cs @@ -261,28 +261,6 @@ internal static Results DetectLoopSingleThreaded(Provider provider, IEnumerable< return results; } - /// - /// In a single thread loops through the useragents in the file - /// provided perform a match with the data set provided passing - /// control back to the method provided for further processing. - /// - /// - /// - /// - /// Counts for each of the methods used - internal static Results DetectLoopSingleThreaded(TrieProvider provider, IEnumerable userAgents, ProcessTrie method, object state) - { - var results = new Results(); - foreach (var line in userAgents) - { - method(results, provider.GetDeviceIndex(line.Trim()), state); - results.Count++; - } - ReportMethods(results.Methods); - ReportTime(results); - return results; - } - /// /// Using multiple threads loops through the useragents in the file /// provided perform a match with the data set provided passing @@ -313,28 +291,6 @@ internal static Results DetectLoopMultiThreaded(Provider provider, IEnumerable - /// Using multiple threads loops through the useragents in the file - /// provided perform a match with the data set provided passing - /// control back to the method provided for further processing. - /// - /// - /// - /// - /// Counts for each of the methods used - internal static Results DetectLoopMultiThreaded(TrieProvider provider, IEnumerable userAgents, ProcessTrie method, object state) - { - var results = new Results(); - Parallel.ForEach(userAgents, line => - { - method(results, provider.GetDeviceIndex(line.Trim()), state); - Interlocked.Increment(ref results.Count); - }); - ReportMethods(results.Methods); - ReportTime(results); - return results; - } - public static void ReportMethods(Dictionary methods) { var total = methods.Sum(i => i.Value); @@ -448,19 +404,6 @@ public static void TrieDoNothing(Results results, int deviceIndex, object state) // Do nothing. } - public static void RetrieveTriePropertyValues(Results results, int deviceIndex, object state) - { - if (state != null) - { - var checkSum = 0; - foreach (var property in ((TrieProvider)state).PropertyNames) - { - checkSum += ((TrieProvider)state).GetPropertyValue(deviceIndex, property).GetHashCode(); - } - Interlocked.Add(ref results.CheckSum, checkSum); - } - } - internal static void CheckFileExists(string dataFile) { if (dataFile == null || File.Exists(dataFile) == false) diff --git a/Integration Tests/HttpHeaders/Enterprise/V32TrieFile.cs b/Integration Tests/HttpHeaders/Enterprise/V32TrieFile.cs deleted file mode 100644 index bf49110..0000000 --- a/Integration Tests/HttpHeaders/Enterprise/V32TrieFile.cs +++ /dev/null @@ -1,61 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; - -namespace FiftyOne.Tests.Integration.HttpHeaders.Enterprise -{ - [TestClass] - public class V32TrieFile : TrieCombinations - { - protected override string DataFile - { - get { return Utils.GetDataFile(Constants.ENTERPRISE_TRIE_V32); } - } - - [TestInitialize()] - public void CreateDataSet() - { - Utils.CheckFileExists(DataFile); - _provider = TrieFactory.Create(DataFile); - } - - [TestMethod] - public void EnterpriseV32TrieFile_OperaMiniSamsung() - { - base.OperaMini_Samsung(); - } - - [TestMethod] - public void EnterpriseV32TrieFile_OperaMini_HTC() - { - base.OperaMini_HTC(); - } - - [TestMethod] - public void EnterpriseV32TrieFile_OperaMini_iPhone() - { - base.OperaMini_iPhone(); - } - } -} diff --git a/Integration Tests/HttpHeaders/Premium/V32TrieFile.cs b/Integration Tests/HttpHeaders/Premium/V32TrieFile.cs deleted file mode 100644 index 5f3976b..0000000 --- a/Integration Tests/HttpHeaders/Premium/V32TrieFile.cs +++ /dev/null @@ -1,61 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; - -namespace FiftyOne.Tests.Integration.HttpHeaders.Premium -{ - [TestClass] - public class V32TrieFile : TrieCombinations - { - protected override string DataFile - { - get { return Utils.GetDataFile(Constants.PREMIUM_TRIE_V32); } - } - - [TestInitialize()] - public void CreateDataSet() - { - Utils.CheckFileExists(DataFile); - _provider = TrieFactory.Create(DataFile); - } - - [TestMethod] - public void PremiumV32TrieFile_OperaMiniSamsung() - { - base.OperaMini_Samsung(); - } - - [TestMethod] - public void PremiumV32TrieFile_OperaMini_HTC() - { - base.OperaMini_HTC(); - } - - [TestMethod] - public void PremiumV32TrieFile_OperaMini_iPhone() - { - base.OperaMini_iPhone(); - } - } -} diff --git a/Integration Tests/HttpHeaders/TrieBase.cs b/Integration Tests/HttpHeaders/TrieBase.cs deleted file mode 100644 index 028b86f..0000000 --- a/Integration Tests/HttpHeaders/TrieBase.cs +++ /dev/null @@ -1,110 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ - -using FiftyOne.Foundation.Mobile.Detection; -using FiftyOne.Foundation.Mobile.Detection.Entities; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; - -namespace FiftyOne.Tests.Integration.HttpHeaders -{ - public abstract class TrieBase : IDisposable - { - internal class Validation : Dictionary - { - internal readonly TrieProvider Provider; - - internal Validation(TrieProvider provider) - { - Provider = provider; - } - - public void Add(string property, string pattern) - { - Add(property, new Regex(pattern, RegexOptions.Compiled)); - } - } - - protected abstract string DataFile { get; } - - protected TrieProvider _provider; - - internal Utils.Results Process(string userAgentPattern, string devicePattern, Validation state) - { - var results = new FiftyOne.Tests.Integration.Utils.Results(); - var random = new Random(0); - var httpHeaders = _provider.HttpHeaders.Where(i => i.Equals("User-Agent") == false).ToArray(); - - // Loop through setting 2 User-Agent headers. - var userAgentIterator = UserAgentGenerator.GetEnumerable(20000, userAgentPattern).GetEnumerator(); - var deviceIterator = UserAgentGenerator.GetEnumerable(20000, devicePattern).GetEnumerator(); - while(userAgentIterator.MoveNext() && - deviceIterator.MoveNext()) - { - var headers = new NameValueCollection(); - headers.Add(httpHeaders[random.Next(httpHeaders.Length)], deviceIterator.Current); - headers.Add("User-Agent", userAgentIterator.Current); - var indexes = _provider.GetDeviceIndexes(headers); - Assert.IsTrue(indexes.Count > 0, "No indexes were found"); - Validate(indexes, state); - } - - return results; - } - - private static void Validate(IDictionary indexes, Validation validation) - { - foreach(var test in validation) - { - var value = validation.Provider.GetPropertyValue(indexes, test.Key); - if (test.Value.IsMatch(value) == false) - { - Assert.Fail(String.Format( - "HttpHeader test failed for Property '{0}' and test '{1}' with result '{2}'", - test.Key, - test.Value, - value)); - } - } - } - - [TestCleanup] - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (_provider != null) - { - _provider.Dispose(); - } - } - } -} diff --git a/Integration Tests/HttpHeaders/TrieCombinations.cs b/Integration Tests/HttpHeaders/TrieCombinations.cs deleted file mode 100644 index 93c2650..0000000 --- a/Integration Tests/HttpHeaders/TrieCombinations.cs +++ /dev/null @@ -1,66 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection; -using FiftyOne.Foundation.Mobile.Detection.Entities; -using System.Text.RegularExpressions; - -namespace FiftyOne.Tests.Integration.HttpHeaders -{ - public abstract class TrieCombinations : TrieBase - { - protected void OperaMini_Samsung() - { - base.Process( - "(?i)Opera Mini", - "(?i)SAMSUNG GT-I", - new Validation(_provider) { - { "BrowserName", "Opera" }, - { "HardwareVendor", "Samsung" }, - }); - } - - protected void OperaMini_iPhone() - { - base.Process( - "(?i)Opera Mini", - @"^Mozilla/5\.0 \(iPhone; CPU iPhone OS ", - new Validation(_provider) { - { "BrowserName", "Opera" }, - { "HardwareVendor", "Apple" }, - }); - } - - protected void OperaMini_HTC() - { - base.Process( - "(?i)Opera Mini", - " HTC ", - new Validation(_provider) { - { "BrowserName", "Opera" }, - { "HardwareVendor", "HTC" }, - }); - } - } -} diff --git a/Integration Tests/Integration Tests.csproj b/Integration Tests/Integration Tests.csproj index 9d0fd74..853b929 100644 --- a/Integration Tests/Integration Tests.csproj +++ b/Integration Tests/Integration Tests.csproj @@ -87,9 +87,6 @@ - - - @@ -121,11 +118,7 @@ - - - - @@ -153,15 +146,6 @@ - - - - - - - - - @@ -216,12 +200,8 @@ - - - - @@ -230,9 +210,6 @@ - - - diff --git a/Integration Tests/Memory/Enterprise/V30TrieFile.cs b/Integration Tests/Memory/Enterprise/V30TrieFile.cs deleted file mode 100644 index 119a086..0000000 --- a/Integration Tests/Memory/Enterprise/V30TrieFile.cs +++ /dev/null @@ -1,73 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Tests.Integration.Memory.Enterprise -{ - [TestClass] - public class V30TrieFile : TrieFile - { - protected override string DataFile - { - get { return Utils.GetDataFile(Constants.ENTERPRISE_TRIE_V30); } - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Enterprise")] - public void EnterpriseV30TrieFile_Memory_UniqueUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetUniqueUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Enterprise")] - public void EnterpriseV30TrieFile_Memory_UniqueUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetUniqueUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Enterprise")] - public void EnterpriseV30TrieFile_Memory_RandomUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetRandomUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Enterprise")] - public void EnterpriseV30TrieFile_Memory_RandomUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetRandomUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Enterprise")] - public void EnterpriseV30TrieFile_Memory_BadUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetBadUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Enterprise")] - public void EnterpriseV30TrieFile_Memory_BadUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetBadUserAgents()); - } - } -} diff --git a/Integration Tests/Memory/Enterprise/V32TrieFile.cs b/Integration Tests/Memory/Enterprise/V32TrieFile.cs deleted file mode 100644 index 1430232..0000000 --- a/Integration Tests/Memory/Enterprise/V32TrieFile.cs +++ /dev/null @@ -1,73 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Tests.Integration.Memory.Enterprise -{ - [TestClass] - public class V32TrieFile : TrieFile - { - protected override string DataFile - { - get { return Utils.GetDataFile(Constants.ENTERPRISE_TRIE_V32); } - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Enterprise")] - public void EnterpriseV32TrieFile_Memory_UniqueUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetUniqueUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Enterprise")] - public void EnterpriseV32TrieFile_Memory_UniqueUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetUniqueUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Enterprise")] - public void EnterpriseV32TrieFile_Memory_RandomUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetRandomUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Enterprise")] - public void EnterpriseV32TrieFile_Memory_RandomUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetRandomUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Enterprise")] - public void EnterpriseV32TrieFile_Memory_BadUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetBadUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Enterprise")] - public void EnterpriseV32TrieFile_Memory_BadUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetBadUserAgents()); - } - } -} diff --git a/Integration Tests/Memory/Lite/V30TrieFile.cs b/Integration Tests/Memory/Lite/V30TrieFile.cs deleted file mode 100644 index f2f8870..0000000 --- a/Integration Tests/Memory/Lite/V30TrieFile.cs +++ /dev/null @@ -1,73 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Tests.Integration.Memory.Lite -{ - [TestClass] - public class V30TrieFile : TrieFile - { - protected override string DataFile - { - get { return Utils.GetDataFile(Constants.LITE_TRIE_V30); } - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Lite")] - public void LiteV30TrieFile_Memory_UniqueUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetUniqueUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Lite")] - public void LiteV30TrieFile_Memory_UniqueUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetUniqueUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Lite")] - public void LiteV30TrieFile_Memory_RandomUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetRandomUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Lite")] - public void LiteV30TrieFile_Memory_RandomUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetRandomUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Lite")] - public void LiteV30TrieFile_Memory_BadUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetBadUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Lite")] - public void LiteV30TrieFile_Memory_BadUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetBadUserAgents()); - } - } -} diff --git a/Integration Tests/Memory/Lite/V32TrieFile.cs b/Integration Tests/Memory/Lite/V32TrieFile.cs deleted file mode 100644 index ae01336..0000000 --- a/Integration Tests/Memory/Lite/V32TrieFile.cs +++ /dev/null @@ -1,73 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Tests.Integration.Memory.Lite -{ - [TestClass] - public class V32TrieFile : TrieFile - { - protected override string DataFile - { - get { return Utils.GetDataFile(Constants.LITE_TRIE_V32); } - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Lite")] - public void LiteV32TrieFile_Memory_UniqueUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetUniqueUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Lite")] - public void LiteV32TrieFile_Memory_UniqueUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetUniqueUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Lite")] - public void LiteV32TrieFile_Memory_RandomUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetRandomUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Lite")] - public void LiteV32TrieFile_Memory_RandomUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetRandomUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Lite")] - public void LiteV32TrieFile_Memory_BadUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetBadUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Lite")] - public void LiteV32TrieFile_Memory_BadUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetBadUserAgents()); - } - } -} diff --git a/Integration Tests/Memory/Premium/V30TrieFile.cs b/Integration Tests/Memory/Premium/V30TrieFile.cs deleted file mode 100644 index 1d38337..0000000 --- a/Integration Tests/Memory/Premium/V30TrieFile.cs +++ /dev/null @@ -1,73 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Tests.Integration.Memory.Premium -{ - [TestClass] - public class V30TrieFile : TrieFile - { - protected override string DataFile - { - get { return Utils.GetDataFile(Constants.PREMIUM_TRIE_V30); } - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Premium")] - public void PremiumV30TrieFile_Memory_UniqueUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetUniqueUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Premium")] - public void PremiumV30TrieFile_Memory_UniqueUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetUniqueUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Premium")] - public void PremiumV30TrieFile_Memory_RandomUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetRandomUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Premium")] - public void PremiumV30TrieFile_Memory_RandomUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetRandomUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Premium")] - public void PremiumV30TrieFile_Memory_BadUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetBadUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Premium")] - public void PremiumV30TrieFile_Memory_BadUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetBadUserAgents()); - } - } -} diff --git a/Integration Tests/Memory/Premium/V32TrieFile.cs b/Integration Tests/Memory/Premium/V32TrieFile.cs deleted file mode 100644 index 0e343c7..0000000 --- a/Integration Tests/Memory/Premium/V32TrieFile.cs +++ /dev/null @@ -1,73 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Tests.Integration.Memory.Premium -{ - [TestClass] - public class V32TrieFile : TrieFile - { - protected override string DataFile - { - get { return Utils.GetDataFile(Constants.PREMIUM_TRIE_V32); } - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Premium")] - public void PremiumV32TrieFile_Memory_UniqueUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetUniqueUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Premium")] - public void PremiumV32TrieFile_Memory_UniqueUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetUniqueUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Premium")] - public void PremiumV32TrieFile_Memory_RandomUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetRandomUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Premium")] - public void PremiumV32TrieFile_Memory_RandomUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetRandomUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Premium")] - public void PremiumV32TrieFile_Memory_BadUserAgentsMulti() - { - base.UserAgentsMulti(UserAgentGenerator.GetBadUserAgents()); - } - - [TestMethod(), TestCategory("Memory"), TestCategory("Premium")] - public void PremiumV32TrieFile_Memory_BadUserAgentsSingle() - { - base.UserAgentsSingle(UserAgentGenerator.GetBadUserAgents()); - } - } -} diff --git a/Integration Tests/Memory/TrieBase.cs b/Integration Tests/Memory/TrieBase.cs deleted file mode 100644 index 8ad64c4..0000000 --- a/Integration Tests/Memory/TrieBase.cs +++ /dev/null @@ -1,97 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection.Entities; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using FiftyOne.Foundation.Mobile.Detection; -using System.Collections.Generic; - -namespace FiftyOne.Tests.Integration.Memory -{ - [TestClass] - public abstract class TrieBase : IDisposable - { - protected TrieProvider _provider; - - /// - /// The memory used to create the dataset. - /// - protected Utils.MemoryMonitor _memory; - - protected abstract string DataFile { get; } - - protected abstract int MaxAllowedMemory { get; } - - protected virtual void UserAgentsSingle(IEnumerable userAgents) - { - Console.WriteLine("Expected Max Memory: {0:0.0} MB", MaxAllowedMemory); - Utils.DetectLoopSingleThreaded( - _provider, - userAgents, - Utils.MonitorTrieMemory, - _memory); - Console.WriteLine("Memory Used: {0:0.0} MB", _memory.AverageMemoryUsed); - if (_memory.AverageMemoryUsed > MaxAllowedMemory) - { - Assert.Inconclusive(String.Format( - "Memory use was '{0:0.0}MB' but max allowed '{1:0.0}MB'", - _memory.AverageMemoryUsed, - MaxAllowedMemory)); - } - } - - protected virtual void UserAgentsMulti(IEnumerable userAgents) - { - Console.WriteLine("Expected Max Memory: {0:0.0} MB", MaxAllowedMemory); - Utils.DetectLoopMultiThreaded( - _provider, - userAgents, - Utils.MonitorTrieMemory, - _memory); - Console.WriteLine("Memory Used: {0:0.0} MB", _memory.AverageMemoryUsed); - if (_memory.AverageMemoryUsed > MaxAllowedMemory) - { - Assert.Inconclusive(String.Format( - "Memory use was '{0:0.0}MB' but max allowed '{1:0.0}MB'", - _memory.AverageMemoryUsed, - MaxAllowedMemory)); - } - } - - [TestCleanup] - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (_provider != null) - { - _provider.Dispose(); - } - } - } -} diff --git a/Integration Tests/Memory/TrieFile.cs b/Integration Tests/Memory/TrieFile.cs deleted file mode 100644 index 4f8a12c..0000000 --- a/Integration Tests/Memory/TrieFile.cs +++ /dev/null @@ -1,45 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Tests.Integration.Memory -{ - [TestClass] - public abstract class TrieFile : TrieBase - { - [TestInitialize()] - public void CreateDataSet() - { - _memory = new Utils.MemoryMonitor(); - Utils.CheckFileExists(DataFile); - _provider = TrieFactory.Create(DataFile); - } - - protected override int MaxAllowedMemory - { - get { return (int)((new FileInfo(DataFile).Length * 0.6) / Utils.MemoryMonitor.MEGABYTE); } - } - } -} diff --git a/Integration Tests/Memory/TrieMemory.cs b/Integration Tests/Memory/TrieMemory.cs deleted file mode 100644 index 9aaecb1..0000000 --- a/Integration Tests/Memory/TrieMemory.cs +++ /dev/null @@ -1,62 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Tests.Integration.Memory -{ - [TestClass] - public abstract class TrieMemory : TrieBase - { - [TestInitialize()] - [ExpectedException(typeof(OutOfMemoryException))] - public void CreateDataSet() - { - _memory = new Utils.MemoryMonitor(); - Utils.CheckFileExists(DataFile); - var file = new FileInfo(DataFile); - try - { - var array = new byte[file.Length]; - using (var stream = file.OpenRead()) - { - stream.Read(array, 0, (int)file.Length); - } - _provider = TrieFactory.Create(array); - } - catch(OutOfMemoryException) - { - Assert.Inconclusive( - "Not enough memory to perform memory test on data file '{0}' of size '{1}'MB", - file.Name, - file.Length / (1024 * 1024)); - } - } - - protected override int MaxAllowedMemory - { - get { return (int)((new FileInfo(DataFile).Length * 1.6) / Utils.MemoryMonitor.MEGABYTE); } - } - } -} diff --git a/Integration Tests/Performance/Lite/V30TrieFile.cs b/Integration Tests/Performance/Lite/V30TrieFile.cs deleted file mode 100644 index 9be2da5..0000000 --- a/Integration Tests/Performance/Lite/V30TrieFile.cs +++ /dev/null @@ -1,115 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Tests.Integration.Performance.Lite -{ - [TestClass] - public class V30TrieFile : TrieFile - { - protected override string DataFile - { - get { return Utils.GetDataFile(Constants.LITE_TRIE_V30); } - } - - [TestMethod] - public void LiteV30TrieFile_Performance_InitializeTime() - { - base.InitializeTime(); - } - - [TestMethod] - public void LiteV30TrieFile_Performance_BadUserAgentsMulti() - { - base.BadUserAgentsMulti(); - } - - [TestMethod] - public void LiteV30TrieFile_Performance_BadUserAgentsSingle() - { - base.BadUserAgentsSingle(); - } - - [TestMethod] - public void LiteV30TrieFile_Performance_UniqueUserAgentsMulti() - { - base.UniqueUserAgentsMulti(); - } - - [TestMethod] - public void LiteV30TrieFile_Performance_UniqueUserAgentsSingle() - { - base.UniqueUserAgentsSingle(); - } - - [TestMethod] - public void LiteV30TrieFile_Performance_RandomUserAgentsMulti() - { - base.RandomUserAgentsMulti(); - } - - [TestMethod] - public void LiteV30TrieFile_Performance_RandomUserAgentsSingle() - { - base.RandomUserAgentsSingle(); - } - - [TestMethod] - public void LiteV30TrieFile_Performance_BadUserAgentsMultiAll() - { - base.BadUserAgentsMultiAll(); - } - - [TestMethod] - public void LiteV30TrieFile_Performance_BadUserAgentsSingleAll() - { - base.BadUserAgentsSingleAll(); - } - - [TestMethod] - public void LiteV30TrieFile_Performance_UniqueUserAgentsMultiAll() - { - base.UniqueUserAgentsMultiAll(); - } - - [TestMethod] - public void LiteV30TrieFile_Performance_UniqueUserAgentsSingleAll() - { - base.UniqueUserAgentsSingleAll(); - } - - [TestMethod] - public void LiteV30TrieFile_Performance_RandomUserAgentsMultiAll() - { - base.RandomUserAgentsMultiAll(); - } - - [TestMethod] - public void LiteV30TrieFile_Performance_RandomUserAgentsSingleAll() - { - base.RandomUserAgentsSingleAll(); - } - } -} diff --git a/Integration Tests/Performance/Lite/V30TrieMemory.cs b/Integration Tests/Performance/Lite/V30TrieMemory.cs deleted file mode 100644 index 869a8a5..0000000 --- a/Integration Tests/Performance/Lite/V30TrieMemory.cs +++ /dev/null @@ -1,120 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Tests.Integration.Performance.Lite -{ - [TestClass] - public class V30TrieMemory : TrieMemory - { - protected override int MaxInitializeTime - { - get { return 10000; } - } - - protected override string DataFile - { - get { return Utils.GetDataFile(Constants.LITE_TRIE_V30); } - } - - [TestMethod] - public void LiteV30TrieMemory_Performance_InitializeTime() - { - base.InitializeTime(); - } - - [TestMethod] - public void LiteV30TrieMemory_Performance_BadUserAgentsMulti() - { - base.BadUserAgentsMulti(); - } - - [TestMethod] - public void LiteV30TrieMemory_Performance_BadUserAgentsSingle() - { - base.BadUserAgentsSingle(); - } - - [TestMethod] - public void LiteV30TrieMemory_Performance_UniqueUserAgentsMulti() - { - base.UniqueUserAgentsMulti(); - } - - [TestMethod] - public void LiteV30TrieMemory_Performance_UniqueUserAgentsSingle() - { - base.UniqueUserAgentsSingle(); - } - - [TestMethod] - public void LiteV30TrieMemory_Performance_RandomUserAgentsMulti() - { - base.RandomUserAgentsMulti(); - } - - [TestMethod] - public void LiteV30TrieMemory_Performance_RandomUserAgentsSingle() - { - base.RandomUserAgentsSingle(); - } - - [TestMethod] - public void LiteV30TrieMemory_Performance_BadUserAgentsMultiAll() - { - base.BadUserAgentsMulti(); - } - - [TestMethod] - public void LiteV30TrieMemory_Performance_BadUserAgentsSingleAll() - { - base.BadUserAgentsSingle(); - } - - [TestMethod] - public void LiteV30TrieMemory_Performance_UniqueUserAgentsMultiAll() - { - base.UniqueUserAgentsMulti(); - } - - [TestMethod] - public void LiteV30TrieMemory_Performance_UniqueUserAgentsSingleAll() - { - base.UniqueUserAgentsSingle(); - } - - [TestMethod] - public void LiteV30TrieMemory_Performance_RandomUserAgentsMultiAll() - { - base.RandomUserAgentsMulti(); - } - - [TestMethod] - public void LiteV30TrieMemory_Performance_RandomUserAgentsSingleAll() - { - base.RandomUserAgentsSingle(); - } - } -} diff --git a/Integration Tests/Performance/Lite/V32TrieFile.cs b/Integration Tests/Performance/Lite/V32TrieFile.cs deleted file mode 100644 index 2e4869c..0000000 --- a/Integration Tests/Performance/Lite/V32TrieFile.cs +++ /dev/null @@ -1,115 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Tests.Integration.Performance.Lite -{ - [TestClass] - public class V32TrieFile : TrieFile - { - protected override string DataFile - { - get { return Utils.GetDataFile(Constants.LITE_TRIE_V32); } - } - - [TestMethod] - public void LiteV32TrieFile_Performance_InitializeTime() - { - base.InitializeTime(); - } - - [TestMethod] - public void LiteV32TrieFile_Performance_BadUserAgentsMulti() - { - base.BadUserAgentsMulti(); - } - - [TestMethod] - public void LiteV32TrieFile_Performance_BadUserAgentsSingle() - { - base.BadUserAgentsSingle(); - } - - [TestMethod] - public void LiteV32TrieFile_Performance_UniqueUserAgentsMulti() - { - base.UniqueUserAgentsMulti(); - } - - [TestMethod] - public void LiteV32TrieFile_Performance_UniqueUserAgentsSingle() - { - base.UniqueUserAgentsSingle(); - } - - [TestMethod] - public void LiteV32TrieFile_Performance_RandomUserAgentsMulti() - { - base.RandomUserAgentsMulti(); - } - - [TestMethod] - public void LiteV32TrieFile_Performance_RandomUserAgentsSingle() - { - base.RandomUserAgentsSingle(); - } - - [TestMethod] - public void LiteV32TrieFile_Performance_BadUserAgentsMultiAll() - { - base.BadUserAgentsMultiAll(); - } - - [TestMethod] - public void LiteV32TrieFile_Performance_BadUserAgentsSingleAll() - { - base.BadUserAgentsSingleAll(); - } - - [TestMethod] - public void LiteV32TrieFile_Performance_UniqueUserAgentsMultiAll() - { - base.UniqueUserAgentsMultiAll(); - } - - [TestMethod] - public void LiteV32TrieFile_Performance_UniqueUserAgentsSingleAll() - { - base.UniqueUserAgentsSingleAll(); - } - - [TestMethod] - public void LiteV32TrieFile_Performance_RandomUserAgentsMultiAll() - { - base.RandomUserAgentsMultiAll(); - } - - [TestMethod] - public void LiteV32TrieFile_Performance_RandomUserAgentsSingleAll() - { - base.RandomUserAgentsSingleAll(); - } - } -} diff --git a/Integration Tests/Performance/Lite/V32TrieMemory.cs b/Integration Tests/Performance/Lite/V32TrieMemory.cs deleted file mode 100644 index bd8dc6f..0000000 --- a/Integration Tests/Performance/Lite/V32TrieMemory.cs +++ /dev/null @@ -1,121 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Tests.Integration.Performance.Lite -{ - [TestClass] - public class V32TrieMemory : TrieMemory - { - protected override int MaxInitializeTime - { - get { return 10000; } - } - - protected override string DataFile - { - get { return Utils.GetDataFile(Constants.LITE_TRIE_V32); } - } - - [TestMethod] - public void LiteV32TrieMemory_Performance_InitializeTime() - { - base.InitializeTime(); - } - - - [TestMethod] - public void LiteV32TrieMemory_Performance_BadUserAgentsMulti() - { - base.BadUserAgentsMulti(); - } - - [TestMethod] - public void LiteV32TrieMemory_Performance_BadUserAgentsSingle() - { - base.BadUserAgentsSingle(); - } - - [TestMethod] - public void LiteV32TrieMemory_Performance_UniqueUserAgentsMulti() - { - base.UniqueUserAgentsMulti(); - } - - [TestMethod] - public void LiteV32TrieMemory_Performance_UniqueUserAgentsSingle() - { - base.UniqueUserAgentsSingle(); - } - - [TestMethod] - public void LiteV32TrieMemory_Performance_RandomUserAgentsMulti() - { - base.RandomUserAgentsMulti(); - } - - [TestMethod] - public void LiteV32TrieMemory_Performance_RandomUserAgentsSingle() - { - base.RandomUserAgentsSingle(); - } - - [TestMethod] - public void LiteV32TrieMemory_Performance_BadUserAgentsMultiAll() - { - base.BadUserAgentsMultiAll(); - } - - [TestMethod] - public void LiteV32TrieMemory_Performance_BadUserAgentsSingleAll() - { - base.BadUserAgentsSingleAll(); - } - - [TestMethod] - public void LiteV32TrieMemory_Performance_UniqueUserAgentsMultiAll() - { - base.UniqueUserAgentsMultiAll(); - } - - [TestMethod] - public void LiteV32TrieMemory_Performance_UniqueUserAgentsSingleAll() - { - base.UniqueUserAgentsSingleAll(); - } - - [TestMethod] - public void LiteV32TrieMemory_Performance_RandomUserAgentsMultiAll() - { - base.RandomUserAgentsMultiAll(); - } - - [TestMethod] - public void LiteV32TrieMemory_Performance_RandomUserAgentsSingleAll() - { - base.RandomUserAgentsSingleAll(); - } - } -} diff --git a/Integration Tests/Performance/TrieBase.cs b/Integration Tests/Performance/TrieBase.cs deleted file mode 100644 index 8c2f808..0000000 --- a/Integration Tests/Performance/TrieBase.cs +++ /dev/null @@ -1,181 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection.Entities; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using FiftyOne.Foundation.Mobile.Detection; -using System.Collections.Generic; - -namespace FiftyOne.Tests.Integration.Performance -{ - [TestClass] - public abstract class TrieBase : IDisposable - { - protected TrieProvider _provider; - - /// - /// Name of the data file to use for the tests. - /// - protected abstract string DataFile { get; } - - /// - /// Time taken to initialise the data set for the tests. - /// - protected TimeSpan _testInitializeTime; - - protected virtual int MaxInitializeTime { get { return 500; } } - - protected virtual int GuidanceTime { get { return 1; } } - - protected virtual void InitializeTime() - { - Assert.IsTrue(_testInitializeTime.TotalMilliseconds < MaxInitializeTime, - String.Format("Initialisation time greater than '{0}' ms", MaxInitializeTime)); - Console.WriteLine("{0:0.00}ms", _testInitializeTime.TotalMilliseconds); - } - - protected virtual Utils.Results UserAgentsSingle(IEnumerable userAgents) - { - return Utils.DetectLoopSingleThreaded( - _provider, - userAgents, - Utils.TrieDoNothing, - _provider); - } - - protected virtual Utils.Results UserAgentsMulti(IEnumerable userAgents) - { - return Utils.DetectLoopMultiThreaded( - _provider, - userAgents, - Utils.TrieDoNothing, - _provider); - } - - protected virtual Utils.Results UserAgentsMultiAll(IEnumerable userAgents) - { - var results = Utils.DetectLoopMultiThreaded(_provider, userAgents, Utils.RetrieveTriePropertyValues, _provider); - Console.WriteLine("Values check sum: '{0}'", results.CheckSum); - Assert.IsTrue(results.AverageTime.TotalMilliseconds < GuidanceTime, - String.Format("Average time of '{0:0.000}' ms exceeded guidance time of '{1}' ms", - results.AverageTime.TotalMilliseconds, - GuidanceTime)); - return results; - } - - protected virtual Utils.Results UserAgentsSingleAll(IEnumerable userAgents) - { - var results = Utils.DetectLoopSingleThreaded(_provider, userAgents, Utils.RetrieveTriePropertyValues, _provider); - Console.WriteLine("Values check sum: '{0}'", results.CheckSum); - Assert.IsTrue(results.AverageTime.TotalMilliseconds < GuidanceTime, - String.Format("Average time of '{0:0.000}' ms exceeded guidance time of '{1}' ms", - results.AverageTime.TotalMilliseconds, - GuidanceTime)); - return results; - } - - protected void BadUserAgentsMulti() - { - UserAgentsMulti(UserAgentGenerator.GetBadUserAgents()); - } - - protected void BadUserAgentsSingle() - { - UserAgentsSingle(UserAgentGenerator.GetBadUserAgents()); - } - - protected void UniqueUserAgentsMulti() - { - UserAgentsMulti(UserAgentGenerator.GetUniqueUserAgents()); - } - - protected void UniqueUserAgentsSingle() - { - UserAgentsSingle(UserAgentGenerator.GetUniqueUserAgents()); - } - - protected void RandomUserAgentsMulti() - { - UserAgentsMulti(UserAgentGenerator.GetRandomUserAgents()); - } - - protected void RandomUserAgentsSingle() - { - UserAgentsSingle(UserAgentGenerator.GetRandomUserAgents()); - } - - protected void BadUserAgentsMultiAll() - { - UserAgentsMultiAll(UserAgentGenerator.GetBadUserAgents()); - } - - protected void BadUserAgentsSingleAll() - { - UserAgentsSingleAll(UserAgentGenerator.GetBadUserAgents()); - } - - protected void UniqueUserAgentsMultiAll() - { - UserAgentsMultiAll(UserAgentGenerator.GetUniqueUserAgents()); - } - - protected void UniqueUserAgentsSingleAll() - { - UserAgentsSingleAll(UserAgentGenerator.GetUniqueUserAgents()); - } - - protected void RandomUserAgentsMultiAll() - { - UserAgentsMultiAll(UserAgentGenerator.GetRandomUserAgents()); - } - - protected void RandomUserAgentsSingleAll() - { - UserAgentsSingleAll(UserAgentGenerator.GetRandomUserAgents()); - } - - [TestCleanup] - public void CleanUp() - { - _provider.Dispose(); - _provider = null; - GC.Collect(int.MaxValue, GCCollectionMode.Forced, true); - GC.WaitForPendingFinalizers(); - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (_provider != null) - { - _provider.Dispose(); - } - } - } -} diff --git a/Integration Tests/Performance/TrieFile.cs b/Integration Tests/Performance/TrieFile.cs deleted file mode 100644 index b8beb7b..0000000 --- a/Integration Tests/Performance/TrieFile.cs +++ /dev/null @@ -1,41 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Tests.Integration.Performance -{ - [TestClass] - public abstract class TrieFile : TrieBase - { - [TestInitialize()] - public void CreateDataSet() - { - var start = DateTime.UtcNow; - Utils.CheckFileExists(DataFile); - _provider = TrieFactory.Create(DataFile); - _testInitializeTime = DateTime.UtcNow - start; - } - } -} diff --git a/Integration Tests/Performance/TrieMemory.cs b/Integration Tests/Performance/TrieMemory.cs deleted file mode 100644 index ca6138a..0000000 --- a/Integration Tests/Performance/TrieMemory.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* ********************************************************************* - * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. - * Copyright © 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, - * Caversham, Reading, Berkshire, United Kingdom RG4 7BY - * - * This Source Code Form is the subject of the following patent - * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte - * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: - * European Patent Application No. 13192291.6; and - * United States Patent Application Nos. 14/085,223 and 14/085,301. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. - * - * If a copy of the MPL was not distributed with this file, You can obtain - * one at http://mozilla.org/MPL/2.0/. - * - * This Source Code Form is “Incompatible With Secondary Licenses”, as - * defined by the Mozilla Public License, v. 2.0. - * ********************************************************************* */ - -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using FiftyOne.Foundation.Mobile.Detection.Factories; -using System.IO; - -namespace FiftyOne.Tests.Integration.Performance -{ - [TestClass] - public abstract class TrieMemory : TrieBase - { - [TestInitialize()] - [ExpectedException(typeof(OutOfMemoryException))] - public void CreateDataSet() - { - var start = DateTime.UtcNow; - _testInitializeTime = DateTime.UtcNow - start; - Utils.CheckFileExists(DataFile); - var file = new FileInfo(DataFile); - try - { - var array = new byte[file.Length]; - using (var stream = file.OpenRead()) - { - stream.Read(array, 0, (int)file.Length); - } - _provider = TrieFactory.Create(array); - } - catch(OutOfMemoryException) - { - Assert.Inconclusive( - "Not enough memory to perform memory test on data file '{0}' of size '{1}'MB", - file.Name, - file.Length / (1024 * 1024)); - } - _testInitializeTime = DateTime.UtcNow - start; - } - } -}