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

46 lines
1.3 KiB
C#
Raw Normal View History

using System.Reflection;
2021-12-16 15:35:09 +01:00
using AutoFixture;
using AutoFixture.Xunit2;
using Bit.Core.Entities;
2021-12-16 15:35:09 +01:00
using Bit.Core.Enums;
2022-08-29 22:06:55 +02:00
namespace Bit.Core.Test.AutoFixture.OrganizationUserFixtures;
2022-08-29 22:06:55 +02:00
public class OrganizationUserCustomization : ICustomization
{
public OrganizationUserStatusType Status { get; set; }
public OrganizationUserType Type { get; set; }
2022-08-29 22:06:55 +02:00
public OrganizationUserCustomization(OrganizationUserStatusType status, OrganizationUserType type)
{
Status = status;
Type = type;
2022-08-29 20:53:16 +02:00
}
2022-08-29 22:06:55 +02:00
public void Customize(IFixture fixture)
2022-08-29 20:53:16 +02:00
{
2022-08-29 22:06:55 +02:00
fixture.Customize<OrganizationUser>(composer => composer
.With(o => o.Type, Type)
.With(o => o.Status, Status));
}
}
2022-08-29 22:06:55 +02:00
public class OrganizationUserAttribute : CustomizeAttribute
{
private readonly OrganizationUserStatusType _status;
private readonly OrganizationUserType _type;
2022-08-29 22:06:55 +02:00
public OrganizationUserAttribute(
OrganizationUserStatusType status = OrganizationUserStatusType.Confirmed,
OrganizationUserType type = OrganizationUserType.User)
{
_status = status;
_type = type;
}
public override ICustomization GetCustomization(ParameterInfo parameter)
{
return new OrganizationUserCustomization(_status, _type);
}
}