From 5ae232e33697ac6ca1085ac7c2c29010a67cc8f2 Mon Sep 17 00:00:00 2001 From: Addison Beck Date: Tue, 7 Jan 2025 14:58:30 -0500 Subject: [PATCH] chore: expand tests of the new `UpdateInstallationCommand` (#5227) --- .../UpdateInstallationCommandTests.cs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/Core.Test/Platform/Installations/Commands/UpdateInstallationCommandTests.cs b/test/Core.Test/Platform/Installations/Commands/UpdateInstallationCommandTests.cs index daa8e1b89..ec04ac711 100644 --- a/test/Core.Test/Platform/Installations/Commands/UpdateInstallationCommandTests.cs +++ b/test/Core.Test/Platform/Installations/Commands/UpdateInstallationCommandTests.cs @@ -9,6 +9,49 @@ namespace Bit.Core.Platform.Installations.Tests; [SutProviderCustomize] public class UpdateInstallationCommandTests { + [Theory] + [BitAutoData] + public async Task UpdateLastActivityDateAsync_WithDefaultGuid_ThrowsException(SutProvider sutProvider) + { + // Arrange + var defaultGuid = default(Guid); + + // Act & Assert + var exception = await Assert.ThrowsAsync( + () => sutProvider.Sut.UpdateLastActivityDateAsync(defaultGuid)); + + Assert.Contains("invalid installation id", exception.Message); + + await sutProvider + .GetDependency() + .DidNotReceive() + .UpsertAsync(Arg.Any()); + } + + [Theory] + [BitAutoData] + public async Task UpdateLastActivityDateAsync_WithNonExistentInstallation_ThrowsException( + Guid installationId, + SutProvider sutProvider) + { + // Arrange + sutProvider + .GetDependency() + .GetByIdAsync(installationId) + .Returns((Installation)null); + + // Act & Assert + var exception = await Assert.ThrowsAsync( + () => sutProvider.Sut.UpdateLastActivityDateAsync(installationId)); + + Assert.Contains("no installation was found", exception.Message); + + await sutProvider + .GetDependency() + .DidNotReceive() + .UpsertAsync(Arg.Any()); + } + [Theory] [BitAutoData] public async Task UpdateLastActivityDateAsync_ShouldUpdateLastActivityDate(