Skip to content

Commit

Permalink
chore: expand tests of the new UpdateInstallationCommand (#5227)
Browse files Browse the repository at this point in the history
  • Loading branch information
addisonbeck authored Jan 7, 2025
1 parent eeb1be1 commit 5ae232e
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 5ae232e

Please sign in to comment.