|
| 1 | +/* |
| 2 | + * This file is part of the Buildings and Habitats object Model (BHoM) |
| 3 | + * Copyright (c) 2015 - 2024, the respective contributors. All rights reserved. |
| 4 | + * |
| 5 | + * Each contributor holds copyright over their respective contributions. |
| 6 | + * The project versioning (Git) records all such contribution source information. |
| 7 | + * |
| 8 | + * |
| 9 | + * The BHoM is free software: you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU Lesser General Public License as published by |
| 11 | + * the Free Software Foundation, either version 3.0 of the License, or |
| 12 | + * (at your option) any later version. |
| 13 | + * |
| 14 | + * The BHoM is distributed in the hope that it will be useful, |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | + * GNU Lesser General Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU Lesser General Public License |
| 20 | + * along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>. |
| 21 | + */ |
| 22 | + |
| 23 | +using BH.oM.Base; |
| 24 | +using BH.oM.Base.Attributes; |
| 25 | +using System; |
| 26 | +using System.Collections.Generic; |
| 27 | +using System.ComponentModel; |
| 28 | +using System.Linq; |
| 29 | +using System.Reflection; |
| 30 | + |
| 31 | +namespace BH.Engine.Test |
| 32 | +{ |
| 33 | + public static partial class Query |
| 34 | + { |
| 35 | + /***************************************************/ |
| 36 | + /**** Public Methods ****/ |
| 37 | + /***************************************************/ |
| 38 | + |
| 39 | + [Description("Checks if a type is defined in an assembly that is part of Test_Toolkit.")] |
| 40 | + [Input("type", "Type to check.")] |
| 41 | + [Output("isTestToolkit", "Returns true if the type is defined inside Test_Toolkit.")] |
| 42 | + public static bool IsTestToolkit(this Type type) |
| 43 | + { |
| 44 | + if (type == null) |
| 45 | + return false; |
| 46 | + |
| 47 | + string assemblyName = type.Assembly?.GetName()?.Name; |
| 48 | + |
| 49 | + return m_testToolkitAssemblyNames.Contains(assemblyName); |
| 50 | + } |
| 51 | + |
| 52 | + /***************************************************/ |
| 53 | + |
| 54 | + [Description("Checks if a method is defined in an assembly that is part of Test_Toolkit.")] |
| 55 | + [Input("method", "Method to check.")] |
| 56 | + [Output("isTestToolkit", "Returns true if the method is defined inside Test_Toolkit.")] |
| 57 | + public static bool IsTestToolkit(this MethodBase method) |
| 58 | + { |
| 59 | + if (method == null) |
| 60 | + return false; |
| 61 | + |
| 62 | + return method.DeclaringType.IsTestToolkit(); |
| 63 | + } |
| 64 | + |
| 65 | + /***************************************************/ |
| 66 | + /**** Private Fields ****/ |
| 67 | + /***************************************************/ |
| 68 | + |
| 69 | + private static HashSet<string> m_testToolkitAssemblyNames = new HashSet<string> |
| 70 | + { |
| 71 | + "CodeComplianceTest_Engine", |
| 72 | + "CodeComplianceTest_oM", |
| 73 | + "InteroperabilityTest_Engine", |
| 74 | + "InteroperabilityTest_oM", |
| 75 | + "NUnit_Engine", |
| 76 | + "NUnit_oM", |
| 77 | + "Test_Engine", |
| 78 | + "TestRunner", |
| 79 | + "UnitTest_Engine", |
| 80 | + "UnitTest_oM" |
| 81 | + }; |
| 82 | + |
| 83 | + /***************************************************/ |
| 84 | + } |
| 85 | +} |
0 commit comments