mirror of
https://github.com/bitwarden/server.git
synced 2024-11-25 12:45:18 +01:00
231eb84e69
* Turn on ImplicitUsings * Fix formatting * Run linter
41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using Bit.Core.Context;
|
|
using Bit.Core.Entities;
|
|
using Bit.Core.Enums;
|
|
using Bit.Core.Models.Data;
|
|
using Bit.Core.Services;
|
|
using Bit.Test.Common.AutoFixture;
|
|
using Bit.Test.Common.AutoFixture.Attributes;
|
|
using Bit.Test.Common.Helpers;
|
|
using NSubstitute;
|
|
using Xunit;
|
|
|
|
namespace Bit.Core.Test.Services
|
|
{
|
|
[SutProviderCustomize]
|
|
public class EventServiceTests
|
|
{
|
|
public static IEnumerable<object[]> InstallationIdTestCases => TestCaseHelper.GetCombinationsOfMultipleLists(
|
|
new object[] { Guid.NewGuid(), null },
|
|
Enum.GetValues<EventType>().Select(e => (object)e)
|
|
).Select(p => p.ToArray());
|
|
|
|
[Theory]
|
|
[BitMemberAutoData(nameof(InstallationIdTestCases))]
|
|
public async Task LogOrganizationEvent_ProvidesInstallationId(Guid? installationId, EventType eventType,
|
|
Organization organization, SutProvider<EventService> sutProvider)
|
|
{
|
|
organization.Enabled = true;
|
|
organization.UseEvents = true;
|
|
|
|
sutProvider.GetDependency<ICurrentContext>().InstallationId.Returns(installationId);
|
|
|
|
await sutProvider.Sut.LogOrganizationEventAsync(organization, eventType);
|
|
|
|
await sutProvider.GetDependency<IEventWriteService>().Received(1).CreateAsync(Arg.Is<IEvent>(e =>
|
|
e.OrganizationId == organization.Id &&
|
|
e.Type == eventType &&
|
|
e.InstallationId == installationId));
|
|
}
|
|
}
|
|
}
|