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:
parent
eeb1be1dba
commit
5ae232e336
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user