Reorganize, shared entities from TypeScript SDK
https://github.com/cloudflare/cloudflare-typescript/blob/v4.4.1/src/resources/shared.ts
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using AMWD.Net.Api.Cloudflare.Auth;
|
||||
using AMWD.Net.Api.Cloudflare;
|
||||
|
||||
namespace Cloudflare.Core.Tests.Auth
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using AMWD.Net.Api.Cloudflare.Auth;
|
||||
using System.Net.Http;
|
||||
using AMWD.Net.Api.Cloudflare;
|
||||
|
||||
namespace Cloudflare.Core.Tests.Auth
|
||||
{
|
||||
|
||||
@@ -6,17 +6,18 @@
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<CollectCoverage>true</CollectCoverage>
|
||||
<CoverletOutputFormat>Cobertura</CoverletOutputFormat>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
|
||||
<PackageReference Include="coverlet.msbuild" Version="6.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||
<PackageReference Include="Moq" Version="4.20.72" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.9.1" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.9.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using AMWD.Net.Api.Cloudflare;
|
||||
using AMWD.Net.Api.Cloudflare.Auth;
|
||||
using Moq;
|
||||
using Moq.Protected;
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -11,7 +9,6 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AMWD.Net.Api.Cloudflare;
|
||||
using AMWD.Net.Api.Cloudflare.Auth;
|
||||
using Moq;
|
||||
using Moq.Protected;
|
||||
|
||||
@@ -110,7 +107,6 @@ namespace Cloudflare.Core.Tests.CloudflareClientTests
|
||||
Assert.IsNotNull(response.Errors);
|
||||
Assert.IsNotNull(response.Messages);
|
||||
Assert.IsNull(response.ResultInfo);
|
||||
Assert.IsNull(response.Timing);
|
||||
|
||||
Assert.AreEqual(0, response.Errors.Count);
|
||||
Assert.AreEqual(0, response.Messages.Count);
|
||||
@@ -191,7 +187,6 @@ namespace Cloudflare.Core.Tests.CloudflareClientTests
|
||||
Assert.IsNotNull(response.Errors);
|
||||
Assert.IsNotNull(response.Messages);
|
||||
Assert.IsNull(response.ResultInfo);
|
||||
Assert.IsNull(response.Timing);
|
||||
|
||||
Assert.AreEqual(0, response.Errors.Count);
|
||||
Assert.AreEqual(0, response.Messages.Count);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -11,7 +9,6 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AMWD.Net.Api.Cloudflare;
|
||||
using AMWD.Net.Api.Cloudflare.Auth;
|
||||
using Moq;
|
||||
using Moq.Protected;
|
||||
|
||||
@@ -110,7 +107,6 @@ namespace Cloudflare.Core.Tests.CloudflareClientTests
|
||||
Assert.IsNotNull(response.Errors);
|
||||
Assert.IsNotNull(response.Messages);
|
||||
Assert.IsNull(response.ResultInfo);
|
||||
Assert.IsNull(response.Timing);
|
||||
|
||||
Assert.AreEqual(0, response.Errors.Count);
|
||||
Assert.AreEqual(0, response.Messages.Count);
|
||||
@@ -212,7 +208,6 @@ namespace Cloudflare.Core.Tests.CloudflareClientTests
|
||||
Assert.IsNotNull(response.Errors);
|
||||
Assert.IsNotNull(response.Messages);
|
||||
Assert.IsNull(response.ResultInfo);
|
||||
Assert.IsNull(response.Timing);
|
||||
|
||||
Assert.AreEqual(0, response.Errors.Count);
|
||||
Assert.AreEqual(0, response.Messages.Count);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -11,7 +9,6 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AMWD.Net.Api.Cloudflare;
|
||||
using AMWD.Net.Api.Cloudflare.Auth;
|
||||
using Moq;
|
||||
using Moq.Protected;
|
||||
|
||||
@@ -118,7 +115,6 @@ namespace Cloudflare.Core.Tests.CloudflareClientTests
|
||||
Assert.IsNotNull(response.Errors);
|
||||
Assert.IsNotNull(response.Messages);
|
||||
Assert.IsNull(response.ResultInfo);
|
||||
Assert.IsNull(response.Timing);
|
||||
|
||||
Assert.AreEqual(0, response.Errors.Count);
|
||||
Assert.AreEqual(0, response.Messages.Count);
|
||||
@@ -171,7 +167,6 @@ namespace Cloudflare.Core.Tests.CloudflareClientTests
|
||||
Assert.IsNotNull(response.Errors);
|
||||
Assert.IsNotNull(response.Messages);
|
||||
Assert.IsNull(response.ResultInfo);
|
||||
Assert.IsNull(response.Timing);
|
||||
|
||||
Assert.AreEqual(0, response.Errors.Count);
|
||||
Assert.AreEqual(0, response.Messages.Count);
|
||||
@@ -252,7 +247,6 @@ namespace Cloudflare.Core.Tests.CloudflareClientTests
|
||||
Assert.IsNotNull(response.Errors);
|
||||
Assert.IsNotNull(response.Messages);
|
||||
Assert.IsNull(response.ResultInfo);
|
||||
Assert.IsNull(response.Timing);
|
||||
|
||||
Assert.AreEqual(0, response.Errors.Count);
|
||||
Assert.AreEqual(0, response.Messages.Count);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -11,7 +9,6 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AMWD.Net.Api.Cloudflare;
|
||||
using AMWD.Net.Api.Cloudflare.Auth;
|
||||
using Moq;
|
||||
using Moq.Protected;
|
||||
|
||||
@@ -104,7 +101,7 @@ namespace Cloudflare.Core.Tests.CloudflareClientTests
|
||||
_httpHandlerMock.Responses.Enqueue(new HttpResponseMessage
|
||||
{
|
||||
StatusCode = HttpStatusCode.OK,
|
||||
Content = new StringContent(@"{""success"": true, ""errors"": [], ""messages"": [], ""result"": { ""string"": ""some-string"", ""integer"": 123 }, ""timing"": {""end_time"": ""2014-03-01T12:20:01Z"", ""process_time"": 1, ""start_time"": ""2014-03-01T12:20:00Z""}}", Encoding.UTF8, MediaTypeNames.Application.Json),
|
||||
Content = new StringContent(@"{""success"": true, ""errors"": [], ""messages"": [], ""result"": { ""string"": ""some-string"", ""integer"": 123 }}", Encoding.UTF8, MediaTypeNames.Application.Json),
|
||||
});
|
||||
|
||||
var client = GetClient();
|
||||
@@ -126,11 +123,6 @@ namespace Cloudflare.Core.Tests.CloudflareClientTests
|
||||
Assert.AreEqual("some-string", response.Result.Str);
|
||||
Assert.AreEqual(123, response.Result.Int);
|
||||
|
||||
Assert.IsNotNull(response.Timing);
|
||||
Assert.AreEqual("01.03.2014 12:20:00", response.Timing.StartTime?.ToString("dd.MM.yyyy HH:mm:ss"));
|
||||
Assert.AreEqual("01.03.2014 12:20:01", response.Timing.EndTime?.ToString("dd.MM.yyyy HH:mm:ss"));
|
||||
Assert.AreEqual(1, response.Timing.ProcessTime);
|
||||
|
||||
Assert.AreEqual(1, _httpHandlerMock.Callbacks.Count);
|
||||
|
||||
var callback = _httpHandlerMock.Callbacks.First();
|
||||
@@ -175,7 +167,6 @@ namespace Cloudflare.Core.Tests.CloudflareClientTests
|
||||
Assert.IsNotNull(response.Errors);
|
||||
Assert.IsNotNull(response.Messages);
|
||||
Assert.IsNull(response.ResultInfo);
|
||||
Assert.IsNull(response.Timing);
|
||||
|
||||
Assert.AreEqual(0, response.Errors.Count);
|
||||
Assert.AreEqual(0, response.Messages.Count);
|
||||
@@ -227,7 +218,6 @@ namespace Cloudflare.Core.Tests.CloudflareClientTests
|
||||
Assert.IsNotNull(response.Errors);
|
||||
Assert.IsNotNull(response.Messages);
|
||||
Assert.IsNull(response.ResultInfo);
|
||||
Assert.IsNull(response.Timing);
|
||||
|
||||
Assert.AreEqual(0, response.Errors.Count);
|
||||
Assert.AreEqual(0, response.Messages.Count);
|
||||
@@ -305,7 +295,6 @@ namespace Cloudflare.Core.Tests.CloudflareClientTests
|
||||
Assert.IsNotNull(response.Errors);
|
||||
Assert.IsNotNull(response.Messages);
|
||||
Assert.IsNull(response.ResultInfo);
|
||||
Assert.IsNull(response.Timing);
|
||||
|
||||
Assert.AreEqual(0, response.Errors.Count);
|
||||
Assert.AreEqual(0, response.Messages.Count);
|
||||
@@ -383,7 +372,6 @@ namespace Cloudflare.Core.Tests.CloudflareClientTests
|
||||
Assert.IsNotNull(response.Errors);
|
||||
Assert.IsNotNull(response.Messages);
|
||||
Assert.IsNull(response.ResultInfo);
|
||||
Assert.IsNull(response.Timing);
|
||||
|
||||
Assert.AreEqual(0, response.Errors.Count);
|
||||
Assert.AreEqual(0, response.Messages.Count);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -11,7 +9,6 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AMWD.Net.Api.Cloudflare;
|
||||
using AMWD.Net.Api.Cloudflare.Auth;
|
||||
using Moq;
|
||||
using Moq.Protected;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Cloudflare.Tests.Extensions
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void ShouldThrowArgumentOutOfRangeExceptionForValidateId()
|
||||
{
|
||||
// Arrange
|
||||
@@ -43,7 +43,7 @@ namespace Cloudflare.Tests.Extensions
|
||||
// Act
|
||||
id.ValidateCloudflareId();
|
||||
|
||||
// Assert - ArgumentOutOfRangeException
|
||||
// Assert - ArgumentException
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
@@ -54,7 +54,7 @@ namespace Cloudflare.Tests.Extensions
|
||||
public void ShouldThrowArgumentExceptionForValidateId(string id)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
|
||||
// Act
|
||||
id.ValidateCloudflareId();
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Cloudflare.Tests.Extensions
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void ShouldThrowArgumentOutOfRangeExceptionForValidateName()
|
||||
{
|
||||
// Arrange
|
||||
@@ -98,7 +98,7 @@ namespace Cloudflare.Tests.Extensions
|
||||
// Act
|
||||
name.ValidateCloudflareName();
|
||||
|
||||
// Assert - ArgumentOutOfRangeException
|
||||
// Assert - ArgumentException
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -142,5 +142,31 @@ namespace Cloudflare.Tests.Extensions
|
||||
|
||||
// Assert - ArgumentException
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[DataRow(null)]
|
||||
[DataRow("SomeExampleString")]
|
||||
public void ShouldValidateLength(string str)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
// Act
|
||||
str.ValidateLength(30, nameof(str));
|
||||
|
||||
// Assert - no exception thrown
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void ShouldThrowArgumentExceptionForValidateLength()
|
||||
{
|
||||
// Arrange
|
||||
string str = "SomeExampleString";
|
||||
|
||||
// Act
|
||||
str.ValidateLength(10, nameof(str));
|
||||
|
||||
// Assert - ArgumentException
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user