Skip to content

Commit c5b965a

Browse files
committed
PercentBuilder
1 parent 10339f0 commit c5b965a

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using AutoFixture.Kernel;
2+
using Noggog;
3+
using Noggog.Testing.AutoFixture;
4+
5+
namespace CSharpExt.UnitTests.AutoFixture;
6+
7+
public class PercentBuilderTests
8+
{
9+
[Theory, DefaultAutoData]
10+
public void Typical(
11+
Percent sut)
12+
{
13+
}
14+
}

Noggog.Testing/AutoFixture/DefaultCustomization.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public void Customize(IFixture fixture)
3232
fixture.Customizations.Add(new LazyBuilder());
3333
fixture.Customizations.Add(new ExtendedListBuilder());
3434
fixture.Customizations.Add(new Array2dBuilder());
35+
fixture.Customizations.Add(new PercentBuilder());
3536
fixture.Behaviors.Add(new ObservableEmptyBehavior());
3637
fixture.Register<IWorkDropoff>(() => InlineWorkDropoff.Instance);
3738
fixture.Register<ICreateStream>(() => NormalFileStreamCreator.Instance);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using AutoFixture;
2+
using AutoFixture.Kernel;
3+
4+
namespace Noggog.Testing.AutoFixture;
5+
6+
public class PercentBuilder : ISpecimenBuilder
7+
{
8+
private readonly Random _random = new();
9+
10+
public object Create(object request, ISpecimenContext context)
11+
{
12+
if (request is Type t
13+
&& t == typeof(Percent))
14+
{
15+
return new Percent(_random.NextDouble());
16+
}
17+
return new NoSpecimen();
18+
}
19+
}

0 commit comments

Comments
 (0)