1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-02 13:53:23 +01:00
bitwarden-server/test/Core.Test/Vault/AutoFixture/CipherAttachmentMetaDataFixtures.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1.4 KiB
C#
Raw Normal View History

using AutoFixture;
using AutoFixture.Dsl;
using Bit.Core.Vault.Models.Data;
namespace Bit.Core.Test.AutoFixture.CipherAttachmentMetaData;
2022-08-29 22:06:55 +02:00
public class MetaData : ICustomization
{
protected virtual IPostprocessComposer<CipherAttachment.MetaData> ComposerAction(IFixture fixture,
ICustomizationComposer<CipherAttachment.MetaData> composer)
{
return composer.With(d => d.Size, fixture.Create<long>());
}
public void Customize(IFixture fixture)
{
fixture.Customize<CipherAttachment.MetaData>(composer => ComposerAction(fixture, composer));
fixture.Behaviors.OfType<ThrowingRecursionBehavior>()
.ToList()
.ForEach(b => fixture.Behaviors.Remove(b));
fixture.Behaviors.Add(new OmitOnRecursionBehavior(1));
}
2022-08-29 22:06:55 +02:00
}
public class MetaDataWithoutContainer : MetaData
{
protected override IPostprocessComposer<CipherAttachment.MetaData> ComposerAction(IFixture fixture,
ICustomizationComposer<CipherAttachment.MetaData> composer) =>
base.ComposerAction(fixture, composer).With(d => d.ContainerName, (string)null);
2022-08-29 22:06:55 +02:00
}
public class MetaDataWithoutKey : MetaDataWithoutContainer
2022-08-29 22:06:55 +02:00
{
protected override IPostprocessComposer<CipherAttachment.MetaData> ComposerAction(IFixture fixture,
ICustomizationComposer<CipherAttachment.MetaData> composer) =>
base.ComposerAction(fixture, composer).Without(d => d.Key);
}