diff --git a/tests/PSProxmoxVE.Core.Tests/Services/BackupServiceTests.cs b/tests/PSProxmoxVE.Core.Tests/Services/BackupServiceTests.cs index 915b0bc..4feafaf 100644 --- a/tests/PSProxmoxVE.Core.Tests/Services/BackupServiceTests.cs +++ b/tests/PSProxmoxVE.Core.Tests/Services/BackupServiceTests.cs @@ -57,15 +57,6 @@ namespace PSProxmoxVE.Core.Tests.Services Times.Once); } - [Fact] - public void CreateBackup_NullSession_ThrowsArgumentNullException() - { - var service = new BackupService(new Mock().Object); - var config = new Dictionary { ["vmid"] = "100" }; - - Assert.Throws("session", () => service.CreateBackup(null!, Node, config)); - } - [Fact] public void CreateBackup_NullConfig_ThrowsArgumentNullException() { @@ -149,14 +140,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Empty(jobs); } - [Fact] - public void GetBackupJobs_NullSession_ThrowsArgumentNullException() - { - var service = new BackupService(new Mock().Object); - - Assert.Throws("session", () => service.GetBackupJobs(null!)); - } - // --------------------------------------------------------------- // GetBackupJob (single) // --------------------------------------------------------------- @@ -192,22 +175,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal("pbs-store", job.Storage); } - [Fact] - public void GetBackupJob_NullSession_ThrowsArgumentNullException() - { - var service = new BackupService(new Mock().Object); - - Assert.Throws("session", () => service.GetBackupJob(null!, "backup-001")); - } - - [Fact] - public void GetBackupJob_NullId_ThrowsArgumentNullException() - { - var service = new BackupService(new Mock().Object); - - Assert.Throws("id", () => service.GetBackupJob(CreateSession(), null!)); - } - // --------------------------------------------------------------- // CreateBackupJob // --------------------------------------------------------------- @@ -244,15 +211,6 @@ namespace PSProxmoxVE.Core.Tests.Services Times.Once); } - [Fact] - public void CreateBackupJob_NullSession_ThrowsArgumentNullException() - { - var service = new BackupService(new Mock().Object); - var config = new Dictionary { ["vmid"] = "100" }; - - Assert.Throws("session", () => service.CreateBackupJob(null!, config)); - } - [Fact] public void CreateBackupJob_NullConfig_ThrowsArgumentNullException() { @@ -292,24 +250,6 @@ namespace PSProxmoxVE.Core.Tests.Services Times.Once); } - [Fact] - public void UpdateBackupJob_NullSession_ThrowsArgumentNullException() - { - var service = new BackupService(new Mock().Object); - var config = new Dictionary { ["enabled"] = "1" }; - - Assert.Throws("session", () => service.UpdateBackupJob(null!, "id", config)); - } - - [Fact] - public void UpdateBackupJob_NullId_ThrowsArgumentNullException() - { - var service = new BackupService(new Mock().Object); - var config = new Dictionary { ["enabled"] = "1" }; - - Assert.Throws("id", () => service.UpdateBackupJob(CreateSession(), null!, config)); - } - [Fact] public void UpdateBackupJob_NullConfig_ThrowsArgumentNullException() { @@ -340,22 +280,6 @@ namespace PSProxmoxVE.Core.Tests.Services mockClient.Verify(c => c.DeleteAsync("cluster/backup/backup-001"), Times.Once); } - [Fact] - public void RemoveBackupJob_NullSession_ThrowsArgumentNullException() - { - var service = new BackupService(new Mock().Object); - - Assert.Throws("session", () => service.RemoveBackupJob(null!, "id")); - } - - [Fact] - public void RemoveBackupJob_NullId_ThrowsArgumentNullException() - { - var service = new BackupService(new Mock().Object); - - Assert.Throws("id", () => service.RemoveBackupJob(CreateSession(), null!)); - } - // --------------------------------------------------------------- // GetNotBackedUp // --------------------------------------------------------------- @@ -404,14 +328,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Empty(result); } - [Fact] - public void GetNotBackedUp_NullSession_ThrowsArgumentNullException() - { - var service = new BackupService(new Mock().Object); - - Assert.Throws("session", () => service.GetNotBackedUp(null!)); - } - // --------------------------------------------------------------- // Constructor // --------------------------------------------------------------- diff --git a/tests/PSProxmoxVE.Core.Tests/Services/CloudInitServiceTests.cs b/tests/PSProxmoxVE.Core.Tests/Services/CloudInitServiceTests.cs index 1d20cac..b578d21 100644 --- a/tests/PSProxmoxVE.Core.Tests/Services/CloudInitServiceTests.cs +++ b/tests/PSProxmoxVE.Core.Tests/Services/CloudInitServiceTests.cs @@ -117,40 +117,6 @@ namespace PSProxmoxVE.Core.Tests.Services mockClient.Verify(c => c.PutAsync("nodes/pve1/qemu/100/cloudinit", null), Times.Once); } - [Fact] - public void GetCloudInitConfig_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new CloudInitService(mockClient.Object); - - // Act & Assert - Assert.Throws(() => service.GetCloudInitConfig(null!, "pve1", 100)); - } - - [Fact] - public void SetCloudInitConfig_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new CloudInitService(mockClient.Object); - var config = new Dictionary { ["ciuser"] = "test" }; - - // Act & Assert - Assert.Throws(() => service.SetCloudInitConfig(null!, "pve1", 100, config)); - } - - [Fact] - public void RegenerateCloudInitImage_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new CloudInitService(mockClient.Object); - - // Act & Assert - Assert.Throws(() => service.RegenerateCloudInitImage(null!, "pve1", 100)); - } - [Fact] public void Constructor_NullClient_ThrowsArgumentNullException() { @@ -197,13 +163,5 @@ namespace PSProxmoxVE.Core.Tests.Services // Assert mockClient.Verify(c => c.GetAsync("nodes/pve%20node/qemu/100/config"), Times.Once); } - - [Fact] - public void GetFullVmConfig_NullSession_ThrowsArgumentNullException() - { - var service = new CloudInitService(new Mock().Object); - - Assert.Throws(() => service.GetFullVmConfig(null!, "pve1", 100)); - } } } diff --git a/tests/PSProxmoxVE.Core.Tests/Services/ClusterConfigServiceTests.cs b/tests/PSProxmoxVE.Core.Tests/Services/ClusterConfigServiceTests.cs index 185220c..03970a2 100644 --- a/tests/PSProxmoxVE.Core.Tests/Services/ClusterConfigServiceTests.cs +++ b/tests/PSProxmoxVE.Core.Tests/Services/ClusterConfigServiceTests.cs @@ -380,50 +380,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Contains("did not contain a 'data' field", ex.Message); } - [Fact] - public void GetClusterConfig_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new ClusterConfigService(mockClient.Object); - - // Act & Assert - Assert.Throws(() => service.GetClusterConfig(null!)); - } - - [Fact] - public void GetConfigNodes_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new ClusterConfigService(mockClient.Object); - - // Act & Assert - Assert.Throws(() => service.GetConfigNodes(null!)); - } - - [Fact] - public void GetClusterOptions_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new ClusterConfigService(mockClient.Object); - - // Act & Assert - Assert.Throws(() => service.GetClusterOptions(null!)); - } - - [Fact] - public void GetNextId_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new ClusterConfigService(mockClient.Object); - - // Act & Assert - Assert.Throws(() => service.GetNextId(null!)); - } - [Fact] public void Constructor_NullClient_ThrowsArgumentNullException() { diff --git a/tests/PSProxmoxVE.Core.Tests/Services/ClusterServiceTests.cs b/tests/PSProxmoxVE.Core.Tests/Services/ClusterServiceTests.cs index bd4ed5a..6592dc8 100644 --- a/tests/PSProxmoxVE.Core.Tests/Services/ClusterServiceTests.cs +++ b/tests/PSProxmoxVE.Core.Tests/Services/ClusterServiceTests.cs @@ -96,28 +96,6 @@ namespace PSProxmoxVE.Core.Tests.Services mockClient.Verify(c => c.GetAsync("cluster/resources?type=vm"), Times.Once); } - [Fact] - public void GetClusterStatus_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new ClusterService(mockClient.Object); - - // Act & Assert - Assert.Throws(() => service.GetClusterStatus(null!)); - } - - [Fact] - public void GetClusterResources_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new ClusterService(mockClient.Object); - - // Act & Assert - Assert.Throws(() => service.GetClusterResources(null!)); - } - [Fact] public void Constructor_NullClient_ThrowsArgumentNullException() { diff --git a/tests/PSProxmoxVE.Core.Tests/Services/ContainerServiceTests.cs b/tests/PSProxmoxVE.Core.Tests/Services/ContainerServiceTests.cs index f5f2599..85ddd0d 100644 --- a/tests/PSProxmoxVE.Core.Tests/Services/ContainerServiceTests.cs +++ b/tests/PSProxmoxVE.Core.Tests/Services/ContainerServiceTests.cs @@ -190,33 +190,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal($"nodes/pve%20node/lxc/{TestVmId}/snapshot/snap%20name/rollback", captured.Path); } - [Fact] - public void CreateContainerSnapshot_NullSession_ThrowsArgumentNullException() - { - var service = new ContainerService(new Mock().Object); - - Assert.Throws("session", - () => service.CreateContainerSnapshot(null!, TestNode, TestVmId, "my-snap")); - } - - [Fact] - public void RemoveContainerSnapshot_NullSession_ThrowsArgumentNullException() - { - var service = new ContainerService(new Mock().Object); - - Assert.Throws("session", - () => service.RemoveContainerSnapshot(null!, TestNode, TestVmId, "my-snap")); - } - - [Fact] - public void RollbackContainerSnapshot_NullSession_ThrowsArgumentNullException() - { - var service = new ContainerService(new Mock().Object); - - Assert.Throws("session", - () => service.RollbackContainerSnapshot(null!, TestNode, TestVmId, "my-snap")); - } - [Fact] public void RollbackContainerSnapshot_WhitespaceSnapname_ThrowsArgumentNullException() { diff --git a/tests/PSProxmoxVE.Core.Tests/Services/FirewallServiceTests.cs b/tests/PSProxmoxVE.Core.Tests/Services/FirewallServiceTests.cs index b0831d4..4969578 100644 --- a/tests/PSProxmoxVE.Core.Tests/Services/FirewallServiceTests.cs +++ b/tests/PSProxmoxVE.Core.Tests/Services/FirewallServiceTests.cs @@ -259,14 +259,6 @@ namespace PSProxmoxVE.Core.Tests.Services // Guard clauses // ------------------------------------------------------------------------- - [Fact] - public void GetGroupRules_NullSession_ThrowsArgumentNullException() - { - var service = new FirewallService(new Mock().Object); - - Assert.Throws("session", () => service.GetGroupRules(null!, Group)); - } - [Fact] public void GetGroupRules_WhitespaceGroup_ThrowsArgumentNullException() { @@ -275,58 +267,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Throws("group", () => service.GetGroupRules(CreateSession(), " ")); } - [Fact] - public void CreateGroupRule_NullSession_ThrowsArgumentNullException() - { - var service = new FirewallService(new Mock().Object); - - Assert.Throws("session", - () => service.CreateGroupRule(null!, Group, new Dictionary())); - } - - [Fact] - public void CreateGroupRule_WhitespaceGroup_ThrowsArgumentNullException() - { - var service = new FirewallService(new Mock().Object); - - Assert.Throws("group", - () => service.CreateGroupRule(CreateSession(), " ", new Dictionary())); - } - - [Fact] - public void UpdateGroupRule_NullSession_ThrowsArgumentNullException() - { - var service = new FirewallService(new Mock().Object); - - Assert.Throws("session", - () => service.UpdateGroupRule(null!, Group, 0, new Dictionary())); - } - - [Fact] - public void UpdateGroupRule_WhitespaceGroup_ThrowsArgumentNullException() - { - var service = new FirewallService(new Mock().Object); - - Assert.Throws("group", - () => service.UpdateGroupRule(CreateSession(), " ", 0, new Dictionary())); - } - - [Fact] - public void RemoveGroupRule_NullSession_ThrowsArgumentNullException() - { - var service = new FirewallService(new Mock().Object); - - Assert.Throws("session", () => service.RemoveGroupRule(null!, Group, 0)); - } - - [Fact] - public void RemoveGroupRule_WhitespaceGroup_ThrowsArgumentNullException() - { - var service = new FirewallService(new Mock().Object); - - Assert.Throws("group", () => service.RemoveGroupRule(CreateSession(), " ", 0)); - } - // ------------------------------------------------------------------------- // FirewallScope.TryValidate // ------------------------------------------------------------------------- diff --git a/tests/PSProxmoxVE.Core.Tests/Services/HaServiceTests.cs b/tests/PSProxmoxVE.Core.Tests/Services/HaServiceTests.cs index 3300e90..c9ef2de 100644 --- a/tests/PSProxmoxVE.Core.Tests/Services/HaServiceTests.cs +++ b/tests/PSProxmoxVE.Core.Tests/Services/HaServiceTests.cs @@ -452,54 +452,6 @@ namespace PSProxmoxVE.Core.Tests.Services mockClient.Verify(c => c.DeleteAsync("cluster/ha/rules/rule1"), Times.Once); } - // ----------------------------------------------------------------- - // Null session tests - // ----------------------------------------------------------------- - - [Fact] - public void GetResources_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new HaService(mockClient.Object); - - // Act & Assert - Assert.Throws(() => service.GetResources(null!)); - } - - [Fact] - public void GetGroups_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new HaService(mockClient.Object); - - // Act & Assert - Assert.Throws(() => service.GetGroups(null!)); - } - - [Fact] - public void GetStatus_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new HaService(mockClient.Object); - - // Act & Assert - Assert.Throws(() => service.GetStatus(null!)); - } - - [Fact] - public void GetRules_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new HaService(mockClient.Object); - - // Act & Assert - Assert.Throws(() => service.GetRules(null!)); - } - [Fact] public void Constructor_NullClient_ThrowsArgumentNullException() { diff --git a/tests/PSProxmoxVE.Core.Tests/Services/NetworkServiceTests.cs b/tests/PSProxmoxVE.Core.Tests/Services/NetworkServiceTests.cs index cb74e02..3d6bcd5 100644 --- a/tests/PSProxmoxVE.Core.Tests/Services/NetworkServiceTests.cs +++ b/tests/PSProxmoxVE.Core.Tests/Services/NetworkServiceTests.cs @@ -149,12 +149,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.Verify(c => c.GetAsync($"nodes/{Node}/network?type=any%20bridge"), Times.Once); } - [Fact] - public void GetNetworks_NullSession_ThrowsArgumentNullException() - { - Assert.Throws("session", () => _service.GetNetworks(null!, Node)); - } - [Fact] public void GetNetworks_WhitespaceNode_ThrowsArgumentNullException() { @@ -243,13 +237,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal("nodes/pve%20node/network", captured.Path); } - [Fact] - public void CreateNetwork_NullSession_ThrowsArgumentNullException() - { - var config = new Dictionary { ["iface"] = "vmbr1" }; - Assert.Throws("session", () => _service.CreateNetwork(null!, Node, config)); - } - [Fact] public void CreateNetwork_NullConfig_ThrowsArgumentNullException() { @@ -299,13 +286,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal("nodes/pve%20node/network/vmbr%200", captured.Path); } - [Fact] - public void SetNetwork_NullSession_ThrowsArgumentNullException() - { - var config = new Dictionary { ["type"] = "bridge" }; - Assert.Throws("session", () => _service.SetNetwork(null!, Node, "vmbr0", config)); - } - [Fact] public void SetNetwork_WhitespaceIface_ThrowsArgumentNullException() { @@ -339,12 +319,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.VerifyNoOtherCalls(); } - [Fact] - public void RemoveNetwork_NullSession_ThrowsArgumentNullException() - { - Assert.Throws("session", () => _service.RemoveNetwork(null!, Node, "vmbr1")); - } - // ----------------------------------------------------------------- // ApplyNetworkConfig // ----------------------------------------------------------------- @@ -401,12 +375,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal("OK", task.ExitStatus); } - [Fact] - public void ApplyNetworkConfig_NullSession_ThrowsArgumentNullException() - { - Assert.Throws("session", () => _service.ApplyNetworkConfig(null!, Node)); - } - // ----------------------------------------------------------------- // GetSdnZones / GetSdnVnets / GetSdnSubnets // ----------------------------------------------------------------- @@ -434,12 +402,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Empty(zones); } - [Fact] - public void GetSdnZones_NullSession_ThrowsArgumentNullException() - { - Assert.Throws("session", () => _service.GetSdnZones(null!)); - } - [Fact] public void GetSdnVnets_ReturnsVnetArray() { @@ -463,12 +425,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Empty(vnets); } - [Fact] - public void GetSdnVnets_NullSession_ThrowsArgumentNullException() - { - Assert.Throws("session", () => _service.GetSdnVnets(null!)); - } - [Fact] public void GetSdnSubnets_RequestsVnetSubnetsPath() { @@ -502,12 +458,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Empty(subnets); } - [Fact] - public void GetSdnSubnets_NullSession_ThrowsArgumentNullException() - { - Assert.Throws("session", () => _service.GetSdnSubnets(null!, Vnet)); - } - [Fact] public void GetSdnSubnets_WhitespaceVnet_ThrowsArgumentNullException() { @@ -532,13 +482,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal("zone1", result.Zone); } - [Fact] - public void CreateSdnZone_NullSession_ThrowsArgumentNullException() - { - var config = new Dictionary { ["zone"] = "zone1" }; - Assert.Throws("session", () => _service.CreateSdnZone(null!, config)); - } - // ----------------------------------------------------------------- // CreateSdnVnet // ----------------------------------------------------------------- @@ -557,13 +500,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal("vnet1", result.Vnet); } - [Fact] - public void CreateSdnVnet_NullSession_ThrowsArgumentNullException() - { - var config = new Dictionary { ["vnet"] = "vnet1" }; - Assert.Throws("session", () => _service.CreateSdnVnet(null!, config)); - } - // ----------------------------------------------------------------- // CreateSdnSubnet // ----------------------------------------------------------------- @@ -595,20 +531,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal("cluster/sdn/vnets/vnet%201/subnets", captured.Path); } - [Fact] - public void CreateSdnSubnet_NullSession_ThrowsArgumentNullException() - { - var config = new Dictionary { ["subnet"] = "10.0.0.0/24" }; - Assert.Throws("session", () => _service.CreateSdnSubnet(null!, Vnet, config)); - } - - [Fact] - public void CreateSdnSubnet_WhitespaceVnet_ThrowsArgumentNullException() - { - var config = new Dictionary { ["subnet"] = "10.0.0.0/24" }; - Assert.Throws("vnet", () => _service.CreateSdnSubnet(_session, " ", config)); - } - // ----------------------------------------------------------------- // RemoveSdnSubnet // ----------------------------------------------------------------- @@ -636,12 +558,6 @@ namespace PSProxmoxVE.Core.Tests.Services c => c.DeleteAsync("cluster/sdn/vnets/vnet%201/subnets/10.0.0.0%2F24"), Times.Once); } - [Fact] - public void RemoveSdnSubnet_NullSession_ThrowsArgumentNullException() - { - Assert.Throws("session", () => _service.RemoveSdnSubnet(null!, Vnet, "10.0.0.0/24")); - } - // ----------------------------------------------------------------- // RemoveSdnZone / RemoveSdnVnet // ----------------------------------------------------------------- diff --git a/tests/PSProxmoxVE.Core.Tests/Services/NodeServiceTests.cs b/tests/PSProxmoxVE.Core.Tests/Services/NodeServiceTests.cs index 49096ec..959fd48 100644 --- a/tests/PSProxmoxVE.Core.Tests/Services/NodeServiceTests.cs +++ b/tests/PSProxmoxVE.Core.Tests/Services/NodeServiceTests.cs @@ -283,39 +283,6 @@ namespace PSProxmoxVE.Core.Tests.Services Times.Once); } - [Fact] - public void GetNodes_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new NodeService(mockClient.Object); - - // Act & Assert - Assert.Throws(() => service.GetNodes(null!)); - } - - [Fact] - public void GetNodeStatus_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new NodeService(mockClient.Object); - - // Act & Assert - Assert.Throws(() => service.GetNodeStatus(null!, "pve1")); - } - - [Fact] - public void GetNodeStatus_NullNode_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new NodeService(mockClient.Object); - - // Act & Assert - Assert.Throws(() => service.GetNodeStatus(CreateSession(), null!)); - } - [Fact] public void Constructor_NullClient_ThrowsArgumentNullException() { diff --git a/tests/PSProxmoxVE.Core.Tests/Services/SnapshotServiceTests.cs b/tests/PSProxmoxVE.Core.Tests/Services/SnapshotServiceTests.cs index f682aaa..b79e1b3 100644 --- a/tests/PSProxmoxVE.Core.Tests/Services/SnapshotServiceTests.cs +++ b/tests/PSProxmoxVE.Core.Tests/Services/SnapshotServiceTests.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Threading.Tasks; using Moq; @@ -325,37 +324,5 @@ namespace PSProxmoxVE.Core.Tests.Services // Assert Assert.Equal($"nodes/pve%20node/qemu/{VmId}/snapshot/snap%20name/rollback", captured.Path); } - - [Fact] - public void GetSnapshots_NullSession_ThrowsArgumentNullException() - { - var service = new SnapshotService(new Mock().Object); - - Assert.Throws("session", () => service.GetSnapshots(null!, Node, VmId)); - } - - [Fact] - public void CreateSnapshot_NullSession_ThrowsArgumentNullException() - { - var service = new SnapshotService(new Mock().Object); - - Assert.Throws("session", () => service.CreateSnapshot(null!, Node, VmId, "snap")); - } - - [Fact] - public void RemoveSnapshot_NullSession_ThrowsArgumentNullException() - { - var service = new SnapshotService(new Mock().Object); - - Assert.Throws("session", () => service.RemoveSnapshot(null!, Node, VmId, "snap")); - } - - [Fact] - public void RollbackSnapshot_NullSession_ThrowsArgumentNullException() - { - var service = new SnapshotService(new Mock().Object); - - Assert.Throws("session", () => service.RollbackSnapshot(null!, Node, VmId, "snap")); - } } } diff --git a/tests/PSProxmoxVE.Core.Tests/Services/StorageServiceTests.cs b/tests/PSProxmoxVE.Core.Tests/Services/StorageServiceTests.cs index cc1af84..dec4695 100644 --- a/tests/PSProxmoxVE.Core.Tests/Services/StorageServiceTests.cs +++ b/tests/PSProxmoxVE.Core.Tests/Services/StorageServiceTests.cs @@ -147,12 +147,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Empty(result); } - [Fact] - public void GetStorages_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.GetStorages(null!)); - } - // ----------------------------------------------------------------- // GetStorageContent // ----------------------------------------------------------------- @@ -194,24 +188,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.Verify(c => c.GetAsync("nodes/pve1/storage/local/content?content=iso"), Times.Once); } - [Fact] - public void GetStorageContent_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.GetStorageContent(null!, "pve1", "local")); - } - - [Fact] - public void GetStorageContent_NullNode_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.GetStorageContent(_session, null!, "local")); - } - - [Fact] - public void GetStorageContent_NullStorage_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.GetStorageContent(_session, "pve1", null!)); - } - // ----------------------------------------------------------------- // CreateStorage // ----------------------------------------------------------------- @@ -303,12 +279,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal(string.Empty, result.Storage); } - [Fact] - public void CreateStorage_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.CreateStorage(null!, new Dictionary())); - } - [Fact] public void CreateStorage_NullConfig_ThrowsArgumentNullException() { @@ -334,18 +304,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.Verify(c => c.PutAsync("storage/nfs-backup", config), Times.Once); } - [Fact] - public void UpdateStorage_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.UpdateStorage(null!, "local", new Dictionary())); - } - - [Fact] - public void UpdateStorage_NullStorage_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.UpdateStorage(_session, null!, new Dictionary())); - } - [Fact] public void UpdateStorage_NullConfig_ThrowsArgumentNullException() { @@ -384,18 +342,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.Verify(c => c.DeleteAsync("storage/..%2Faccess%2Fusers%2Fx"), Times.Once); } - [Fact] - public void RemoveStorage_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.RemoveStorage(null!, "local")); - } - - [Fact] - public void RemoveStorage_NullStorage_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.RemoveStorage(_session, null!)); - } - // ----------------------------------------------------------------- // GetStorageStatus // ----------------------------------------------------------------- @@ -418,24 +364,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal("dir", result.Type); } - [Fact] - public void GetStorageStatus_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.GetStorageStatus(null!, "pve1", "local")); - } - - [Fact] - public void GetStorageStatus_NullNode_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.GetStorageStatus(_session, null!, "local")); - } - - [Fact] - public void GetStorageStatus_NullStorage_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.GetStorageStatus(_session, "pve1", null!)); - } - // ----------------------------------------------------------------- // RemoveContent // ----------------------------------------------------------------- @@ -454,18 +382,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.Verify(c => c.DeleteAsync("nodes/pve1/storage/local/content/local%3Aiso%2Fdebian-12.iso"), Times.Once); } - [Fact] - public void RemoveContent_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.RemoveContent(null!, "pve1", "local", "vol")); - } - - [Fact] - public void RemoveContent_NullVolume_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.RemoveContent(_session, "pve1", "local", null!)); - } - // ----------------------------------------------------------------- // UpdateContent // ----------------------------------------------------------------- @@ -489,12 +405,6 @@ namespace PSProxmoxVE.Core.Tests.Services config), Times.Once); } - [Fact] - public void UpdateContent_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.UpdateContent(null!, "pve1", "local", "vol", new Dictionary())); - } - [Fact] public void UpdateContent_NullConfig_ThrowsArgumentNullException() { @@ -571,13 +481,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal("nodes/pve%20node/storage/local%20storage/upload", captured.Path); } - [Fact] - public void UploadIso_WhitespaceContentType_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.UploadIso(_session, "pve1", "local", "/tmp/test.iso", contentType: " ")); - } - [Fact] public void UploadIso_TimeoutOverride_PassesItToClientConstruction() { @@ -606,18 +509,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal(TimeSpan.FromMinutes(30), service.SeenTimeout); } - [Fact] - public void UploadIso_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.UploadIso(null!, "pve1", "local", "/tmp/test.iso")); - } - - [Fact] - public void UploadIso_NullFilePath_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.UploadIso(_session, "pve1", "local", null!)); - } - // ----------------------------------------------------------------- // DownloadUrl // ----------------------------------------------------------------- @@ -709,34 +600,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal(TimeSpan.FromMinutes(30), service.SeenTimeout); } - [Fact] - public void DownloadUrl_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.DownloadUrl(null!, "pve1", "local", "https://example.com/f.iso", "f.iso", "iso")); - } - - [Fact] - public void DownloadUrl_NullUrl_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.DownloadUrl(_session, "pve1", "local", null!, "f.iso", "iso")); - } - - [Fact] - public void DownloadUrl_NullFilename_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.DownloadUrl(_session, "pve1", "local", "https://example.com/f.iso", null!, "iso")); - } - - [Fact] - public void DownloadUrl_NullContentType_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.DownloadUrl(_session, "pve1", "local", "https://example.com/f.iso", "f.iso", null!)); - } - // ----------------------------------------------------------------- // AllocateDisk // ----------------------------------------------------------------- @@ -764,13 +627,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal("pve1", result.Node); } - [Fact] - public void AllocateDisk_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.AllocateDisk(null!, "pve1", "local", new Dictionary())); - } - [Fact] public void AllocateDisk_NullConfig_ThrowsArgumentNullException() { diff --git a/tests/PSProxmoxVE.Core.Tests/Services/TaskServiceTests.cs b/tests/PSProxmoxVE.Core.Tests/Services/TaskServiceTests.cs index 58b050f..aa09841 100644 --- a/tests/PSProxmoxVE.Core.Tests/Services/TaskServiceTests.cs +++ b/tests/PSProxmoxVE.Core.Tests/Services/TaskServiceTests.cs @@ -58,19 +58,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.True(task.IsSuccessful); } - [Fact] - public void GetTask_NullSession_ThrowsArgumentNullException() - { - // Arrange - var mockClient = new Mock(); - var service = new TaskService(mockClient.Object); - - // Act & Assert - var ex = Assert.Throws(() => - service.GetTask(null!, TestNode, TestUpid)); - Assert.Equal("session", ex.ParamName); - } - [Fact] public void GetTaskLog_HappyPath_ReturnsLogEntries() { diff --git a/tests/PSProxmoxVE.Core.Tests/Services/TemplateServiceTests.cs b/tests/PSProxmoxVE.Core.Tests/Services/TemplateServiceTests.cs index 2af0c22..8f6151f 100644 --- a/tests/PSProxmoxVE.Core.Tests/Services/TemplateServiceTests.cs +++ b/tests/PSProxmoxVE.Core.Tests/Services/TemplateServiceTests.cs @@ -75,22 +75,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal(Node, task.Node); } - [Fact] - public void CreateTemplate_NullSession_ThrowsArgumentNullException() - { - var service = new TemplateService(new Mock().Object); - - Assert.Throws("session", () => service.CreateTemplate(null!, Node, VmId)); - } - - [Fact] - public void CreateTemplate_NullNode_ThrowsArgumentNullException() - { - var service = new TemplateService(new Mock().Object); - - Assert.Throws("node", () => service.CreateTemplate(CreateSession(), null!, VmId)); - } - [Fact] public void CreateTemplate_EmptyNode_ThrowsArgumentNullException() { @@ -145,14 +129,6 @@ namespace PSProxmoxVE.Core.Tests.Services mockClient.Verify(c => c.GetAsync("nodes/pve%20node/qemu"), Times.Once); } - [Fact] - public void GetTemplates_NullSession_ThrowsArgumentNullException() - { - var service = new TemplateService(new Mock().Object); - - Assert.Throws("session", () => service.GetTemplates(null!, Node)); - } - [Fact] public void GetTemplates_AllNodes_AggregatesAcrossNodesAndStampsNode() { diff --git a/tests/PSProxmoxVE.Core.Tests/Services/UserServiceTests.cs b/tests/PSProxmoxVE.Core.Tests/Services/UserServiceTests.cs index b6d2ab6..da4a8b8 100644 --- a/tests/PSProxmoxVE.Core.Tests/Services/UserServiceTests.cs +++ b/tests/PSProxmoxVE.Core.Tests/Services/UserServiceTests.cs @@ -53,12 +53,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.Verify(c => c.GetAsync("access/users"), Times.Once); } - [Fact] - public void GetUsers_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.GetUsers(null!)); - } - [Fact] public void GetUser_ReturnsSingleUser() { @@ -75,12 +69,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal(1, result.Enabled); } - [Fact] - public void GetUser_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.GetUser(null!, "root@pam")); - } - [Fact] public void GetUser_NullUserId_ThrowsArgumentNullException() { @@ -111,18 +99,6 @@ namespace PSProxmoxVE.Core.Tests.Services Times.Once); } - [Fact] - public void CreateUser_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.CreateUser(null!, "user@pve")); - } - - [Fact] - public void CreateUser_NullUserId_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.CreateUser(_session, null!)); - } - [Fact] public void SetUser_PutsFormData() { @@ -146,20 +122,6 @@ namespace PSProxmoxVE.Core.Tests.Services Times.Once); } - [Fact] - public void SetUser_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.SetUser(null!, "user@pve", new Dictionary())); - } - - [Fact] - public void SetUser_NullUserId_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.SetUser(_session, null!, new Dictionary())); - } - [Fact] public void SetUser_NullConfig_ThrowsArgumentNullException() { @@ -181,18 +143,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.Verify(c => c.DeleteAsync("access/users/deploy%40pve"), Times.Once); } - [Fact] - public void RemoveUser_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.RemoveUser(null!, "user@pve")); - } - - [Fact] - public void RemoveUser_NullUserId_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.RemoveUser(_session, null!)); - } - // ================================================================= // API Tokens // ================================================================= @@ -219,18 +169,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal("root@pam", result[1].UserId); } - [Fact] - public void GetApiTokens_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.GetApiTokens(null!, "root@pam")); - } - - [Fact] - public void GetApiTokens_NullUserId_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.GetApiTokens(_session, null!)); - } - [Fact] public void CreateApiToken_ReturnsTokenWithSecret() { @@ -249,27 +187,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal("aabbccdd-1122-3344-5566-778899aabbcc", result.Value); } - [Fact] - public void CreateApiToken_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.CreateApiToken(null!, "root@pam", "token1")); - } - - [Fact] - public void CreateApiToken_NullUserId_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.CreateApiToken(_session, null!, "token1")); - } - - [Fact] - public void CreateApiToken_NullTokenId_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.CreateApiToken(_session, "root@pam", null!)); - } - [Fact] public void RemoveApiToken_CallsDeleteWithCorrectPath() { @@ -284,27 +201,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.Verify(c => c.DeleteAsync("access/users/root%40pam/token/automation"), Times.Once); } - [Fact] - public void RemoveApiToken_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.RemoveApiToken(null!, "root@pam", "token1")); - } - - [Fact] - public void RemoveApiToken_NullUserId_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.RemoveApiToken(_session, null!, "token1")); - } - - [Fact] - public void RemoveApiToken_NullTokenId_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.RemoveApiToken(_session, "root@pam", null!)); - } - [Fact] public void UpdateApiToken_CallsPutWithCorrectPath() { @@ -320,13 +216,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.Verify(c => c.PutAsync("access/users/root%40pam/token/automation", config), Times.Once); } - [Fact] - public void UpdateApiToken_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.UpdateApiToken(null!, "root@pam", "token1", new Dictionary())); - } - [Fact] public void UpdateApiToken_NullConfig_ThrowsArgumentNullException() { @@ -361,12 +250,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal("VM.PowerMgmt,VM.Console", result[2].Privileges); } - [Fact] - public void GetRoles_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.GetRoles(null!)); - } - [Fact] public void CreateRole_PostsFormData() { @@ -385,18 +268,6 @@ namespace PSProxmoxVE.Core.Tests.Services Times.Once); } - [Fact] - public void CreateRole_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.CreateRole(null!, "role1")); - } - - [Fact] - public void CreateRole_NullRoleId_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.CreateRole(_session, null!)); - } - [Fact] public void UpdateRole_PutsPrivileges() { @@ -414,27 +285,6 @@ namespace PSProxmoxVE.Core.Tests.Services Times.Once); } - [Fact] - public void UpdateRole_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.UpdateRole(null!, "role1", "privs")); - } - - [Fact] - public void UpdateRole_NullRoleId_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.UpdateRole(_session, null!, "privs")); - } - - [Fact] - public void UpdateRole_NullPrivileges_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.UpdateRole(_session, "role1", null!)); - } - [Fact] public void RemoveRole_CallsDeleteWithCorrectPath() { @@ -449,18 +299,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.Verify(c => c.DeleteAsync("access/roles/BackupOperator"), Times.Once); } - [Fact] - public void RemoveRole_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.RemoveRole(null!, "role1")); - } - - [Fact] - public void RemoveRole_NullRoleId_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.RemoveRole(_session, null!)); - } - // ================================================================= // Groups // ================================================================= @@ -486,12 +324,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal("operators", result[1].GroupId); } - [Fact] - public void GetGroups_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.GetGroups(null!)); - } - [Fact] public void CreateGroup_PostsFormData() { @@ -510,18 +342,6 @@ namespace PSProxmoxVE.Core.Tests.Services Times.Once); } - [Fact] - public void CreateGroup_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.CreateGroup(null!, "group1")); - } - - [Fact] - public void CreateGroup_NullGroupId_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.CreateGroup(_session, null!)); - } - [Fact] public void UpdateGroup_PutsConfig() { @@ -537,20 +357,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.Verify(c => c.PutAsync("access/groups/devops", config), Times.Once); } - [Fact] - public void UpdateGroup_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.UpdateGroup(null!, "group1", new Dictionary())); - } - - [Fact] - public void UpdateGroup_NullGroupId_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.UpdateGroup(_session, null!, new Dictionary())); - } - [Fact] public void UpdateGroup_NullConfig_ThrowsArgumentNullException() { @@ -572,18 +378,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.Verify(c => c.DeleteAsync("access/groups/devops"), Times.Once); } - [Fact] - public void RemoveGroup_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.RemoveGroup(null!, "group1")); - } - - [Fact] - public void RemoveGroup_NullGroupId_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.RemoveGroup(_session, null!)); - } - // ================================================================= // Domains / Realms // ================================================================= @@ -612,12 +406,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Equal("ldap", result[2].Type); } - [Fact] - public void GetDomains_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.GetDomains(null!)); - } - [Fact] public void CreateDomain_PostsConfig() { @@ -639,13 +427,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.Verify(c => c.PostAsync("access/domains", config), Times.Once); } - [Fact] - public void CreateDomain_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.CreateDomain(null!, new Dictionary())); - } - [Fact] public void CreateDomain_NullConfig_ThrowsArgumentNullException() { @@ -668,20 +449,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.Verify(c => c.PutAsync("access/domains/corp-ad", config), Times.Once); } - [Fact] - public void UpdateDomain_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.UpdateDomain(null!, "pam", new Dictionary())); - } - - [Fact] - public void UpdateDomain_NullRealm_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.UpdateDomain(_session, null!, new Dictionary())); - } - [Fact] public void UpdateDomain_NullConfig_ThrowsArgumentNullException() { @@ -703,18 +470,6 @@ namespace PSProxmoxVE.Core.Tests.Services _mockClient.Verify(c => c.DeleteAsync("access/domains/corp-ad"), Times.Once); } - [Fact] - public void RemoveDomain_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.RemoveDomain(null!, "pam")); - } - - [Fact] - public void RemoveDomain_NullRealm_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.RemoveDomain(_session, null!)); - } - // ================================================================= // Password // ================================================================= @@ -737,27 +492,6 @@ namespace PSProxmoxVE.Core.Tests.Services Times.Once); } - [Fact] - public void ChangePassword_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.ChangePassword(null!, "user@pve", "pass")); - } - - [Fact] - public void ChangePassword_NullUserId_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.ChangePassword(_session, null!, "pass")); - } - - [Fact] - public void ChangePassword_NullPassword_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.ChangePassword(_session, "user@pve", null!)); - } - // ================================================================= // Permissions / ACLs // ================================================================= @@ -851,12 +585,6 @@ namespace PSProxmoxVE.Core.Tests.Services Assert.Empty(result); } - [Fact] - public void GetPermissions_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => _service.GetPermissions(null!)); - } - [Fact] public void SetPermission_PutsAclData() { @@ -964,26 +692,5 @@ namespace PSProxmoxVE.Core.Tests.Services d.Count == 3)), Times.Once); } - - [Fact] - public void SetPermission_NullSession_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.SetPermission(null!, "/", "Admin")); - } - - [Fact] - public void SetPermission_NullPath_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.SetPermission(_session, null!, "Admin")); - } - - [Fact] - public void SetPermission_NullRoles_ThrowsArgumentNullException() - { - Assert.Throws(() => - _service.SetPermission(_session, "/", null!)); - } } }