1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-29 13:25:17 +01:00
bitwarden-server/test/Common/AutoFixture/JsonDocumentFixtures.cs
Justin Baur 231eb84e69
Turn On ImplicitUsings (#2079)
* Turn on ImplicitUsings

* Fix formatting

* Run linter
2022-06-29 19:46:41 -04:00

33 lines
829 B
C#

using System.Text.Json;
using AutoFixture;
using AutoFixture.Kernel;
namespace Bit.Test.Common.AutoFixture.JsonDocumentFixtures
{
public class JsonDocumentCustomization : ICustomization, ISpecimenBuilder
{
public string Json { get; set; }
public void Customize(IFixture fixture)
{
fixture.Customizations.Add(this);
}
public object Create(object request, ISpecimenContext context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
var type = request as Type;
if (type == null || (type != typeof(JsonDocument)))
{
return new NoSpecimen();
}
return JsonDocument.Parse(Json ?? "{}");
}
}
}