2022-06-30 01:46:41 +02:00
|
|
|
|
using System.Reflection;
|
2021-12-16 15:35:09 +01:00
|
|
|
|
using AutoFixture;
|
|
|
|
|
using AutoFixture.Xunit2;
|
2022-02-10 19:48:06 +01:00
|
|
|
|
using Bit.Core.Entities;
|
2021-12-16 15:35:09 +01:00
|
|
|
|
using Bit.Core.Enums;
|
2021-05-25 19:23:47 +02:00
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
namespace Bit.Core.Test.AutoFixture.OrganizationUserFixtures;
|
2021-05-25 19:23:47 +02:00
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
public class OrganizationUserCustomization : ICustomization
|
|
|
|
|
{
|
|
|
|
|
public OrganizationUserStatusType Status { get; set; }
|
|
|
|
|
public OrganizationUserType Type { get; set; }
|
2021-05-25 19:23:47 +02:00
|
|
|
|
|
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 21:53:48 +02:00
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
public class OrganizationUserAttribute : CustomizeAttribute
|
|
|
|
|
{
|
|
|
|
|
private readonly OrganizationUserStatusType _status;
|
|
|
|
|
private readonly OrganizationUserType _type;
|
2022-08-29 21:53:48 +02:00
|
|
|
|
|
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);
|
2021-05-25 19:23:47 +02:00
|
|
|
|
}
|
|
|
|
|
}
|