Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions Contentstack.Core.Tests/Contentstack.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.18" />
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.18" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-reportgenerator-cli" Version="4.2.10" />
<PackageReference Include="AutoFixture" Version="4.18.1" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.18.1" />
<DotNetCliToolReference Include="dotnet-reportgenerator-cli" Version="4.2.20" />
<PackageReference Include="Moq" Version="4.20.72" />
</ItemGroup>

Expand Down
8 changes: 3 additions & 5 deletions Contentstack.Core.Tests/Mocks/EntryTestHelper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using AutoFixture;
using Contentstack.Core;
using Contentstack.Core.Configuration;
using Contentstack.Core.Models;
Expand Down Expand Up @@ -58,12 +57,11 @@ public static Entry CreateEntry(ContentstackClient client, string contentTypeId
/// </summary>
public static ContentstackClient CreateMockClient(string mockResponse = null)
{
var fixture = new Fixture();
var options = new ContentstackOptions()
{
ApiKey = fixture.Create<string>(),
DeliveryToken = fixture.Create<string>(),
Environment = fixture.Create<string>()
ApiKey = Guid.NewGuid().ToString("N"),
DeliveryToken = Guid.NewGuid().ToString("N"),
Environment = Guid.NewGuid().ToString("N")
};

var client = new ContentstackClient(new OptionsWrapper<ContentstackOptions>(options));
Expand Down
24 changes: 11 additions & 13 deletions Contentstack.Core.Unit.Tests/AssetLibraryUnitTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using AutoFixture;
using Contentstack.Core;
using Contentstack.Core.Configuration;
using Contentstack.Core.Internals;
Expand All @@ -17,7 +16,6 @@ namespace Contentstack.Core.Unit.Tests
/// </summary>
public class AssetLibraryUnitTests
{
private readonly IFixture _fixture = new Fixture();
private ContentstackClient _client;

public AssetLibraryUnitTests()
Expand All @@ -29,9 +27,9 @@ private void Initialize()
{
var options = new ContentstackOptions()
{
ApiKey = _fixture.Create<string>(),
DeliveryToken = _fixture.Create<string>(),
Environment = _fixture.Create<string>()
ApiKey = Guid.NewGuid().ToString("N"),
DeliveryToken = Guid.NewGuid().ToString("N"),
Environment = Guid.NewGuid().ToString("N")
};
_client = new ContentstackClient(new OptionsWrapper<ContentstackOptions>(options));
}
Expand All @@ -48,8 +46,8 @@ public void Where_AddsQueryParameter()
{
// Arrange
var assetLibrary = CreateAssetLibrary();
var key = _fixture.Create<string>();
var value = _fixture.Create<string>();
var key = Guid.NewGuid().ToString("N");
var value = Guid.NewGuid().ToString("N");

// Act
AssetLibrary result = assetLibrary.Where(key, value);
Expand All @@ -73,7 +71,7 @@ public void Where_WithNullKey_DoesNotAddParameter()
{
// Arrange
var assetLibrary = CreateAssetLibrary();
var value = _fixture.Create<string>();
var value = Guid.NewGuid().ToString("N");

// Act
AssetLibrary result = assetLibrary.Where(null, value);
Expand All @@ -88,7 +86,7 @@ public void Where_WithEmptyKey_DoesNotAddParameter()
{
// Arrange
var assetLibrary = CreateAssetLibrary();
var value = _fixture.Create<string>();
var value = Guid.NewGuid().ToString("N");

// Act
AssetLibrary result = assetLibrary.Where("", value);
Expand Down Expand Up @@ -379,8 +377,8 @@ public void AddParam_AddsQueryParameter()
{
// Arrange
var assetLibrary = CreateAssetLibrary();
var key = _fixture.Create<string>();
var value = _fixture.Create<string>();
var key = Guid.NewGuid().ToString("N");
var value = Guid.NewGuid().ToString("N");

// Act
AssetLibrary result = assetLibrary.AddParam(key, value);
Expand Down Expand Up @@ -529,7 +527,7 @@ public void SetHeaderForKey_AddsHeader()
// Arrange
var assetLibrary = CreateAssetLibrary();
var key = "custom_header";
var value = _fixture.Create<string>();
var value = Guid.NewGuid().ToString("N");

// Act
AssetLibrary result = assetLibrary.SetHeaderForKey(key, value);
Expand All @@ -552,7 +550,7 @@ public void RemoveHeader_RemovesHeader()
// Arrange
var assetLibrary = CreateAssetLibrary();
var key = "custom_header";
var value = _fixture.Create<string>();
var value = Guid.NewGuid().ToString("N");
assetLibrary.SetHeaderForKey(key, value);

var headersField = typeof(AssetLibrary).GetField("_Headers",
Expand Down
18 changes: 8 additions & 10 deletions Contentstack.Core.Unit.Tests/AssetUnitTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using AutoFixture;
using Contentstack.Core;
using Contentstack.Core.Configuration;
using Contentstack.Core.Internals;
Expand All @@ -16,7 +15,6 @@ namespace Contentstack.Core.Unit.Tests
/// </summary>
public class AssetUnitTests
{
private readonly IFixture _fixture = new Fixture();
private ContentstackClient _client;

public AssetUnitTests()
Expand All @@ -28,9 +26,9 @@ private void Initialize()
{
var options = new ContentstackOptions()
{
ApiKey = _fixture.Create<string>(),
DeliveryToken = _fixture.Create<string>(),
Environment = _fixture.Create<string>()
ApiKey = Guid.NewGuid().ToString("N"),
DeliveryToken = Guid.NewGuid().ToString("N"),
Environment = Guid.NewGuid().ToString("N")
};
_client = new ContentstackClient(new OptionsWrapper<ContentstackOptions>(options));
}
Expand Down Expand Up @@ -99,7 +97,7 @@ public void GetDeleteAt_WithoutDeletedAt_ReturnsMinValue()
public void GetDeletedBy_WithDeletedBy_ReturnsUid()
{
// Arrange
var deletedBy = _fixture.Create<string>();
var deletedBy = Guid.NewGuid().ToString("N");
var attributes = new Dictionary<string, object>
{
{ "uid", "test_asset_uid" },
Expand Down Expand Up @@ -513,8 +511,8 @@ public void AddParam_AddsQueryParameter()
{
// Arrange
var asset = CreateAsset();
var key = _fixture.Create<string>();
var value = _fixture.Create<string>();
var key = Guid.NewGuid().ToString("N");
var value = Guid.NewGuid().ToString("N");

// Act
Asset result = asset.AddParam(key, value);
Expand Down Expand Up @@ -603,7 +601,7 @@ public void SetHeader_AddsHeader()
// Arrange
var asset = CreateAsset();
var key = "custom_header";
var value = _fixture.Create<string>();
var value = Guid.NewGuid().ToString("N");

// Act
asset.SetHeader(key, value);
Expand All @@ -623,7 +621,7 @@ public void RemoveHeader_RemovesHeader()
// Arrange
var asset = CreateAsset();
var key = "custom_header";
var value = _fixture.Create<string>();
var value = Guid.NewGuid().ToString("N");
asset.SetHeader(key, value);

var headersField = typeof(Asset).GetField("_Headers",
Expand Down
4 changes: 1 addition & 3 deletions Contentstack.Core.Unit.Tests/ConfigUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Linq;
using System.Net;
using System.Reflection;
using AutoFixture;
using Contentstack.Core.Configuration;
using Contentstack.Core.Internals;
using Xunit;
Expand All @@ -11,7 +10,6 @@ namespace Contentstack.Core.Unit.Tests
{
public class ConfigUnitTests
{
private readonly IFixture _fixture = new Fixture();

private Config CreateConfig()
{
Expand Down Expand Up @@ -149,7 +147,7 @@ public void Environment_Set_UpdatesValue()
{
// Arrange
var config = CreateConfig();
var environment = _fixture.Create<string>();
var environment = Guid.NewGuid().ToString("N");

// Act
config.Environment = environment;
Expand Down
20 changes: 9 additions & 11 deletions Contentstack.Core.Unit.Tests/ContentTypeUnitTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using AutoFixture;
using Contentstack.Core;
using Contentstack.Core.Configuration;
using Contentstack.Core.Internals;
Expand All @@ -16,7 +15,6 @@ namespace Contentstack.Core.Unit.Tests
/// </summary>
public class ContentTypeUnitTests
{
private readonly IFixture _fixture = new Fixture();
private ContentstackClient _client;

public ContentTypeUnitTests()
Expand All @@ -28,9 +26,9 @@ private void Initialize()
{
var options = new ContentstackOptions()
{
ApiKey = _fixture.Create<string>(),
DeliveryToken = _fixture.Create<string>(),
Environment = _fixture.Create<string>()
ApiKey = Guid.NewGuid().ToString("N"),
DeliveryToken = Guid.NewGuid().ToString("N"),
Environment = Guid.NewGuid().ToString("N")
};
_client = new ContentstackClient(new OptionsWrapper<ContentstackOptions>(options));
}
Expand All @@ -46,7 +44,7 @@ private ContentType CreateContentType(string contentTypeId = "source")
public void ContentTypeId_Get_ReturnsContentTypeId()
{
// Arrange
var contentTypeId = _fixture.Create<string>();
var contentTypeId = Guid.NewGuid().ToString("N");
var contentType = CreateContentType(contentTypeId);

// Act
Expand All @@ -61,7 +59,7 @@ public void ContentTypeId_Set_UpdatesContentTypeId()
{
// Arrange
var contentType = CreateContentType();
var newContentTypeId = _fixture.Create<string>();
var newContentTypeId = Guid.NewGuid().ToString("N");

// Act
contentType.ContentTypeId = newContentTypeId;
Expand All @@ -79,7 +77,7 @@ public void Entry_WithValidUid_ReturnsEntry()
{
// Arrange
var contentType = CreateContentType();
var entryUid = _fixture.Create<string>();
var entryUid = Guid.NewGuid().ToString("N");

// Act
var entry = contentType.Entry(entryUid);
Expand Down Expand Up @@ -161,7 +159,7 @@ public void SetHeader_AddsHeader()
// Arrange
var contentType = CreateContentType();
var key = "custom_header";
var value = _fixture.Create<string>();
var value = Guid.NewGuid().ToString("N");

// Act
contentType.SetHeader(key, value);
Expand All @@ -180,7 +178,7 @@ public void SetHeader_WithNullKey_DoesNotAddHeader()
{
// Arrange
var contentType = CreateContentType();
var value = _fixture.Create<string>();
var value = Guid.NewGuid().ToString("N");
var headersField = typeof(ContentType).GetField("_Headers",
BindingFlags.NonPublic | BindingFlags.Instance);
var headersBefore = new Dictionary<string, object>((Dictionary<string, object>)headersField?.GetValue(contentType));
Expand Down Expand Up @@ -225,7 +223,7 @@ public void RemoveHeader_WithExistingKey_RemovesHeader()
// Arrange
var contentType = CreateContentType();
var key = "test_header";
var value = _fixture.Create<string>();
var value = Guid.NewGuid().ToString("N");

var headersField = typeof(ContentType).GetField("_Headers",
BindingFlags.NonPublic | BindingFlags.Instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="AutoFixture" Version="4.18.1" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.18.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.18" />
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.18" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading