Skip to content

Commit

Permalink
#255 Add invalid request scenarios to space tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamZ-Kontent committed Jan 18, 2024
1 parent 2aa20d0 commit 1afb8a7
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions Kontent.Ai.Management.Tests/ManagementClientTests/SpaceTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using FluentAssertions;
using Kontent.Ai.Management.Models.Shared;
using Kontent.Ai.Management.Models.Spaces;
using Kontent.Ai.Management.Models.Spaces.Patch;
Expand Down Expand Up @@ -35,6 +36,14 @@ public async void CreateSpace_CreatesSpace()
.Validate();
}

[Fact]
public async void CreateSpace_ModelIsNull_Throws()
{
var client = _scenario.CreateManagementClient();

await client.Invoking(x => x.CreateSpaceAsync(null)).Should().ThrowAsync<ArgumentNullException>();
}

[Fact]
public async void ListSpaces_ListsSpaces()
{
Expand Down Expand Up @@ -79,6 +88,14 @@ public async void GetSpace_ByCodename_GetsSpace()
.Validate();
}

[Fact]
public async void GetSpace_IdentifierIsNull_Throws()
{
var client = _scenario.CreateManagementClient();

await client.Invoking(x => x.GetSpaceAsync(null)).Should().ThrowAsync<ArgumentNullException>();
}

[Fact]
public async void ModifySpace_Replace_ModifiesSpace()
{
Expand All @@ -101,6 +118,27 @@ public async void ModifySpace_Replace_ModifiesSpace()
.Validate();
}

[Fact]
public async void ModifySpace_IdentifierIsNull_Throws()
{
var client = _scenario.CreateManagementClient();
var changes = new SpaceOperationReplaceModel[]
{
new() { PropertyName = PropertyName.Name, Value = "New space name" }
};

await client.Invoking(x => x.ModifySpaceAsync(null, changes)).Should().ThrowAsync<ArgumentNullException>();
}

[Fact]
public async void ModifySpace_ChangesAreNull_Throws()
{
var client = _scenario.CreateManagementClient();
var identifier = Reference.ById(Guid.NewGuid());

await client.Invoking(x => x.ModifySpaceAsync(identifier, null)).Should().ThrowAsync<ArgumentNullException>();
}

[Fact]
public async void DeleteSpace_ById_DeletesSpace()
{
Expand Down Expand Up @@ -129,5 +167,13 @@ public async void DeleteSpace_ByCodename_DeletesSpace()
.HttpMethod(HttpMethod.Delete)
.Validate();
}

[Fact]
public async void DeleteSpace_IdentifierIsNull_Throws()
{
var client = _scenario.CreateManagementClient();

await client.Invoking(x => x.DeleteSpaceAsync(null)).Should().ThrowAsync<ArgumentNullException>();
}
}

0 comments on commit 1afb8a7

Please sign in to comment.