1
0
mirror of https://github.com/bitwarden/server synced 2025-12-22 03:03:33 +00:00

XUnit.v3 Upgrade

This commit is contained in:
Justin Baur
2025-11-18 16:12:52 -05:00
parent 2b926ef1c5
commit 76b463cc99
97 changed files with 379 additions and 449 deletions

View File

@@ -1,15 +1,11 @@
// FIXME: Update this file to be null safe and then delete the line below
#nullable disable
using AutoFixture;
using AutoFixture.Xunit2;
using AutoFixture;
using AutoFixture.Xunit3;
namespace Bit.Test.Common.AutoFixture.Attributes;
public class CustomAutoDataAttribute : AutoDataAttribute
{
public CustomAutoDataAttribute(params Type[] iCustomizationTypes) : this(iCustomizationTypes
.Select(t => (ICustomization)Activator.CreateInstance(t)).ToArray())
public CustomAutoDataAttribute(params Type[] iCustomizationTypes) : this(CreateCustomizations(iCustomizationTypes))
{ }
public CustomAutoDataAttribute(params ICustomization[] customizations) : base(() =>
@@ -22,4 +18,22 @@ public class CustomAutoDataAttribute : AutoDataAttribute
return fixture;
})
{ }
private static ICustomization[] CreateCustomizations(Type[] customizationTypes)
{
var customizations = new ICustomization[customizationTypes.Length];
for (var i = 0; i < customizationTypes.Length; i++)
{
var customizationType = customizationTypes[i];
var customizationObj = Activator.CreateInstance(customizationTypes[i]);
if (customizationObj is not ICustomization customization)
{
throw new InvalidOperationException($"{customizationType.FullName} should implement ICustomization");
}
customizations[i] = customization;
}
return customizations;
}
}