1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-03 14:03:33 +01:00
bitwarden-server/test/Core.Test/AutoFixture/PolicyFixtures.cs

42 lines
1021 B
C#
Raw Normal View History

using System.Reflection;
using AutoFixture;
2021-12-16 15:35:09 +01:00
using AutoFixture.Xunit2;
using Bit.Core.Entities;
2021-12-16 15:35:09 +01:00
using Bit.Core.Enums;
namespace Bit.Core.Test.AutoFixture.PolicyFixtures
2022-08-29 20:53:16 +02:00
{
internal class PolicyCustomization : ICustomization
2022-08-29 20:53:16 +02:00
{
public PolicyType Type { get; set; }
public PolicyCustomization(PolicyType type)
{
Type = type;
}
public void Customize(IFixture fixture)
{
fixture.Customize<Policy>(composer => composer
.With(o => o.OrganizationId, Guid.NewGuid())
.With(o => o.Type, Type)
.With(o => o.Enabled, true));
}
2022-08-29 20:53:16 +02:00
}
public class PolicyAttribute : CustomizeAttribute
2022-08-29 20:53:16 +02:00
{
private readonly PolicyType _type;
public PolicyAttribute(PolicyType type)
{
_type = type;
}
public override ICustomization GetCustomization(ParameterInfo parameter)
{
return new PolicyCustomization(_type);
}
}
}