2021-10-30 00:40:50 +02:00
|
|
|
using System;
|
|
|
|
using Xunit;
|
|
|
|
using AutoFixture;
|
|
|
|
using System.Reflection;
|
|
|
|
using System.Linq;
|
2021-10-30 19:32:15 +02:00
|
|
|
using Bit.Test.Common.Helpers;
|
2021-10-30 00:40:50 +02:00
|
|
|
|
|
|
|
namespace Bit.Test.Common.AutoFixture.Attributes
|
|
|
|
{
|
2021-10-30 19:32:15 +02:00
|
|
|
public class BitMemberAutoDataAttribute : MemberDataAttributeBase
|
2021-10-30 00:40:50 +02:00
|
|
|
{
|
|
|
|
private readonly Func<IFixture> _createFixture;
|
|
|
|
|
2021-10-30 19:32:15 +02:00
|
|
|
public BitMemberAutoDataAttribute(string memberName, params object[] parameters) :
|
2021-10-30 00:40:50 +02:00
|
|
|
this(() => new Fixture(), memberName, parameters)
|
|
|
|
{ }
|
|
|
|
|
2021-10-30 19:32:15 +02:00
|
|
|
public BitMemberAutoDataAttribute(Func<IFixture> createFixture, string memberName, params object[] parameters) :
|
2021-10-30 00:40:50 +02:00
|
|
|
base(memberName, parameters)
|
|
|
|
{
|
|
|
|
_createFixture = createFixture;
|
|
|
|
}
|
|
|
|
|
2021-10-30 19:32:15 +02:00
|
|
|
protected override object[] ConvertDataItem(MethodInfo testMethod, object item) =>
|
|
|
|
BitAutoDataAttributeHelpers.GetData(testMethod, _createFixture(), item as object[]).First();
|
2021-10-30 00:40:50 +02:00
|
|
|
}
|
|
|
|
}
|