From 0f04ad02d8c7fcb0447b38f3ad433429fb8a4cbd Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Fri, 4 Dec 2020 17:22:40 +0100 Subject: [PATCH 01/17] HttpMethodsWhitelist and GeneralContains request filters added --- Directory.Build.props | 2 +- src/QAToolKit.Core/Models/RequestFilter.cs | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 59ed3a3..83b1ab4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 0.3.3 + 0.3.4 \ No newline at end of file diff --git a/src/QAToolKit.Core/Models/RequestFilter.cs b/src/QAToolKit.Core/Models/RequestFilter.cs index a71d599..aa6328f 100644 --- a/src/QAToolKit.Core/Models/RequestFilter.cs +++ b/src/QAToolKit.Core/Models/RequestFilter.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Net.Http; namespace QAToolKit.Core.Models { @@ -8,16 +9,24 @@ namespace QAToolKit.Core.Models public class RequestFilter { /// - /// A list of endpoint names which are allowed to be processed. + /// Filter requests by a list of endpoint names which are allowed to be processed. /// public string[] EndpointNameWhitelist { get; set; } /// - /// A list of allowed authentication types + /// Filter requests by a list of allowed authentication types. AuthenticationType is a tag or a placeholder you can place in the Swagger endpoint description. /// public IEnumerable AuthenticationTypes { get; set; } /// - /// A list of allowed test types + /// Filter requests by a list of allowed test types. TestType is a tag or a placeholder you can place in the Swagger endpoint description. /// public IEnumerable TestTypes { get; set; } + /// + /// Filter requests by a list of HTTP methods whiltelist. + /// + public IEnumerable HttpMethodsWhitelist { get; set; } + /// + /// Filter requests by a list of strings which can be found in swagger description, summary or tags. String case is ignored. + /// + public IEnumerable GeneralContains { get; set; } } } \ No newline at end of file From dca752b95ab0367b1eff1b08ef048257f1087f36 Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Wed, 9 Dec 2020 07:47:12 +0100 Subject: [PATCH 02/17] MultipartFormData and TextPlain content types added --- .../Models/AuthenticationTypeTests.cs | 2 +- .../ContentType/ContentTypeFormTests.cs | 52 +++++ .../ContentType/ContentTypeJsonTests.cs | 71 ++++++ .../ContentType/ContentTypeMultipartTests.cs | 52 +++++ .../ContentType/ContentTypeOctetTests.cs | 52 +++++ .../ContentType/ContentTypeTextTests.cs | 52 +++++ .../Models/ContentType/ContentTypeXmlTests.cs | 52 +++++ .../Models/ContentTypeTests.cs | 203 ------------------ src/QAToolKit.Core/Models/ContentType.cs | 26 ++- 9 files changed, 357 insertions(+), 205 deletions(-) create mode 100644 src/QAToolKit.Core.Test/Models/ContentType/ContentTypeFormTests.cs create mode 100644 src/QAToolKit.Core.Test/Models/ContentType/ContentTypeJsonTests.cs create mode 100644 src/QAToolKit.Core.Test/Models/ContentType/ContentTypeMultipartTests.cs create mode 100644 src/QAToolKit.Core.Test/Models/ContentType/ContentTypeOctetTests.cs create mode 100644 src/QAToolKit.Core.Test/Models/ContentType/ContentTypeTextTests.cs create mode 100644 src/QAToolKit.Core.Test/Models/ContentType/ContentTypeXmlTests.cs delete mode 100644 src/QAToolKit.Core.Test/Models/ContentTypeTests.cs diff --git a/src/QAToolKit.Core.Test/Models/AuthenticationTypeTests.cs b/src/QAToolKit.Core.Test/Models/AuthenticationTypeTests.cs index 21d31ad..1d78c59 100644 --- a/src/QAToolKit.Core.Test/Models/AuthenticationTypeTests.cs +++ b/src/QAToolKit.Core.Test/Models/AuthenticationTypeTests.cs @@ -70,7 +70,7 @@ public void ConvertBasicFromString_Success(string value) { Assert.Equal(AuthenticationType.Basic, AuthenticationType.From(value)); } - + [Theory] [InlineData("")] [InlineData(null)] diff --git a/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeFormTests.cs b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeFormTests.cs new file mode 100644 index 0000000..9ee65d1 --- /dev/null +++ b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeFormTests.cs @@ -0,0 +1,52 @@ +using QAToolKit.Core.Models; +using Xunit; + +namespace QAToolKit.Core.Test.Models +{ + public class ContentTypeFormTests + { + [Fact] + public void ContentTypeFormTestsPresent_Success() + { + Assert.Equal("application/x-www-form-urlencoded", ContentType.FormUrlEncoded.Value()); + } + + [Theory] + [InlineData("application/x-www-form-urlencoded")] + public void ConvertFormFromString_Success(string value) + { + Assert.Equal(ContentType.FormUrlEncoded, ContentType.From(value)); + } + + [Theory] + [InlineData(ContentType.Enumeration.FormUrlEncoded)] + public void ConvertFormFromEnum_Success(ContentType.Enumeration value) + { + Assert.Equal(ContentType.FormUrlEncoded, ContentType.From(value)); + } + + [Fact] + public void ConvertFormObjectToString_Success() + { + Assert.Equal("application/x-www-form-urlencoded", ContentType.FormUrlEncoded.Value()); + } + + [Fact] + public void ConvertFormObjectToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.FormUrlEncoded, ContentType.ToEnum(ContentType.FormUrlEncoded)); + } + + [Fact] + public void ConvertFormStringToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.FormUrlEncoded, ContentType.ToEnum("application/x-www-form-urlencoded")); + } + + [Fact] + public void ConvertFormStringToContentType_Success() + { + Assert.Equal(ContentType.FormUrlEncoded, ContentType.From("application/x-www-form-urlencoded")); + } + } +} diff --git a/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeJsonTests.cs b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeJsonTests.cs new file mode 100644 index 0000000..d25deed --- /dev/null +++ b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeJsonTests.cs @@ -0,0 +1,71 @@ +using QAToolKit.Core.Exceptions; +using QAToolKit.Core.Models; +using Xunit; + +namespace QAToolKit.Core.Test.Models +{ + public class ContentTypeJsonTests + { + [Fact] + public void ContentTypeJsonTestsPresent_Success() + { + Assert.Equal("application/json", ContentType.Json.Value()); + } + + [Theory] + [InlineData("application/json")] + public void ConverJsonFromString_Success(string value) + { + Assert.Equal(ContentType.Json, ContentType.From(value)); + } + + [Theory] + [InlineData("")] + [InlineData(null)] + [InlineData("somestring")] + public void ConvertFromString_Fails(string value) + { + Assert.Throws(() => ContentType.From(value)); + } + + [Theory] + [InlineData(ContentType.Enumeration.Json)] + public void ConverJsonFromEnum_Success(ContentType.Enumeration value) + { + Assert.Equal(ContentType.Json, ContentType.From(value)); + } + + [Fact] + public void ConvertJsonObjectToString_Success() + { + Assert.Equal("application/json", ContentType.Json.Value()); + } + + [Fact] + public void ConvertJsonObjectToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.Json, ContentType.ToEnum(ContentType.Json)); + } + + [Fact] + public void ConvertJsonStringToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.Json, ContentType.ToEnum("application/json")); + } + + [Theory] + [InlineData("")] + [InlineData(null)] + [InlineData("somestring")] + public void ConvertStringToEnum_Fails(string value) + { + Assert.Throws(() => ContentType.ToEnum(value)); + } + + [Fact] + public void ConvertJsonStringToContentType_Success() + { + Assert.Equal(ContentType.Json, ContentType.From("application/json")); + } + } +} diff --git a/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeMultipartTests.cs b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeMultipartTests.cs new file mode 100644 index 0000000..2ee2ff4 --- /dev/null +++ b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeMultipartTests.cs @@ -0,0 +1,52 @@ +using QAToolKit.Core.Models; +using Xunit; + +namespace QAToolKit.Core.Test.Models +{ + public class ContentTypeMultipartTests + { + [Fact] + public void ContentTypeMultipartTestsPresent_Success() + { + Assert.Equal("multipart/form-data", ContentType.MultipartFormData.Value()); + } + + [Theory] + [InlineData("multipart/form-data")] + public void ConvertMultipartFromString_Success(string value) + { + Assert.Equal(ContentType.MultipartFormData, ContentType.From(value)); + } + + [Theory] + [InlineData(ContentType.Enumeration.MultipartFormData)] + public void ConvertMultipartFromEnum_Success(ContentType.Enumeration value) + { + Assert.Equal(ContentType.MultipartFormData, ContentType.From(value)); + } + + [Fact] + public void ConvertMultipartObjectToString_Success() + { + Assert.Equal("multipart/form-data", ContentType.MultipartFormData.Value()); + } + + [Fact] + public void ConvertMultipartObjectToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.MultipartFormData, ContentType.ToEnum(ContentType.MultipartFormData)); + } + + [Fact] + public void ConvertMultipartStringToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.MultipartFormData, ContentType.ToEnum("multipart/form-data")); + } + + [Fact] + public void ConvertMultipartStringToContentType_Success() + { + Assert.Equal(ContentType.MultipartFormData, ContentType.From("multipart/form-data")); + } + } +} diff --git a/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeOctetTests.cs b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeOctetTests.cs new file mode 100644 index 0000000..abce381 --- /dev/null +++ b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeOctetTests.cs @@ -0,0 +1,52 @@ +using QAToolKit.Core.Models; +using Xunit; + +namespace QAToolKit.Core.Test.Models +{ + public class ContentTypeOctetTests + { + [Fact] + public void ContentTypeBinaryTestsPresent_Success() + { + Assert.Equal("application/octet-stream", ContentType.OctetStream.Value()); + } + + [Theory] + [InlineData("application/octet-stream")] + public void ConvertBinaryFromString_Success(string value) + { + Assert.Equal(ContentType.OctetStream, ContentType.From(value)); + } + + [Theory] + [InlineData(ContentType.Enumeration.OctetStream)] + public void ConvertBinaryFromEnum_Success(ContentType.Enumeration value) + { + Assert.Equal(ContentType.OctetStream, ContentType.From(value)); + } + + [Fact] + public void ConvertBinaryObjectToString_Success() + { + Assert.Equal("application/octet-stream", ContentType.OctetStream.Value()); + } + + [Fact] + public void ConvertBinaryObjectToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.OctetStream, ContentType.ToEnum(ContentType.OctetStream)); + } + + [Fact] + public void ConvertBinaryStringToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.OctetStream, ContentType.ToEnum("application/octet-stream")); + } + + [Fact] + public void ConvertBinaryStringToContentType_Success() + { + Assert.Equal(ContentType.OctetStream, ContentType.From("application/octet-stream")); + } + } +} diff --git a/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeTextTests.cs b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeTextTests.cs new file mode 100644 index 0000000..3190957 --- /dev/null +++ b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeTextTests.cs @@ -0,0 +1,52 @@ +using QAToolKit.Core.Models; +using Xunit; + +namespace QAToolKit.Core.Test.Models +{ + public class ContentTypeTextTests + { + [Fact] + public void ContentTypeTextTestsPresent_Success() + { + Assert.Equal("text/plain", ContentType.TextPlain.Value()); + } + + [Theory] + [InlineData("text/plain")] + public void ConvertFromTextString_Success(string value) + { + Assert.Equal(ContentType.TextPlain, ContentType.From(value)); + } + + [Theory] + [InlineData(ContentType.Enumeration.TextPlain)] + public void ConvertFromTextEnum_Success(ContentType.Enumeration value) + { + Assert.Equal(ContentType.TextPlain, ContentType.From(value)); + } + + [Fact] + public void ConvertTextObjectToString_Success() + { + Assert.Equal("text/plain", ContentType.TextPlain.Value()); + } + + [Fact] + public void ConvertTextObjectToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.TextPlain, ContentType.ToEnum(ContentType.TextPlain)); + } + + [Fact] + public void ConvertTextStringToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.TextPlain, ContentType.ToEnum("text/plain")); + } + + [Fact] + public void ConvertTextStringToContentType_Success() + { + Assert.Equal(ContentType.TextPlain, ContentType.From("text/plain")); + } + } +} diff --git a/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeXmlTests.cs b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeXmlTests.cs new file mode 100644 index 0000000..069a6c7 --- /dev/null +++ b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeXmlTests.cs @@ -0,0 +1,52 @@ +using QAToolKit.Core.Models; +using Xunit; + +namespace QAToolKit.Core.Test.Models +{ + public class ContentTypeXmlTests + { + [Fact] + public void ContentTypeXmlTestsPresent_Success() + { + Assert.Equal("application/xml", ContentType.Xml.Value()); + } + + [Theory] + [InlineData("application/xml")] + public void ConvertXmlFromString_Success(string value) + { + Assert.Equal(ContentType.Xml, ContentType.From(value)); + } + + [Theory] + [InlineData(ContentType.Enumeration.Xml)] + public void ConvertXmlFromEnum_Success(ContentType.Enumeration value) + { + Assert.Equal(ContentType.Xml, ContentType.From(value)); + } + + [Fact] + public void ConvertXmlObjectToString_Success() + { + Assert.Equal("application/xml", ContentType.Xml.Value()); + } + + [Fact] + public void ConvertXmlObjectToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.Xml, ContentType.ToEnum(ContentType.Xml)); + } + + [Fact] + public void ConvertXmlStringToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.Xml, ContentType.ToEnum("application/xml")); + } + + [Fact] + public void ConvertXmlStringToContentType_Success() + { + Assert.Equal(ContentType.Xml, ContentType.From("application/xml")); + } + } +} diff --git a/src/QAToolKit.Core.Test/Models/ContentTypeTests.cs b/src/QAToolKit.Core.Test/Models/ContentTypeTests.cs deleted file mode 100644 index 79b33f7..0000000 --- a/src/QAToolKit.Core.Test/Models/ContentTypeTests.cs +++ /dev/null @@ -1,203 +0,0 @@ -using QAToolKit.Core.Exceptions; -using QAToolKit.Core.Models; -using Xunit; - -namespace QAToolKit.Core.Test.Models -{ - public class ContentTypeTests - { - [Fact] - public void ContentTypeJsonTestsPresent_Success() - { - Assert.Equal("application/json", ContentType.Json.Value()); - } - - [Fact] - public void ContentTypeXmlTestsPresent_Success() - { - Assert.Equal("application/xml", ContentType.Xml.Value()); - } - - [Fact] - public void ContentTypeFormTestsPresent_Success() - { - Assert.Equal("application/x-www-form-urlencoded", ContentType.FormUrlEncoded.Value()); - } - - [Fact] - public void ContentTypeBinaryTestsPresent_Success() - { - Assert.Equal("application/octet-stream", ContentType.OctetStream.Value()); - } - - [Theory] - [InlineData("application/json")] - public void ConverJsonFromString_Success(string value) - { - Assert.Equal(ContentType.Json, ContentType.From(value)); - } - - [Theory] - [InlineData("application/xml")] - public void ConvertXmlFromString_Success(string value) - { - Assert.Equal(ContentType.Xml, ContentType.From(value)); - } - - [Theory] - [InlineData("application/x-www-form-urlencoded")] - public void ConvertFormFromString_Success(string value) - { - Assert.Equal(ContentType.FormUrlEncoded, ContentType.From(value)); - } - - [Theory] - [InlineData("application/octet-stream")] - public void ConvertBinaryFromString_Success(string value) - { - Assert.Equal(ContentType.OctetStream, ContentType.From(value)); - } - - [Theory] - [InlineData("")] - [InlineData(null)] - [InlineData("somestring")] - public void ConvertFromString_Fails(string value) - { - Assert.Throws(() => ContentType.From(value)); - } - - [Theory] - [InlineData(ContentType.Enumeration.Json)] - public void ConverJsonFromEnum_Success(ContentType.Enumeration value) - { - Assert.Equal(ContentType.Json, ContentType.From(value)); - } - - [Theory] - [InlineData(ContentType.Enumeration.Xml)] - public void ConvertXmlFromEnum_Success(ContentType.Enumeration value) - { - Assert.Equal(ContentType.Xml, ContentType.From(value)); - } - - [Theory] - [InlineData(ContentType.Enumeration.FormUrlEncoded)] - public void ConvertFormFromEnum_Success(ContentType.Enumeration value) - { - Assert.Equal(ContentType.FormUrlEncoded, ContentType.From(value)); - } - - [Theory] - [InlineData(ContentType.Enumeration.OctetStream)] - public void ConvertBinaryFromEnum_Success(ContentType.Enumeration value) - { - Assert.Equal(ContentType.OctetStream, ContentType.From(value)); - } - - [Fact] - public void ConvertJsonObjectToString_Success() - { - Assert.Equal("application/json", ContentType.Json.Value()); - } - - [Fact] - public void ConvertXmlObjectToString_Success() - { - Assert.Equal("application/xml", ContentType.Xml.Value()); - } - - [Fact] - public void ConvertFormObjectToString_Success() - { - Assert.Equal("application/x-www-form-urlencoded", ContentType.FormUrlEncoded.Value()); - } - - [Fact] - public void ConvertBinaryObjectToString_Success() - { - Assert.Equal("application/octet-stream", ContentType.OctetStream.Value()); - } - - [Fact] - public void ConvertJsonObjectToEnum_Success() - { - Assert.Equal(ContentType.Enumeration.Json, ContentType.ToEnum(ContentType.Json)); - } - - [Fact] - public void ConvertXmlObjectToEnum_Success() - { - Assert.Equal(ContentType.Enumeration.Xml, ContentType.ToEnum(ContentType.Xml)); - } - - [Fact] - public void ConvertFormObjectToEnum_Success() - { - Assert.Equal(ContentType.Enumeration.FormUrlEncoded, ContentType.ToEnum(ContentType.FormUrlEncoded)); - } - - [Fact] - public void ConvertBinaryObjectToEnum_Success() - { - Assert.Equal(ContentType.Enumeration.OctetStream, ContentType.ToEnum(ContentType.OctetStream)); - } - - [Fact] - public void ConvertJsonStringToEnum_Success() - { - Assert.Equal(ContentType.Enumeration.Json, ContentType.ToEnum("application/json")); - } - - [Fact] - public void ConvertXmlStringToEnum_Success() - { - Assert.Equal(ContentType.Enumeration.Xml, ContentType.ToEnum("application/xml")); - } - - [Fact] - public void ConvertFormStringToEnum_Success() - { - Assert.Equal(ContentType.Enumeration.FormUrlEncoded, ContentType.ToEnum("application/x-www-form-urlencoded")); - } - - [Fact] - public void ConvertBinaryStringToEnum_Success() - { - Assert.Equal(ContentType.Enumeration.OctetStream, ContentType.ToEnum("application/octet-stream")); - } - - [Theory] - [InlineData("")] - [InlineData(null)] - [InlineData("somestring")] - public void ConvertStringToEnum_Fails(string value) - { - Assert.Throws(()=> ContentType.ToEnum(value)); - } - - [Fact] - public void ConvertJsonStringToContentType_Success() - { - Assert.Equal(ContentType.Json, ContentType.From("application/json")); - } - - [Fact] - public void ConvertXmlStringToContentType_Success() - { - Assert.Equal(ContentType.Xml, ContentType.From("application/xml")); - } - - [Fact] - public void ConvertFormStringToContentType_Success() - { - Assert.Equal(ContentType.FormUrlEncoded, ContentType.From("application/x-www-form-urlencoded")); - } - - [Fact] - public void ConvertBinaryStringToContentType_Success() - { - Assert.Equal(ContentType.OctetStream, ContentType.From("application/octet-stream")); - } - } -} diff --git a/src/QAToolKit.Core/Models/ContentType.cs b/src/QAToolKit.Core/Models/ContentType.cs index c011f3c..ca15f95 100644 --- a/src/QAToolKit.Core/Models/ContentType.cs +++ b/src/QAToolKit.Core/Models/ContentType.cs @@ -27,7 +27,15 @@ public enum Enumeration /// /// Binary content type for uploading files for example /// - OctetStream + OctetStream, + /// + /// multipart/form-data content type + /// + MultipartFormData, + /// + /// text/plain content type + /// + TextPlain } private readonly string _value; @@ -48,6 +56,14 @@ public enum Enumeration /// application/octet-stream content type /// public static readonly ContentType OctetStream = new ContentType("application/octet-stream"); + /// + /// multipart/form-data content type + /// + public static readonly ContentType MultipartFormData = new ContentType("multipart/form-data"); + /// + /// text/plain content type + /// + public static readonly ContentType TextPlain = new ContentType("text/plain"); /// /// Content type constructor @@ -85,6 +101,8 @@ public static ContentType From(string value) "application/xml" => Xml, "application/x-www-form-urlencoded" => FormUrlEncoded, "application/octet-stream" => OctetStream, + "multipart/form-data" => MultipartFormData, + "text/plain" => TextPlain, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } @@ -102,6 +120,8 @@ public static ContentType From(Enumeration value) Enumeration.Xml => Xml, Enumeration.FormUrlEncoded => FormUrlEncoded, Enumeration.OctetStream => OctetStream, + Enumeration.MultipartFormData => MultipartFormData, + Enumeration.TextPlain => TextPlain, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } @@ -124,6 +144,8 @@ public static Enumeration ToEnum(ContentType value) "application/xml" => Enumeration.Xml, "application/x-www-form-urlencoded" => Enumeration.FormUrlEncoded, "application/octet-stream" => Enumeration.OctetStream, + "multipart/form-data" => Enumeration.MultipartFormData, + "text/plain" => Enumeration.TextPlain, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } @@ -146,6 +168,8 @@ public static Enumeration ToEnum(string value) "application/xml" => Enumeration.Xml, "application/x-www-form-urlencoded" => Enumeration.FormUrlEncoded, "application/octet-stream" => Enumeration.OctetStream, + "multipart/form-data" => Enumeration.MultipartFormData, + "text/plain" => Enumeration.TextPlain, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } From 7a778135726a24846b291a478c549d8c6b25c754 Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Wed, 9 Dec 2020 07:59:22 +0100 Subject: [PATCH 03/17] version bump --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 83b1ab4..8f6c07a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 0.3.4 + 0.3.5 \ No newline at end of file From 689d2caa0cf47c5db870614c3eed82b45fad1c10 Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Mon, 14 Dec 2020 13:48:51 +0100 Subject: [PATCH 04/17] nuget updates --- Directory.Build.props | 2 +- src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 8f6c07a..4ba80d2 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 0.3.5 + 0.3.6 \ No newline at end of file diff --git a/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj b/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj index 7889a5a..ec4a7b3 100644 --- a/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj +++ b/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj @@ -13,7 +13,7 @@ - + all From 553e7e6b50b941247914d30d55a1f16c504eb86d Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Sat, 2 Jan 2021 14:03:31 +0100 Subject: [PATCH 05/17] maintenance updates --- .github/workflows/codeql-analysis.yml | 39 ++---------------------- .github/workflows/dotnet-core.yml | 2 +- .github/workflows/sonarqube-analysis.yml | 2 +- LICENSE | 2 +- README.md | 7 ++++- 5 files changed, 11 insertions(+), 41 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 013b298..80734df 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,20 +1,8 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# ******** NOTE ******** - name: "CodeQL Analyze" on: pull_request: - branches: [ develop, main ] + branches: [ develop ] schedule: - cron: '36 12 * * 3' @@ -26,9 +14,6 @@ jobs: fail-fast: false matrix: language: [ 'csharp' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - # Learn more... - # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection steps: - name: Checkout repository @@ -41,31 +26,11 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: '5.0.x' - # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v1 with: languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v1 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v1 \ No newline at end of file diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index 83a9d5c..6850245 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -12,7 +12,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest, windows-latest ] + os: [ ubuntu-latest, windows-latest, macos-latest ] steps: - uses: actions/checkout@v2 - name: Setup .NET Core 3.1 diff --git a/.github/workflows/sonarqube-analysis.yml b/.github/workflows/sonarqube-analysis.yml index 5078324..0fcfa4a 100644 --- a/.github/workflows/sonarqube-analysis.yml +++ b/.github/workflows/sonarqube-analysis.yml @@ -21,7 +21,7 @@ jobs: with: dotnet-version: '5.0.x' - name: SonarScanner for .NET Core with pull request decoration support - uses: highbyte/sonarscan-dotnet@2.0-beta + uses: highbyte/sonarscan-dotnet@2.0 with: sonarProjectKey: qatoolkit_qatoolkit-core-net sonarProjectName: qatoolkit_qatoolkit-core-net diff --git a/LICENSE b/LICENSE index 345345f..b4bc1c7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Miha Jakovac +Copyright (c) 2020-2021 Miha Jakovac Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 54bda34..d31a163 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,17 @@ [![CodeQL](https://github.com/qatoolkit/qatoolkit-core-net/workflows/CodeQL%20Analyze/badge.svg)](https://github.com/qatoolkit/qatoolkit-core-net/security/code-scanning) [![Sonarcloud Quality gate](https://github.com/qatoolkit/qatoolkit-core-net/workflows/Sonarqube%20Analyze/badge.svg)](https://sonarcloud.io/dashboard?id=qatoolkit_qatoolkit-core-net) [![NuGet package](https://img.shields.io/nuget/v/QAToolKit.Core?label=QAToolKit.Core)](https://www.nuget.org/packages/QAToolKit.Core/) +[![Discord](https://img.shields.io/discord/787220825127780354?color=%23267CB9&label=Discord%20chat)](https://discord.gg/hYs6ayYQC5) ## Description `QAToolKit.Core` is a .NET Standard 2.1 library, that contains core objects and functions of the toolkit. It's normally not used as a standalone library but is a dependency for other QAToolKit libraries. Supported .NET frameworks and standards: `netstandard2.0`, `netstandard2.1`, `netcoreapp3.1`, `net5.0` +Get in touch with me on: + +[![Discord](https://img.shields.io/discord/787220825127780354?color=%23267CB9&label=Discord%20chat)](https://discord.gg/hYs6ayYQC5) + ## 1. HttpRequest functions HttpRequest object is one of the main objects that is shared among the QA Toolkit libraries. `QAToolKit.Core` library contains `HttpRequestTools` which can manipulate the HttpRequest object. @@ -72,7 +77,7 @@ To-do MIT License -Copyright (c) 2020 Miha Jakovac +Copyright (c) 2020-2021 Miha Jakovac Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From af95651762cebbe66a0788ea9b4b99cc0eb953b8 Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Thu, 25 Feb 2021 19:04:11 +0100 Subject: [PATCH 06/17] Hashing helper, refactorings * Hashing helper, refactorings * hashing helper to static --- .gitignore | 1 + Directory.Build.props | 2 +- .../Helpers/DictionaryHelperTests.cs | 19 ++++---- .../Helpers/HashingHelperTests.cs | 35 +++++++++++++++ .../QAToolKit.Core.Test.csproj | 7 +-- src/QAToolKit.Core/Helpers/HashingHelper.cs | 44 +++++++++++++++++++ .../Interfaces/ISQLTestResult.cs | 5 ++- src/QAToolKit.Core/QAToolKit.Core.csproj | 1 + 8 files changed, 100 insertions(+), 14 deletions(-) create mode 100644 src/QAToolKit.Core.Test/Helpers/HashingHelperTests.cs create mode 100644 src/QAToolKit.Core/Helpers/HashingHelper.cs diff --git a/.gitignore b/.gitignore index 85de9d6..7f5771f 100644 --- a/.gitignore +++ b/.gitignore @@ -361,3 +361,4 @@ MigrationBackup/ # Fody - auto-generated XML schema FodyWeavers.xsd /src/QAToolKit.Core.Test/global.json +/.idea/ diff --git a/Directory.Build.props b/Directory.Build.props index 4ba80d2..b580f08 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 0.3.6 + 0.3.7 \ No newline at end of file diff --git a/src/QAToolKit.Core.Test/Helpers/DictionaryHelperTests.cs b/src/QAToolKit.Core.Test/Helpers/DictionaryHelperTests.cs index dd37356..288c2d2 100644 --- a/src/QAToolKit.Core.Test/Helpers/DictionaryHelperTests.cs +++ b/src/QAToolKit.Core.Test/Helpers/DictionaryHelperTests.cs @@ -6,8 +6,15 @@ namespace QAToolKit.Core.Test.Helpers { public class DictionaryHelperTests { - [Fact] - public void DictionaryContainsKey_Success() + [Theory] + [InlineData("key1")] + [InlineData("kEy1")] + [InlineData("caTegory")] + [InlineData("Category")] + [InlineData("category")] + [InlineData("Name")] + [InlineData("name")] + public void DictionaryContainsKey_Success(string key) { var dictionary = new Dictionary { { "Key1", "Id"}, @@ -15,13 +22,7 @@ public void DictionaryContainsKey_Success() { "Name", "MJ"} }; - Assert.True(dictionary.KeyExists("key1")); - Assert.True(dictionary.KeyExists("kEy1")); - Assert.True(dictionary.KeyExists("caTegory")); - Assert.True(dictionary.KeyExists("Category")); - Assert.True(dictionary.KeyExists("category")); - Assert.True(dictionary.KeyExists("Name")); - Assert.True(dictionary.KeyExists("name")); + Assert.True(dictionary.KeyExists(key)); ; } [Fact] diff --git a/src/QAToolKit.Core.Test/Helpers/HashingHelperTests.cs b/src/QAToolKit.Core.Test/Helpers/HashingHelperTests.cs new file mode 100644 index 0000000..a405a35 --- /dev/null +++ b/src/QAToolKit.Core.Test/Helpers/HashingHelperTests.cs @@ -0,0 +1,35 @@ +using System; +using QAToolKit.Core.Helpers; +using Xunit; + +namespace QAToolKit.Core.Test.Helpers +{ + public class HashingHelperTests + { + [Fact] + public void Hashing_Success() + { + var hash = HashingHelper.GenerateStringHash("SET STATISTICS TIME ON;SET STATISTICS IO ON;SELECT * FROM mytable INNER JOIN mytable2 ON mytable.id=mytable2.sampleid;SET STATISTICS TIME OFF;SET STATISTICS IO OFF;"); + + Assert.Equal("0x3983EB6B3BF4491D4A288DAC9CC66484", hash); + } + + [Theory] + [InlineData("SETSTATISTICS TIME ON;SET STATISTICS IO ON;SELECT * FROM mytable INNER JOIN mytable2 ON mytable.id=mytable2.sampleid;SET STATISTICS TIME OFF;SET STATISTICS IO OFF;")] + [InlineData("SETSTATISTICS TIME ON;SET STATISTICS IO ON;SELECT * FROM mytable INNER JOIN mytable2 ON mytable.id=mytable2.sampleid;SET STATISTICS TIME OFF;SET STATISTICS IO OFF")] + [InlineData("SETSTATISTICS TIME ON;SET STATISTICS IO ON;SELECT * FROM mytable INNER JOIN mytable2 ON mytable.id=mytable2.sid;SET STATISTICS TIME OFF;SET STATISTICS IO OFF;")] + [InlineData("")] + public void HashingShouldFail_Success(string input) + { + var hash = HashingHelper.GenerateStringHash(input); + + Assert.NotEqual("0x3983EB6B3BF4491D4A288DAC9CC66484", hash); + } + + [Fact] + public void HashingShouldThrowNullException() + { + Assert.Throws(()=> HashingHelper.GenerateStringHash(null)); + } + } +} \ No newline at end of file diff --git a/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj b/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj index ec4a7b3..ad333dd 100644 --- a/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj +++ b/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj @@ -7,19 +7,20 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/QAToolKit.Core/Helpers/HashingHelper.cs b/src/QAToolKit.Core/Helpers/HashingHelper.cs new file mode 100644 index 0000000..d08d63e --- /dev/null +++ b/src/QAToolKit.Core/Helpers/HashingHelper.cs @@ -0,0 +1,44 @@ +using System; +using System.Text; +using Murmur; + +namespace QAToolKit.Core.Helpers +{ + /// + /// Hashing Helper + /// + public static class HashingHelper + { + /// + /// Generate a non-cryptographic string hash by MurMur algorithm + /// + /// + /// + public static string GenerateStringHash(string stringToHash) + { + if (stringToHash == null) + { + throw new ArgumentNullException(nameof(stringToHash)); + } + + var hash = MurmurHash.Create128(); + var hashArray = hash.ComputeHash(Encoding.UTF8.GetBytes(stringToHash)); + + return ConvertBytesToString(hashArray); + } + + private static string ConvertBytesToString(in byte[] data) + { + Array.Reverse(data); + var sBuilder = new StringBuilder(); + + foreach (var t in data) + { + sBuilder.Append(t.ToString("x2")); + } + + // Return the hexadecimal string. + return $"0x{sBuilder.ToString().ToUpper()}"; + } + } +} \ No newline at end of file diff --git a/src/QAToolKit.Core/Interfaces/ISQLTestResult.cs b/src/QAToolKit.Core/Interfaces/ISQLTestResult.cs index 50d24e5..af01621 100644 --- a/src/QAToolKit.Core/Interfaces/ISQLTestResult.cs +++ b/src/QAToolKit.Core/Interfaces/ISQLTestResult.cs @@ -1,8 +1,11 @@ -namespace QAToolKit.Core.Interfaces +using System; + +namespace QAToolKit.Core.Interfaces { /// /// SQL test result interface /// + [Obsolete("It will be removed in future releases. Database nuget has it's own interfaces.")] public interface ISqlTestResult { /// diff --git a/src/QAToolKit.Core/QAToolKit.Core.csproj b/src/QAToolKit.Core/QAToolKit.Core.csproj index 7aa2eb3..5df259d 100644 --- a/src/QAToolKit.Core/QAToolKit.Core.csproj +++ b/src/QAToolKit.Core/QAToolKit.Core.csproj @@ -34,6 +34,7 @@ + From 951a198921f73c80232389add3320f8bb8f07398 Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Thu, 4 Mar 2021 17:49:28 +0100 Subject: [PATCH 07/17] convert to pascal case string helper --- Directory.Build.props | 2 +- .../Helpers/StringHelperTests.cs | 16 ++++++ src/QAToolKit.Core/Helpers/StringHelper.cs | 52 ++++++++++++------- 3 files changed, 50 insertions(+), 20 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index b580f08..f49f3e0 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 0.3.7 + 0.3.8 \ No newline at end of file diff --git a/src/QAToolKit.Core.Test/Helpers/StringHelperTests.cs b/src/QAToolKit.Core.Test/Helpers/StringHelperTests.cs index 1e3ca4f..52bf8f9 100644 --- a/src/QAToolKit.Core.Test/Helpers/StringHelperTests.cs +++ b/src/QAToolKit.Core.Test/Helpers/StringHelperTests.cs @@ -106,5 +106,21 @@ public void StringContainsCaseInsensitive_Success(string input) { Assert.True(input.ContainsCaseInsensitive("Test STrinG 1")); } + + [Theory] + [InlineData("test string ")] + [InlineData("test string")] + [InlineData("test-string ")] + [InlineData(" test_string")] + [InlineData("TEST string ")] + [InlineData("test String")] + [InlineData("test-STRING ")] + [InlineData(" TEST STRING")] + public void ConvertStringToPascalCase_Success(string input) + { + var result = StringHelper.ToPascalCase(input, new string[]{"-","_"," "}); + + Assert.Equal("TestString", result); + } } } diff --git a/src/QAToolKit.Core/Helpers/StringHelper.cs b/src/QAToolKit.Core/Helpers/StringHelper.cs index 2621a64..02bc6f4 100644 --- a/src/QAToolKit.Core/Helpers/StringHelper.cs +++ b/src/QAToolKit.Core/Helpers/StringHelper.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.RegularExpressions; namespace QAToolKit.Core.Helpers @@ -16,8 +17,8 @@ public static class StringHelper /// public static string ReplaceMultipleSpacesWithOne(string input) { - RegexOptions options = RegexOptions.None; - Regex regex = new Regex("[ ]{2,}", options); + const RegexOptions options = RegexOptions.None; + var regex = new Regex("[ ]{2,}", options); return regex.Replace(input, " "); } @@ -30,26 +31,23 @@ public static string ReplaceMultipleSpacesWithOne(string input) /// public static string Between(string mainString, string firstString, string lastString) { - string FinalString; - var Pos1 = mainString.ToLower().IndexOf(firstString.ToLower()) + firstString.Length; - var Pos2 = mainString.ToLower().IndexOf(lastString.ToLower()); + var pos1 = mainString.ToLower().IndexOf(firstString.ToLower()) + firstString.Length; + var pos2 = mainString.ToLower().IndexOf(lastString.ToLower()); - if (Pos1 > Pos2) + if (pos1 > pos2) { var allIndexes = AllIndexesOf(mainString.ToLower(), lastString.ToLower()); - foreach (int index in allIndexes) + foreach (var index in allIndexes) { - if (index > Pos1) - { - Pos2 = index; - break; - } + if (index <= pos1) continue; + pos2 = index; + break; } } - FinalString = mainString.ToLower().Substring(Pos1, Pos2 - Pos1); - return FinalString; + var finalString = mainString.ToLower().Substring(pos1, pos2 - pos1); + return finalString; } @@ -89,12 +87,12 @@ public static string TrimString(string input) /// /// /// - public static List AllIndexesOf(string str, string value) + public static IEnumerable AllIndexesOf(string str, string value) { - if (String.IsNullOrEmpty(value)) + if (string.IsNullOrEmpty(value)) throw new ArgumentException("the string to find may not be empty", nameof(value)); var indexes = new List(); - for (int index = 0; ; index += value.Length) + for (var index = 0;; index += value.Length) { index = str.IndexOf(value, index); if (index == -1) @@ -131,9 +129,25 @@ public static string ObfuscateStringBetween(string original, string startTag, st /// /// /// - public static bool ContainsCaseInsensitive(this string text, string value, StringComparison stringComparison = StringComparison.CurrentCultureIgnoreCase) + public static bool ContainsCaseInsensitive(this string text, string value, + StringComparison stringComparison = StringComparison.CurrentCultureIgnoreCase) { return text.IndexOf(value, stringComparison) >= 0; } + + /// + /// Convert strings with different separators to pascal case string + /// + /// + /// + /// + public static string ToPascalCase(this string input, string[] separators) + { + var words = input.Split(separators, StringSplitOptions.RemoveEmptyEntries) + .Select(word => word.Substring(0, 1).ToUpper() + word.Substring(1).ToLower()); + + var result = string.Concat(words); + return result; + } } -} +} \ No newline at end of file From 6656840ac6c5f80ad2a3b71755e736ec9ff97305 Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Tue, 17 Aug 2021 20:02:03 +0200 Subject: [PATCH 08/17] updated dependencies and version bump --- Directory.Build.props | 2 +- src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj | 6 +++--- src/QAToolKit.Core/QAToolKit.Core.csproj | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index f49f3e0..e97debe 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 0.3.8 + 0.3.9 \ No newline at end of file diff --git a/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj b/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj index ad333dd..055de37 100644 --- a/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj +++ b/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj @@ -7,20 +7,20 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/QAToolKit.Core/QAToolKit.Core.csproj b/src/QAToolKit.Core/QAToolKit.Core.csproj index 5df259d..9f2d65c 100644 --- a/src/QAToolKit.Core/QAToolKit.Core.csproj +++ b/src/QAToolKit.Core/QAToolKit.Core.csproj @@ -35,6 +35,6 @@ - + From 9c849092393876e808c88fdcc590b2ba2aa56e8d Mon Sep 17 00:00:00 2001 From: mihaj Date: Sun, 10 Oct 2021 10:56:53 +0200 Subject: [PATCH 09/17] new content type support text/json --- .../ContentType/ContentTypeTextJsonTests.cs | 71 +++++++++++++++++++ src/QAToolKit.Core/Models/ContentType.cs | 14 +++- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 src/QAToolKit.Core.Test/Models/ContentType/ContentTypeTextJsonTests.cs diff --git a/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeTextJsonTests.cs b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeTextJsonTests.cs new file mode 100644 index 0000000..0baaa00 --- /dev/null +++ b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeTextJsonTests.cs @@ -0,0 +1,71 @@ +using QAToolKit.Core.Exceptions; +using QAToolKit.Core.Models; +using Xunit; + +namespace QAToolKit.Core.Test.Models +{ + public class ContentTypeTextJsonTests + { + [Fact] + public void ContentTypeTextJsonTestsPresent_Success() + { + Assert.Equal("text/json", ContentType.TextJson.Value()); + } + + [Theory] + [InlineData("text/json")] + public void ContentTypeTextJsonFromString_Success(string value) + { + Assert.Equal(ContentType.TextJson, ContentType.From(value)); + } + + [Theory] + [InlineData("")] + [InlineData(null)] + [InlineData("somestring")] + public void ConvertFromString_Fails(string value) + { + Assert.Throws(() => ContentType.From(value)); + } + + [Theory] + [InlineData(ContentType.Enumeration.TextJson)] + public void ConverTextJsonFromEnum_Success(ContentType.Enumeration value) + { + Assert.Equal(ContentType.TextJson, ContentType.From(value)); + } + + [Fact] + public void ConvertTextJsonObjectToString_Success() + { + Assert.Equal("text/json", ContentType.TextJson.Value()); + } + + [Fact] + public void ConvertTextJsonObjectToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.TextJson, ContentType.ToEnum(ContentType.TextJson)); + } + + [Fact] + public void ConvertTextJsonStringToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.TextJson, ContentType.ToEnum("text/json")); + } + + [Theory] + [InlineData("")] + [InlineData(null)] + [InlineData("somestring")] + public void ConvertStringToEnum_Fails(string value) + { + Assert.Throws(() => ContentType.ToEnum(value)); + } + + [Fact] + public void ConvertTextJsonStringToContentType_Success() + { + Assert.Equal(ContentType.TextJson, ContentType.From("text/json")); + } + } +} diff --git a/src/QAToolKit.Core/Models/ContentType.cs b/src/QAToolKit.Core/Models/ContentType.cs index ca15f95..c49238d 100644 --- a/src/QAToolKit.Core/Models/ContentType.cs +++ b/src/QAToolKit.Core/Models/ContentType.cs @@ -35,7 +35,11 @@ public enum Enumeration /// /// text/plain content type /// - TextPlain + TextPlain, + /// + /// text/json content type + /// + TextJson } private readonly string _value; @@ -64,6 +68,10 @@ public enum Enumeration /// text/plain content type /// public static readonly ContentType TextPlain = new ContentType("text/plain"); + /// + /// text/json content type + /// + public static readonly ContentType TextJson = new ContentType("text/json"); /// /// Content type constructor @@ -103,6 +111,7 @@ public static ContentType From(string value) "application/octet-stream" => OctetStream, "multipart/form-data" => MultipartFormData, "text/plain" => TextPlain, + "text/json" => TextJson, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } @@ -122,6 +131,7 @@ public static ContentType From(Enumeration value) Enumeration.OctetStream => OctetStream, Enumeration.MultipartFormData => MultipartFormData, Enumeration.TextPlain => TextPlain, + Enumeration.TextJson => TextJson, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } @@ -146,6 +156,7 @@ public static Enumeration ToEnum(ContentType value) "application/octet-stream" => Enumeration.OctetStream, "multipart/form-data" => Enumeration.MultipartFormData, "text/plain" => Enumeration.TextPlain, + "text/json" => Enumeration.TextJson, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } @@ -170,6 +181,7 @@ public static Enumeration ToEnum(string value) "application/octet-stream" => Enumeration.OctetStream, "multipart/form-data" => Enumeration.MultipartFormData, "text/plain" => Enumeration.TextPlain, + "text/json" => Enumeration.TextJson, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } From fa4d2cad59a7844c25b82dfbbddf32bc52438910 Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Sun, 10 Oct 2021 11:01:55 +0200 Subject: [PATCH 10/17] new content-type text/json (#57) * updated dependencies and version bump * new content type support text/json --- .../ContentType/ContentTypeTextJsonTests.cs | 71 +++++++++++++++++++ src/QAToolKit.Core/Models/ContentType.cs | 14 +++- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 src/QAToolKit.Core.Test/Models/ContentType/ContentTypeTextJsonTests.cs diff --git a/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeTextJsonTests.cs b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeTextJsonTests.cs new file mode 100644 index 0000000..0baaa00 --- /dev/null +++ b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypeTextJsonTests.cs @@ -0,0 +1,71 @@ +using QAToolKit.Core.Exceptions; +using QAToolKit.Core.Models; +using Xunit; + +namespace QAToolKit.Core.Test.Models +{ + public class ContentTypeTextJsonTests + { + [Fact] + public void ContentTypeTextJsonTestsPresent_Success() + { + Assert.Equal("text/json", ContentType.TextJson.Value()); + } + + [Theory] + [InlineData("text/json")] + public void ContentTypeTextJsonFromString_Success(string value) + { + Assert.Equal(ContentType.TextJson, ContentType.From(value)); + } + + [Theory] + [InlineData("")] + [InlineData(null)] + [InlineData("somestring")] + public void ConvertFromString_Fails(string value) + { + Assert.Throws(() => ContentType.From(value)); + } + + [Theory] + [InlineData(ContentType.Enumeration.TextJson)] + public void ConverTextJsonFromEnum_Success(ContentType.Enumeration value) + { + Assert.Equal(ContentType.TextJson, ContentType.From(value)); + } + + [Fact] + public void ConvertTextJsonObjectToString_Success() + { + Assert.Equal("text/json", ContentType.TextJson.Value()); + } + + [Fact] + public void ConvertTextJsonObjectToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.TextJson, ContentType.ToEnum(ContentType.TextJson)); + } + + [Fact] + public void ConvertTextJsonStringToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.TextJson, ContentType.ToEnum("text/json")); + } + + [Theory] + [InlineData("")] + [InlineData(null)] + [InlineData("somestring")] + public void ConvertStringToEnum_Fails(string value) + { + Assert.Throws(() => ContentType.ToEnum(value)); + } + + [Fact] + public void ConvertTextJsonStringToContentType_Success() + { + Assert.Equal(ContentType.TextJson, ContentType.From("text/json")); + } + } +} diff --git a/src/QAToolKit.Core/Models/ContentType.cs b/src/QAToolKit.Core/Models/ContentType.cs index ca15f95..c49238d 100644 --- a/src/QAToolKit.Core/Models/ContentType.cs +++ b/src/QAToolKit.Core/Models/ContentType.cs @@ -35,7 +35,11 @@ public enum Enumeration /// /// text/plain content type /// - TextPlain + TextPlain, + /// + /// text/json content type + /// + TextJson } private readonly string _value; @@ -64,6 +68,10 @@ public enum Enumeration /// text/plain content type /// public static readonly ContentType TextPlain = new ContentType("text/plain"); + /// + /// text/json content type + /// + public static readonly ContentType TextJson = new ContentType("text/json"); /// /// Content type constructor @@ -103,6 +111,7 @@ public static ContentType From(string value) "application/octet-stream" => OctetStream, "multipart/form-data" => MultipartFormData, "text/plain" => TextPlain, + "text/json" => TextJson, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } @@ -122,6 +131,7 @@ public static ContentType From(Enumeration value) Enumeration.OctetStream => OctetStream, Enumeration.MultipartFormData => MultipartFormData, Enumeration.TextPlain => TextPlain, + Enumeration.TextJson => TextJson, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } @@ -146,6 +156,7 @@ public static Enumeration ToEnum(ContentType value) "application/octet-stream" => Enumeration.OctetStream, "multipart/form-data" => Enumeration.MultipartFormData, "text/plain" => Enumeration.TextPlain, + "text/json" => Enumeration.TextJson, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } @@ -170,6 +181,7 @@ public static Enumeration ToEnum(string value) "application/octet-stream" => Enumeration.OctetStream, "multipart/form-data" => Enumeration.MultipartFormData, "text/plain" => Enumeration.TextPlain, + "text/json" => Enumeration.TextJson, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } From b91674415180f8c1f6b118f5b0a4d5818d8f2334 Mon Sep 17 00:00:00 2001 From: mihaj Date: Sun, 10 Oct 2021 11:06:43 +0200 Subject: [PATCH 11/17] version bump --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index e97debe..14df131 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 0.3.9 + 0.3.10 \ No newline at end of file From 71f418d5ee284530977d4763c6322fcb5da9bba5 Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Wed, 27 Oct 2021 19:25:52 +0200 Subject: [PATCH 12/17] format added to Property object, split class (#60) --- Directory.Build.props | 2 +- src/QAToolKit.Core/Models/HttpRequest.cs | 167 ---------------------- src/QAToolKit.Core/Models/Location.cs | 29 ++++ src/QAToolKit.Core/Models/Parameter.cs | 37 +++++ src/QAToolKit.Core/Models/Property.cs | 39 +++++ src/QAToolKit.Core/Models/RequestBody.cs | 27 ++++ src/QAToolKit.Core/Models/Response.cs | 24 ++++ src/QAToolKit.Core/Models/ResponseType.cs | 33 +++++ 8 files changed, 190 insertions(+), 168 deletions(-) create mode 100644 src/QAToolKit.Core/Models/Location.cs create mode 100644 src/QAToolKit.Core/Models/Parameter.cs create mode 100644 src/QAToolKit.Core/Models/Property.cs create mode 100644 src/QAToolKit.Core/Models/RequestBody.cs create mode 100644 src/QAToolKit.Core/Models/Response.cs create mode 100644 src/QAToolKit.Core/Models/ResponseType.cs diff --git a/Directory.Build.props b/Directory.Build.props index 14df131..9d37d92 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 0.3.10 + 0.3.11 \ No newline at end of file diff --git a/src/QAToolKit.Core/Models/HttpRequest.cs b/src/QAToolKit.Core/Models/HttpRequest.cs index 0ee3053..1f8bcc4 100644 --- a/src/QAToolKit.Core/Models/HttpRequest.cs +++ b/src/QAToolKit.Core/Models/HttpRequest.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Net; using System.Net.Http; namespace QAToolKit.Core.Models @@ -58,170 +57,4 @@ public class HttpRequest /// public List AuthenticationTypes { get; set; } } - - /// - /// An URL parameter - /// - public class Parameter - { - /// - /// Paramter name - /// - public string Name { get; set; } - /// - /// Paramter type - /// - public string Type { get; set; } - /// - /// Is parameter nullable - /// - public bool Nullable { get; set; } - /// - /// Paramter value - /// - public string Value { get; set; } - /// - /// Is parameter required - /// - public bool Required { get; set; } - /// - /// Parameter location can be either path or in query - /// - public Location Location { get; set; } - } - - /// - /// Request body or response property - /// - public class Property - { - /// - /// Property name - /// - public string Name { get; set; } - /// - /// Property description - /// - public string Description { get; set; } - /// - /// OpenApi property format of an object; string, date-time, int64,... - /// - public string Format { get; set; } - /// - /// OpenApi property type integer, string, array, object - /// - public string Type { get; set; } - /// - /// Property value - /// - public object Value { get; set; } - /// - /// Is property required - /// - public bool Required { get; set; } - /// - /// Schema properties - /// - public List Properties { get; set; } - } - - /// - /// Request body object - /// - public class RequestBody - { - /// - /// Request body model name - /// - public string Name { get; set; } - /// - /// Is parameter required - /// - public bool Required { get; set; } - /// - /// Request body content type - /// - public ContentType.Enumeration ContentType { get; set; } - /// - /// Request body model properties - /// - public List Properties { get; set; } - } - - /// - /// Response object - /// - public class Response - { - /// - /// Response HTTP status code - /// - public HttpStatusCode? StatusCode { get; set; } - /// - /// Is return object a single item or array - /// - public ResponseType Type { get; set; } - /// - /// Response paramters - /// - public List Properties { get; set; } - } - - /// - /// The location of paramter in HTTP request - /// - public enum Location - { - /// - /// Undefined - /// - Undefined, - /// - /// URI path - /// - Path, - /// - /// URI query - /// - Query, - /// - /// Header parameter - /// - Header, - /// - /// Cookie parameter - /// - Cookie - } - - /// - /// Response body type - /// - public enum ResponseType - { - /// - /// undefined response type - /// - Undefined, - /// - /// Empty body response - /// - Empty, - /// - /// Single item/object response - /// - Object, - /// - /// List of objects response - /// - Objects, - /// - /// Array of primitive values - /// - Array, - /// - /// Primitive value like integer, string, bool - /// - Primitive - } } diff --git a/src/QAToolKit.Core/Models/Location.cs b/src/QAToolKit.Core/Models/Location.cs new file mode 100644 index 0000000..62c7a62 --- /dev/null +++ b/src/QAToolKit.Core/Models/Location.cs @@ -0,0 +1,29 @@ +namespace QAToolKit.Core.Models +{ + /// + /// The location of parameter in HTTP request + /// + public enum Location + { + /// + /// Undefined + /// + Undefined, + /// + /// URI path + /// + Path, + /// + /// URI query + /// + Query, + /// + /// Header parameter + /// + Header, + /// + /// Cookie parameter + /// + Cookie + } +} \ No newline at end of file diff --git a/src/QAToolKit.Core/Models/Parameter.cs b/src/QAToolKit.Core/Models/Parameter.cs new file mode 100644 index 0000000..5d2a8e3 --- /dev/null +++ b/src/QAToolKit.Core/Models/Parameter.cs @@ -0,0 +1,37 @@ +namespace QAToolKit.Core.Models +{ + /// + /// An URL parameter + /// + public class Parameter + { + /// + /// Parameter name + /// + public string Name { get; set; } + /// + /// Parameter type like string, integer, number,... + /// + public string Type { get; set; } + /// + /// Parameter format like int32, int64, double,... + /// + public string Format { get; set; } + /// + /// Is parameter nullable + /// + public bool Nullable { get; set; } + /// + /// Parameter value + /// + public string Value { get; set; } + /// + /// Is parameter required + /// + public bool Required { get; set; } + /// + /// Parameter location can be either path or in query + /// + public Location Location { get; set; } + } +} \ No newline at end of file diff --git a/src/QAToolKit.Core/Models/Property.cs b/src/QAToolKit.Core/Models/Property.cs new file mode 100644 index 0000000..5fe9cc8 --- /dev/null +++ b/src/QAToolKit.Core/Models/Property.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; + +namespace QAToolKit.Core.Models +{ + /// + /// Request body or response property + /// + public class Property + { + /// + /// Property name + /// + public string Name { get; set; } + /// + /// Property description + /// + public string Description { get; set; } + /// + /// OpenApi property format of an object; string, date-time, int64,... + /// + public string Format { get; set; } + /// + /// OpenApi property type integer, string, array, object + /// + public string Type { get; set; } + /// + /// Property value + /// + public object Value { get; set; } + /// + /// Is property required + /// + public bool Required { get; set; } + /// + /// Schema properties + /// + public List Properties { get; set; } + } +} \ No newline at end of file diff --git a/src/QAToolKit.Core/Models/RequestBody.cs b/src/QAToolKit.Core/Models/RequestBody.cs new file mode 100644 index 0000000..45654c6 --- /dev/null +++ b/src/QAToolKit.Core/Models/RequestBody.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; + +namespace QAToolKit.Core.Models +{ + /// + /// Request body object + /// + public class RequestBody + { + /// + /// Request body model name + /// + public string Name { get; set; } + /// + /// Is parameter required + /// + public bool Required { get; set; } + /// + /// Request body content type + /// + public ContentType.Enumeration ContentType { get; set; } + /// + /// Request body model properties + /// + public List Properties { get; set; } + } +} \ No newline at end of file diff --git a/src/QAToolKit.Core/Models/Response.cs b/src/QAToolKit.Core/Models/Response.cs new file mode 100644 index 0000000..f3cdadc --- /dev/null +++ b/src/QAToolKit.Core/Models/Response.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using System.Net; + +namespace QAToolKit.Core.Models +{ + /// + /// Response object + /// + public class Response + { + /// + /// Response HTTP status code + /// + public HttpStatusCode? StatusCode { get; set; } + /// + /// Is return object a single item or array + /// + public ResponseType Type { get; set; } + /// + /// Response parameters + /// + public List Properties { get; set; } + } +} \ No newline at end of file diff --git a/src/QAToolKit.Core/Models/ResponseType.cs b/src/QAToolKit.Core/Models/ResponseType.cs new file mode 100644 index 0000000..3e4b548 --- /dev/null +++ b/src/QAToolKit.Core/Models/ResponseType.cs @@ -0,0 +1,33 @@ +namespace QAToolKit.Core.Models +{ + /// + /// Response body type + /// + public enum ResponseType + { + /// + /// undefined response type + /// + Undefined, + /// + /// Empty body response + /// + Empty, + /// + /// Single item/object response + /// + Object, + /// + /// List of objects response + /// + Objects, + /// + /// Array of primitive values + /// + Array, + /// + /// Primitive value like integer, string, bool + /// + Primitive + } +} \ No newline at end of file From e2c763402332e08856f8cc38295526f11b43b051 Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Sat, 27 Nov 2021 11:04:18 +0100 Subject: [PATCH 13/17] Content type updates, Request Body content type as string (#62) --- Directory.Build.props | 2 +- src/QAToolKit.Core.Test/Assets/AddBike.json | 2 +- src/QAToolKit.Core.Test/Assets/addPet.json | 6 +-- .../Fixtures/AddNewUserHttpRequest.cs | 2 +- .../Models/ContentType/ContentTypPdflTests.cs | 52 +++++++++++++++++++ .../ContentType/ContentTypTextCsvTests.cs | 52 +++++++++++++++++++ .../ContentType/ContentTypTextXmlTests.cs | 52 +++++++++++++++++++ .../HttpRequestBodyGenerator.cs | 2 +- src/QAToolKit.Core/Models/ContentType.cs | 40 +++++++++++++- src/QAToolKit.Core/Models/RequestBody.cs | 2 +- 10 files changed, 202 insertions(+), 10 deletions(-) create mode 100644 src/QAToolKit.Core.Test/Models/ContentType/ContentTypPdflTests.cs create mode 100644 src/QAToolKit.Core.Test/Models/ContentType/ContentTypTextCsvTests.cs create mode 100644 src/QAToolKit.Core.Test/Models/ContentType/ContentTypTextXmlTests.cs diff --git a/Directory.Build.props b/Directory.Build.props index 9d37d92..63e5e51 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 0.3.11 + 0.3.12 \ No newline at end of file diff --git a/src/QAToolKit.Core.Test/Assets/AddBike.json b/src/QAToolKit.Core.Test/Assets/AddBike.json index 228d160..74f6ec5 100644 --- a/src/QAToolKit.Core.Test/Assets/AddBike.json +++ b/src/QAToolKit.Core.Test/Assets/AddBike.json @@ -34,7 +34,7 @@ { "Name": "Bicycle", "Required": false, - "ContentType": 0, + "ContentType": "application/json", "Properties": [ { "Name": "id", diff --git a/src/QAToolKit.Core.Test/Assets/addPet.json b/src/QAToolKit.Core.Test/Assets/addPet.json index 6223720..8da7402 100644 --- a/src/QAToolKit.Core.Test/Assets/addPet.json +++ b/src/QAToolKit.Core.Test/Assets/addPet.json @@ -16,7 +16,7 @@ { "Name": "Pet", "Required": true, - "ContentType": 0, + "ContentType": "application/json", "Properties": [ { "Name": "id", @@ -163,7 +163,7 @@ { "Name": "Pet", "Required": true, - "ContentType": 1, + "ContentType": "application/xml", "Properties": [ { "Name": "id", @@ -310,7 +310,7 @@ { "Name": "Pet", "Required": true, - "ContentType": 2, + "ContentType": "application/x-www-form-urlencoded", "Properties": [ { "Name": "id", diff --git a/src/QAToolKit.Core.Test/Fixtures/AddNewUserHttpRequest.cs b/src/QAToolKit.Core.Test/Fixtures/AddNewUserHttpRequest.cs index ae10d49..4295765 100644 --- a/src/QAToolKit.Core.Test/Fixtures/AddNewUserHttpRequest.cs +++ b/src/QAToolKit.Core.Test/Fixtures/AddNewUserHttpRequest.cs @@ -20,7 +20,7 @@ public static HttpRequest Get() Path = "/users", RequestBodies = new List() { new RequestBody(){ - ContentType = ContentType.Enumeration.Json, + ContentType = "application/json", Name = "User", Required = true, Properties = new List(){ diff --git a/src/QAToolKit.Core.Test/Models/ContentType/ContentTypPdflTests.cs b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypPdflTests.cs new file mode 100644 index 0000000..39d21ee --- /dev/null +++ b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypPdflTests.cs @@ -0,0 +1,52 @@ +using QAToolKit.Core.Models; +using Xunit; + +namespace QAToolKit.Core.Test.Models +{ + public class ContentTypePdfTests + { + [Fact] + public void ContentTypePdfTestsPresent_Success() + { + Assert.Equal("application/pdf", ContentType.Pdf.Value()); + } + + [Theory] + [InlineData("application/pdf")] + public void ConvertXmlFromString_Success(string value) + { + Assert.Equal(ContentType.Pdf, ContentType.From(value)); + } + + [Theory] + [InlineData(ContentType.Enumeration.Pdf)] + public void ConvertXmlFromEnum_Success(ContentType.Enumeration value) + { + Assert.Equal(ContentType.Pdf, ContentType.From(value)); + } + + [Fact] + public void ConvertXmlObjectToString_Success() + { + Assert.Equal("application/pdf", ContentType.Pdf.Value()); + } + + [Fact] + public void ConvertXmlObjectToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.Pdf, ContentType.ToEnum(ContentType.Pdf)); + } + + [Fact] + public void ConvertXmlStringToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.Pdf, ContentType.ToEnum("application/pdf")); + } + + [Fact] + public void ConvertXmlStringToContentType_Success() + { + Assert.Equal(ContentType.Pdf, ContentType.From("application/pdf")); + } + } +} diff --git a/src/QAToolKit.Core.Test/Models/ContentType/ContentTypTextCsvTests.cs b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypTextCsvTests.cs new file mode 100644 index 0000000..cb495e9 --- /dev/null +++ b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypTextCsvTests.cs @@ -0,0 +1,52 @@ +using QAToolKit.Core.Models; +using Xunit; + +namespace QAToolKit.Core.Test.Models +{ + public class ContentTypeTextCsvTests + { + [Fact] + public void ContentTypeTextCSvTestsPresent_Success() + { + Assert.Equal("text/csv", ContentType.TextCsv.Value()); + } + + [Theory] + [InlineData("text/csv")] + public void ConvertCSvFromString_Success(string value) + { + Assert.Equal(ContentType.TextCsv, ContentType.From(value)); + } + + [Theory] + [InlineData(ContentType.Enumeration.TextCsv)] + public void ConvertCSvFromEnum_Success(ContentType.Enumeration value) + { + Assert.Equal(ContentType.TextCsv, ContentType.From(value)); + } + + [Fact] + public void ConvertCSvObjectToString_Success() + { + Assert.Equal("text/csv", ContentType.TextCsv.Value()); + } + + [Fact] + public void ConvertCSvObjectToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.TextCsv, ContentType.ToEnum(ContentType.TextCsv)); + } + + [Fact] + public void ConvertCSvStringToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.TextCsv, ContentType.ToEnum("text/csv")); + } + + [Fact] + public void ConvertCSvStringToContentType_Success() + { + Assert.Equal(ContentType.TextCsv, ContentType.From("text/csv")); + } + } +} diff --git a/src/QAToolKit.Core.Test/Models/ContentType/ContentTypTextXmlTests.cs b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypTextXmlTests.cs new file mode 100644 index 0000000..b346d64 --- /dev/null +++ b/src/QAToolKit.Core.Test/Models/ContentType/ContentTypTextXmlTests.cs @@ -0,0 +1,52 @@ +using QAToolKit.Core.Models; +using Xunit; + +namespace QAToolKit.Core.Test.Models +{ + public class ContentTypeTextXmlTests + { + [Fact] + public void ContentTypeTextXmlTestsPresent_Success() + { + Assert.Equal("text/xml", ContentType.TextXml.Value()); + } + + [Theory] + [InlineData("text/xml")] + public void ConvertXmlFromString_Success(string value) + { + Assert.Equal(ContentType.TextXml, ContentType.From(value)); + } + + [Theory] + [InlineData(ContentType.Enumeration.TextXml)] + public void ConvertXmlFromEnum_Success(ContentType.Enumeration value) + { + Assert.Equal(ContentType.TextXml, ContentType.From(value)); + } + + [Fact] + public void ConvertXmlObjectToString_Success() + { + Assert.Equal("text/xml", ContentType.TextXml.Value()); + } + + [Fact] + public void ConvertXmlObjectToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.TextXml, ContentType.ToEnum(ContentType.TextXml)); + } + + [Fact] + public void ConvertXmlStringToEnum_Success() + { + Assert.Equal(ContentType.Enumeration.TextXml, ContentType.ToEnum("text/xml")); + } + + [Fact] + public void ConvertXmlStringToContentType_Success() + { + Assert.Equal(ContentType.TextXml, ContentType.From("text/xml")); + } + } +} diff --git a/src/QAToolKit.Core/HttpRequestTools/HttpRequestBodyGenerator.cs b/src/QAToolKit.Core/HttpRequestTools/HttpRequestBodyGenerator.cs index a924207..775d1db 100644 --- a/src/QAToolKit.Core/HttpRequestTools/HttpRequestBodyGenerator.cs +++ b/src/QAToolKit.Core/HttpRequestTools/HttpRequestBodyGenerator.cs @@ -36,7 +36,7 @@ public HttpRequestBodyGenerator(HttpRequest httpRequest, Action public object ReplaceRequestBodyModel(ContentType.Enumeration useContentType) { - var requestBody = _httpRequest.RequestBodies.FirstOrDefault(body => body.ContentType == useContentType); + var requestBody = _httpRequest.RequestBodies.FirstOrDefault(body => body.ContentType == ContentType.From(useContentType).Value()); if (requestBody != null) { diff --git a/src/QAToolKit.Core/Models/ContentType.cs b/src/QAToolKit.Core/Models/ContentType.cs index c49238d..6ded565 100644 --- a/src/QAToolKit.Core/Models/ContentType.cs +++ b/src/QAToolKit.Core/Models/ContentType.cs @@ -39,7 +39,19 @@ public enum Enumeration /// /// text/json content type /// - TextJson + TextJson, + /// + /// Text xml content type + /// + TextXml, + /// + /// Text CSV content type + /// + TextCsv, + /// + /// PDF content type + /// + Pdf } private readonly string _value; @@ -72,7 +84,19 @@ public enum Enumeration /// text/json content type /// public static readonly ContentType TextJson = new ContentType("text/json"); - + /// + /// Text XML content type + /// + public static readonly ContentType TextXml = new ContentType("text/xml"); + /// + /// Text CSV content type + /// + public static readonly ContentType TextCsv = new ContentType("text/csv"); + /// + /// PDF content type + /// + public static readonly ContentType Pdf = new ContentType("application/pdf"); + /// /// Content type constructor /// @@ -112,6 +136,9 @@ public static ContentType From(string value) "multipart/form-data" => MultipartFormData, "text/plain" => TextPlain, "text/json" => TextJson, + "text/xml" => TextXml, + "text/csv" => TextCsv, + "application/pdf" => Pdf, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } @@ -132,6 +159,9 @@ public static ContentType From(Enumeration value) Enumeration.MultipartFormData => MultipartFormData, Enumeration.TextPlain => TextPlain, Enumeration.TextJson => TextJson, + Enumeration.TextXml => TextXml, + Enumeration.TextCsv => TextCsv, + Enumeration.Pdf => Pdf, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } @@ -157,6 +187,9 @@ public static Enumeration ToEnum(ContentType value) "multipart/form-data" => Enumeration.MultipartFormData, "text/plain" => Enumeration.TextPlain, "text/json" => Enumeration.TextJson, + "text/xml" => Enumeration.TextXml, + "text/csv" => Enumeration.TextCsv, + "application/pdf" => Enumeration.Pdf, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } @@ -182,6 +215,9 @@ public static Enumeration ToEnum(string value) "multipart/form-data" => Enumeration.MultipartFormData, "text/plain" => Enumeration.TextPlain, "text/json" => Enumeration.TextJson, + "text/xml" => Enumeration.TextXml, + "text/csv" => Enumeration.TextCsv, + "application/pdf" => Enumeration.Pdf, _ => throw new QAToolKitCoreException($"{value} is invalid content type. Check the documentation which types are supported."), }; } diff --git a/src/QAToolKit.Core/Models/RequestBody.cs b/src/QAToolKit.Core/Models/RequestBody.cs index 45654c6..34499f9 100644 --- a/src/QAToolKit.Core/Models/RequestBody.cs +++ b/src/QAToolKit.Core/Models/RequestBody.cs @@ -18,7 +18,7 @@ public class RequestBody /// /// Request body content type /// - public ContentType.Enumeration ContentType { get; set; } + public string ContentType { get; set; } /// /// Request body model properties /// From 2144cc7e181a4bbccb16ad0457cfa3a124a40eb6 Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Sat, 29 Jan 2022 09:32:51 +0100 Subject: [PATCH 14/17] net 6 upgrade --- .github/workflows/codeql-analysis.yml | 4 ++-- .github/workflows/dotnet-core.yml | 8 ++++---- .github/workflows/sonarqube-analysis.yml | 6 +++--- Directory.Build.props | 2 +- LICENSE | 2 +- README.md | 2 +- src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj | 8 ++++---- src/QAToolKit.Core/QAToolKit.Core.csproj | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 80734df..de65587 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -22,10 +22,10 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: '3.1.x' - - name: Setup .NET Core 5.0 + - name: Setup .NET Core 6.0 uses: actions/setup-dotnet@v1 with: - dotnet-version: '5.0.x' + dotnet-version: '6.0.x' - name: Initialize CodeQL uses: github/codeql-action/init@v1 with: diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index 6850245..c2942ae 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -19,10 +19,10 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: '3.1.x' - - name: Setup .NET Core 5.0 + - name: Setup .NET Core 6.0 uses: actions/setup-dotnet@v1 with: - dotnet-version: '5.0.x' + dotnet-version: '6.0.x' - name: Install dependencies run: dotnet restore - name: Build @@ -47,10 +47,10 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: '3.1.x' - - name: Setup .NET Core 5.0 + - name: Setup .NET Core 6.0 uses: actions/setup-dotnet@v1 with: - dotnet-version: '5.0.x' + dotnet-version: '6.0.x' - name: Pack NuGet uses: brandedoutcast/publish-nuget@v2.5.5 with: diff --git a/.github/workflows/sonarqube-analysis.yml b/.github/workflows/sonarqube-analysis.yml index 0fcfa4a..89189e5 100644 --- a/.github/workflows/sonarqube-analysis.yml +++ b/.github/workflows/sonarqube-analysis.yml @@ -16,12 +16,12 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: '3.1.x' - - name: Setup .NET Core 5.0 + - name: Setup .NET Core 6.0 uses: actions/setup-dotnet@v1 with: - dotnet-version: '5.0.x' + dotnet-version: '6.0.x' - name: SonarScanner for .NET Core with pull request decoration support - uses: highbyte/sonarscan-dotnet@2.0 + uses: highbyte/sonarscan-dotnet@v2.1.2 with: sonarProjectKey: qatoolkit_qatoolkit-core-net sonarProjectName: qatoolkit_qatoolkit-core-net diff --git a/Directory.Build.props b/Directory.Build.props index 63e5e51..e172c42 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 0.3.12 + 0.3.13 \ No newline at end of file diff --git a/LICENSE b/LICENSE index b4bc1c7..2ee8f53 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020-2021 Miha Jakovac +Copyright (c) 2020-2022 Miha Jakovac Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index d31a163..2b0482e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Description `QAToolKit.Core` is a .NET Standard 2.1 library, that contains core objects and functions of the toolkit. It's normally not used as a standalone library but is a dependency for other QAToolKit libraries. -Supported .NET frameworks and standards: `netstandard2.0`, `netstandard2.1`, `netcoreapp3.1`, `net5.0` +Supported .NET frameworks and standards: `netstandard2.0`, `netstandard2.1`, `netcoreapp3.1`, `net6.0` Get in touch with me on: diff --git a/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj b/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj index 055de37..518a5dd 100644 --- a/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj +++ b/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 latest false @@ -11,9 +11,9 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + diff --git a/src/QAToolKit.Core/QAToolKit.Core.csproj b/src/QAToolKit.Core/QAToolKit.Core.csproj index 9f2d65c..461af58 100644 --- a/src/QAToolKit.Core/QAToolKit.Core.csproj +++ b/src/QAToolKit.Core/QAToolKit.Core.csproj @@ -1,7 +1,7 @@  - netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0 + netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0 true latest 5a2191e1-6682-437f-8ed2-de9324bfc4f4 @@ -19,7 +19,7 @@ https://github.com/qatoolkit/qatoolkit-core-net qatoolkit-64x64.png https://github.com/qatoolkit/qatoolkit-core-net - qatoolkit-core-net;.net;c#;f#;dotnet;netstandard;net5 + qatoolkit-core-net;.net;c#;f#;dotnet;netstandard;net6 Debug;Release From 7d6fcc63c620bb349f30074bc8d306dc63651a99 Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Sat, 14 Jan 2023 08:28:54 +0100 Subject: [PATCH 15/17] Upgrade to NET 7 (#67) * Upgrade to .net 7 * pipelines upgrade * sonarqube tool update --- .github/workflows/codeql-analysis.yml | 8 ++------ .github/workflows/dotnet-core.yml | 16 ++++------------ .github/workflows/sonarqube-analysis.yml | 10 +++------- Directory.Build.props | 2 +- README.md | 4 ++-- .../QAToolKit.Core.Test.csproj | 16 ++++++++-------- src/QAToolKit.Core/QAToolKit.Core.csproj | 4 ++-- 7 files changed, 22 insertions(+), 38 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index de65587..4494688 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -18,14 +18,10 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v2 - - name: Setup .NET Core 3.1 + - name: Setup .NET Core 7.0 uses: actions/setup-dotnet@v1 with: - dotnet-version: '3.1.x' - - name: Setup .NET Core 6.0 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '6.0.x' + dotnet-version: '7.0.x' - name: Initialize CodeQL uses: github/codeql-action/init@v1 with: diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index c2942ae..5856b41 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -15,14 +15,10 @@ jobs: os: [ ubuntu-latest, windows-latest, macos-latest ] steps: - uses: actions/checkout@v2 - - name: Setup .NET Core 3.1 + - name: Setup .NET Core 7.0 uses: actions/setup-dotnet@v1 with: - dotnet-version: '3.1.x' - - name: Setup .NET Core 6.0 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '6.0.x' + dotnet-version: '7.0.x' - name: Install dependencies run: dotnet restore - name: Build @@ -43,14 +39,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Setup .NET Core 3.1 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '3.1.x' - - name: Setup .NET Core 6.0 + - name: Setup .NET Core 7.0 uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.x' + dotnet-version: '7.0.x' - name: Pack NuGet uses: brandedoutcast/publish-nuget@v2.5.5 with: diff --git a/.github/workflows/sonarqube-analysis.yml b/.github/workflows/sonarqube-analysis.yml index 89189e5..8dda5a3 100644 --- a/.github/workflows/sonarqube-analysis.yml +++ b/.github/workflows/sonarqube-analysis.yml @@ -12,16 +12,12 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Setup .NET Core 3.1 + - name: Setup .NET Core 7.0 uses: actions/setup-dotnet@v1 with: - dotnet-version: '3.1.x' - - name: Setup .NET Core 6.0 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '6.0.x' + dotnet-version: '7.0.x' - name: SonarScanner for .NET Core with pull request decoration support - uses: highbyte/sonarscan-dotnet@v2.1.2 + uses: highbyte/sonarscan-dotnet@v2.2.1 with: sonarProjectKey: qatoolkit_qatoolkit-core-net sonarProjectName: qatoolkit_qatoolkit-core-net diff --git a/Directory.Build.props b/Directory.Build.props index e172c42..8fd71e3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 0.3.13 + 0.3.14 \ No newline at end of file diff --git a/README.md b/README.md index 2b0482e..0e18808 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Description `QAToolKit.Core` is a .NET Standard 2.1 library, that contains core objects and functions of the toolkit. It's normally not used as a standalone library but is a dependency for other QAToolKit libraries. -Supported .NET frameworks and standards: `netstandard2.0`, `netstandard2.1`, `netcoreapp3.1`, `net6.0` +Supported .NET frameworks and standards: `netstandard2.0`, `netstandard2.1`, `net7.0` Get in touch with me on: @@ -77,7 +77,7 @@ To-do MIT License -Copyright (c) 2020-2021 Miha Jakovac +Copyright (c) 2020-2023 Miha Jakovac Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj b/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj index 518a5dd..c427d5e 100644 --- a/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj +++ b/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj @@ -1,26 +1,26 @@  - net6.0 + net7.0 latest false - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/QAToolKit.Core/QAToolKit.Core.csproj b/src/QAToolKit.Core/QAToolKit.Core.csproj index 461af58..f2cb5b1 100644 --- a/src/QAToolKit.Core/QAToolKit.Core.csproj +++ b/src/QAToolKit.Core/QAToolKit.Core.csproj @@ -1,7 +1,7 @@  - netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0 + netstandard2.0;netstandard2.1;net7.0 true latest 5a2191e1-6682-437f-8ed2-de9324bfc4f4 @@ -35,6 +35,6 @@ - + From ba0a314cf9cf51df9f6a9b9a1744ff863100a5cb Mon Sep 17 00:00:00 2001 From: mihaj Date: Sat, 14 Jan 2023 08:38:43 +0100 Subject: [PATCH 16/17] csproj update --- .../QAToolKit.Core.Test.csproj | 30 ++----------------- src/QAToolKit.Core/QAToolKit.Core.csproj | 8 +---- 2 files changed, 4 insertions(+), 34 deletions(-) diff --git a/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj b/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj index c38399b..87627be 100644 --- a/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj +++ b/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj @@ -1,43 +1,19 @@  -<<<<<<< HEAD net7.0 -======= - net6.0 ->>>>>>> main latest false - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - -<<<<<<< HEAD - - - -======= - - - ->>>>>>> main - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - net7.0 - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/QAToolKit.Core/QAToolKit.Core.csproj b/src/QAToolKit.Core/QAToolKit.Core.csproj index e067565..0dd2b75 100644 --- a/src/QAToolKit.Core/QAToolKit.Core.csproj +++ b/src/QAToolKit.Core/QAToolKit.Core.csproj @@ -1,11 +1,7 @@  -<<<<<<< HEAD netstandard2.0;netstandard2.1;net7.0 -======= - netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0 ->>>>>>> main true latest 5a2191e1-6682-437f-8ed2-de9324bfc4f4 @@ -23,7 +19,7 @@ https://github.com/qatoolkit/qatoolkit-core-net qatoolkit-64x64.png https://github.com/qatoolkit/qatoolkit-core-net - qatoolkit-core-net;.net;c#;f#;dotnet;netstandard;net6 + qatoolkit-core-net;.net;c#;f#;dotnet;netstandard;net7 Debug;Release @@ -40,8 +36,6 @@ - netstandard2.0;netstandard2.1;net7.0 - qatoolkit-core-net;.net;c#;f#;dotnet;netstandard;net6 From 694911c39253452b9d657651261e57c85f6b170f Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Thu, 7 Mar 2024 08:20:54 +0100 Subject: [PATCH 17/17] net8 update * Upgrade to .NET 7 * .NET 8 update * version bump * artifact name in the action updated * removed manual sonarqube scan --- .github/workflows/codeql-analysis.yml | 14 ++++----- .github/workflows/dotnet-core.yml | 20 ++++++------ .github/workflows/sonarqube-analysis.yml | 31 ------------------- Directory.Build.props | 2 +- README.md | 14 +++------ .../QAToolKit.Core.Test.csproj | 25 ++++++++++----- src/QAToolKit.Core/QAToolKit.Core.csproj | 7 ++--- 7 files changed, 43 insertions(+), 70 deletions(-) delete mode 100644 .github/workflows/sonarqube-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4494688..92c9234 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -17,16 +17,16 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 - - name: Setup .NET Core 7.0 - uses: actions/setup-dotnet@v1 + uses: actions/checkout@v4.1.1 + - name: Setup .NET Core 8.0 + uses: actions/setup-dotnet@v4 with: - dotnet-version: '7.0.x' + dotnet-version: '8.0.x' - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2.16.3 with: languages: ${{ matrix.language }} - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v2.16.3 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 \ No newline at end of file + uses: github/codeql-action/analyze@v2.16.3 \ No newline at end of file diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index 5856b41..2ffe0aa 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -14,11 +14,11 @@ jobs: matrix: os: [ ubuntu-latest, windows-latest, macos-latest ] steps: - - uses: actions/checkout@v2 - - name: Setup .NET Core 7.0 - uses: actions/setup-dotnet@v1 + - uses: actions/checkout@v4.1.1 + - name: Setup .NET Core 8.0 + uses: actions/setup-dotnet@v4 with: - dotnet-version: '7.0.x' + dotnet-version: '8.0.x' - name: Install dependencies run: dotnet restore - name: Build @@ -26,10 +26,10 @@ jobs: - name: Test run: dotnet test --no-restore --verbosity normal - name: Upload a Build Artifact - uses: actions/upload-artifact@v2.2.0 + uses: actions/upload-artifact@v4.3.1 with: # Artifact name - name: qatoolkit-core-net.zip + name: qatoolkit-core-net-${{ matrix.os }}.zip # A file, directory or wildcard pattern that describes what to upload path: src/QAToolKit.Core/bin/ deploy: @@ -38,11 +38,11 @@ jobs: if: github.event_name == 'release' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup .NET Core 7.0 - uses: actions/setup-dotnet@v1 + - uses: actions/checkout@v4.1.1 + - name: Setup .NET Core 8.0 + uses: actions/setup-dotnet@v4 with: - dotnet-version: '7.0.x' + dotnet-version: '8.0.x' - name: Pack NuGet uses: brandedoutcast/publish-nuget@v2.5.5 with: diff --git a/.github/workflows/sonarqube-analysis.yml b/.github/workflows/sonarqube-analysis.yml deleted file mode 100644 index 8dda5a3..0000000 --- a/.github/workflows/sonarqube-analysis.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Sonarqube Analyze -on: - push: - branches: - - main - pull_request: - types: [opened, synchronize, reopened] -jobs: - sonarcloud: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Setup .NET Core 7.0 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '7.0.x' - - name: SonarScanner for .NET Core with pull request decoration support - uses: highbyte/sonarscan-dotnet@v2.2.1 - with: - sonarProjectKey: qatoolkit_qatoolkit-core-net - sonarProjectName: qatoolkit_qatoolkit-core-net - sonarOrganization: qatoolkit - dotnetBuildArguments: ./src/QAToolKit.Core/QAToolKit.Core.csproj - dotnetTestArguments: ./src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=opencover - sonarBeginArguments: /d:sonar.verbose="true" /d:sonar.language="cs" /d:sonar.cs.opencover.reportsPaths="**/*.opencover.xml" - sonarHostname: "https://sonarcloud.io" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index 8fd71e3..9496389 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 0.3.14 + 0.3.15 \ No newline at end of file diff --git a/README.md b/README.md index f263bf2..d52823f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # QAToolKit Core library -[![Build .NET Library](https://github.com/qatoolkit/qatoolkit-core-net/workflows/.NET%20Core/badge.svg?branch=main)](https://github.com/qatoolkit/qatoolkit-core-net/actions) +[![Build .NET Library](https://github.com/qatoolkit/qatoolkit-core-net/actions/workflows/dotnet-core.yml/badge.svg)](https://github.com/qatoolkit/qatoolkit-core-net/actions/workflows/dotnet-core.yml) [![CodeQL](https://github.com/qatoolkit/qatoolkit-core-net/workflows/CodeQL%20Analyze/badge.svg)](https://github.com/qatoolkit/qatoolkit-core-net/security/code-scanning) [![Sonarcloud Quality gate](https://github.com/qatoolkit/qatoolkit-core-net/workflows/Sonarqube%20Analyze/badge.svg)](https://sonarcloud.io/dashboard?id=qatoolkit_qatoolkit-core-net) [![NuGet package](https://img.shields.io/nuget/v/QAToolKit.Core?label=QAToolKit.Core)](https://www.nuget.org/packages/QAToolKit.Core/) @@ -8,11 +8,7 @@ ## Description `QAToolKit.Core` is a .NET Standard 2.1 library, that contains core objects and functions of the toolkit. It's normally not used as a standalone library but is a dependency for other QAToolKit libraries. -<<<<<<< HEAD -Supported .NET frameworks and standards: `netstandard2.0`, `netstandard2.1`, `net7.0` -======= -Supported .NET frameworks and standards: `netstandard2.0`, `netstandard2.1`, `netcoreapp3.1`, `net6.0` ->>>>>>> main +Supported .NET frameworks and standards: `netstandard2.0`, `netstandard2.1`, `netcoreapp3.1`, `net8.0` Get in touch with me on: @@ -81,9 +77,9 @@ To-do MIT License -Copyright (c) 2020-2023 Miha Jakovac -Supported .NET frameworks and standards: `netstandard2.0`, `netstandard2.1`, `net7.0` -Copyright (c) 2020-2023 Miha Jakovac +Copyright (c) 2020-2024 Miha Jakovac +Supported .NET frameworks and standards: `netstandard2.0`, `netstandard2.1`, `net8.0` +Copyright (c) 2020-2024 Miha Jakovac Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj b/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj index 87627be..6cf84f0 100644 --- a/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj +++ b/src/QAToolKit.Core.Test/QAToolKit.Core.Test.csproj @@ -1,19 +1,28 @@  - net7.0 + net8.0 latest false - - - - - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/QAToolKit.Core/QAToolKit.Core.csproj b/src/QAToolKit.Core/QAToolKit.Core.csproj index 0dd2b75..fc83bd4 100644 --- a/src/QAToolKit.Core/QAToolKit.Core.csproj +++ b/src/QAToolKit.Core/QAToolKit.Core.csproj @@ -1,7 +1,7 @@  - netstandard2.0;netstandard2.1;net7.0 + netstandard2.0;netstandard2.1;net8.0 true latest 5a2191e1-6682-437f-8ed2-de9324bfc4f4 @@ -19,7 +19,7 @@ https://github.com/qatoolkit/qatoolkit-core-net qatoolkit-64x64.png https://github.com/qatoolkit/qatoolkit-core-net - qatoolkit-core-net;.net;c#;f#;dotnet;netstandard;net7 + qatoolkit-core-net;.net;c#;f#;dotnet;netstandard;net8 Debug;Release @@ -35,7 +35,6 @@ - - +