1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-16 01:51:21 +01:00

chore: expand tests of the new UpdateInstallationCommand (#5227)

This commit is contained in:
Addison Beck 2025-01-07 14:58:30 -05:00 committed by GitHub
parent eeb1be1dba
commit 5ae232e336
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,6 +9,49 @@ namespace Bit.Core.Platform.Installations.Tests;
[SutProviderCustomize]
public class UpdateInstallationCommandTests
{
[Theory]
[BitAutoData]
public async Task UpdateLastActivityDateAsync_WithDefaultGuid_ThrowsException(SutProvider<UpdateInstallationCommand> sutProvider)
{
// Arrange
var defaultGuid = default(Guid);
// Act & Assert
var exception = await Assert.ThrowsAsync<Exception>(
() => sutProvider.Sut.UpdateLastActivityDateAsync(defaultGuid));
Assert.Contains("invalid installation id", exception.Message);
await sutProvider
.GetDependency<IInstallationRepository>()
.DidNotReceive()
.UpsertAsync(Arg.Any<Installation>());
}
[Theory]
[BitAutoData]
public async Task UpdateLastActivityDateAsync_WithNonExistentInstallation_ThrowsException(
Guid installationId,
SutProvider<UpdateInstallationCommand> sutProvider)
{
// Arrange
sutProvider
.GetDependency<IGetInstallationQuery>()
.GetByIdAsync(installationId)
.Returns((Installation)null);
// Act & Assert
var exception = await Assert.ThrowsAsync<Exception>(
() => sutProvider.Sut.UpdateLastActivityDateAsync(installationId));
Assert.Contains("no installation was found", exception.Message);
await sutProvider
.GetDependency<IInstallationRepository>()
.DidNotReceive()
.UpsertAsync(Arg.Any<Installation>());
}
[Theory]
[BitAutoData]
public async Task UpdateLastActivityDateAsync_ShouldUpdateLastActivityDate(