2024-10-03 22:13:43 +02:00
|
|
|
|
#nullable enable
|
|
|
|
|
using AutoFixture;
|
2024-10-02 19:23:19 +02:00
|
|
|
|
using Bit.Core.NotificationCenter.Entities;
|
|
|
|
|
using Bit.Test.Common.AutoFixture.Attributes;
|
|
|
|
|
|
|
|
|
|
namespace Bit.Core.Test.NotificationCenter.AutoFixture;
|
|
|
|
|
|
|
|
|
|
public class NotificationCustomization(bool global) : ICustomization
|
|
|
|
|
{
|
|
|
|
|
public void Customize(IFixture fixture)
|
|
|
|
|
{
|
|
|
|
|
fixture.Customize<Notification>(composer =>
|
|
|
|
|
{
|
|
|
|
|
var postprocessComposer = composer.With(n => n.Id, Guid.NewGuid())
|
|
|
|
|
.With(n => n.Global, global);
|
|
|
|
|
|
|
|
|
|
postprocessComposer = global
|
|
|
|
|
? postprocessComposer.Without(n => n.UserId)
|
|
|
|
|
: postprocessComposer.With(n => n.UserId, Guid.NewGuid());
|
|
|
|
|
|
|
|
|
|
return global
|
|
|
|
|
? postprocessComposer.Without(n => n.OrganizationId)
|
|
|
|
|
: postprocessComposer.With(n => n.OrganizationId, Guid.NewGuid());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-03 22:13:43 +02:00
|
|
|
|
public class NotificationCustomizeAttribute(bool global = true) : BitCustomizeAttribute
|
2024-10-02 19:23:19 +02:00
|
|
|
|
{
|
|
|
|
|
public override ICustomization GetCustomization() => new NotificationCustomization(global);
|
|
|
|
|
}
|