2021-02-22 22:35:16 +01:00
|
|
|
|
using AutoFixture;
|
|
|
|
|
using AutoFixture.Dsl;
|
2023-03-02 19:23:38 +01:00
|
|
|
|
using Bit.Core.Vault.Models.Data;
|
2021-02-22 22:35:16 +01:00
|
|
|
|
|
|
|
|
|
namespace Bit.Core.Test.AutoFixture.CipherAttachmentMetaData;
|
2022-08-29 22:06:55 +02:00
|
|
|
|
|
2021-02-22 22:35:16 +01:00
|
|
|
|
public class MetaData : ICustomization
|
|
|
|
|
{
|
|
|
|
|
protected virtual IPostprocessComposer<CipherAttachment.MetaData> ComposerAction(IFixture fixture,
|
|
|
|
|
ICustomizationComposer<CipherAttachment.MetaData> composer)
|
|
|
|
|
{
|
2022-01-21 15:36:25 +01:00
|
|
|
|
return composer.With(d => d.Size, fixture.Create<long>());
|
2021-02-22 22:35:16 +01:00
|
|
|
|
}
|
|
|
|
|
public void Customize(IFixture fixture)
|
|
|
|
|
{
|
|
|
|
|
fixture.Customize<CipherAttachment.MetaData>(composer => ComposerAction(fixture, composer));
|
2023-07-21 21:08:08 +02:00
|
|
|
|
fixture.Behaviors.OfType<ThrowingRecursionBehavior>()
|
|
|
|
|
.ToList()
|
|
|
|
|
.ForEach(b => fixture.Behaviors.Remove(b));
|
|
|
|
|
fixture.Behaviors.Add(new OmitOnRecursionBehavior(1));
|
2021-02-22 22:35:16 +01:00
|
|
|
|
}
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
2021-02-22 22:35:16 +01: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
|
|
|
|
}
|
|
|
|
|
|
2021-02-22 22:35:16 +01:00
|
|
|
|
public class MetaDataWithoutKey : MetaDataWithoutContainer
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2021-02-22 22:35:16 +01:00
|
|
|
|
protected override IPostprocessComposer<CipherAttachment.MetaData> ComposerAction(IFixture fixture,
|
|
|
|
|
ICustomizationComposer<CipherAttachment.MetaData> composer) =>
|
|
|
|
|
base.ComposerAction(fixture, composer).Without(d => d.Key);
|
|
|
|
|
}
|