From 1afb8a701457e2951c9a9fe46e701dfe359624d0 Mon Sep 17 00:00:00 2001 From: Adam Zavadil Date: Wed, 17 Jan 2024 13:12:16 +0100 Subject: [PATCH] #255 Add invalid request scenarios to space tests --- .../ManagementClientTests/SpaceTests.cs | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Kontent.Ai.Management.Tests/ManagementClientTests/SpaceTests.cs b/Kontent.Ai.Management.Tests/ManagementClientTests/SpaceTests.cs index 05824511..536961ee 100644 --- a/Kontent.Ai.Management.Tests/ManagementClientTests/SpaceTests.cs +++ b/Kontent.Ai.Management.Tests/ManagementClientTests/SpaceTests.cs @@ -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; @@ -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(); + } + [Fact] public async void ListSpaces_ListsSpaces() { @@ -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(); + } + [Fact] public async void ModifySpace_Replace_ModifiesSpace() { @@ -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(); + } + + [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(); + } + [Fact] public async void DeleteSpace_ById_DeletesSpace() { @@ -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(); + } } \ No newline at end of file