forked from tomchavakis/nuget-license
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also test optional fields in custom package information
- Loading branch information
Showing
4 changed files
with
64 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
.../Helper/AutoFixture/NuGet/Versioning/CustomPackageInformationBuilderWithOptionalFileds.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Licensed to the projects contributors. | ||
// The license conditions are provided in the LICENSE file located in the project root | ||
|
||
using AutoFixture; | ||
using AutoFixture.Kernel; | ||
using NuGetUtility.PackageInformationReader; | ||
using NuGetUtility.Wrapper.NuGetWrapper.Versioning; | ||
|
||
namespace NuGetUtility.Test.Helper.AutoFixture.NuGet.Versioning | ||
{ | ||
internal class CustomPackageInformationBuilderWithOptionalFileds : ISpecimenBuilder | ||
{ | ||
public object Create(object request, ISpecimenContext context) | ||
{ | ||
if (request is System.Type t && t == typeof(CustomPackageInformation)) | ||
{ | ||
return new CustomPackageInformation(context.Create<string>(), | ||
context.Create<INuGetVersion>(), | ||
context.Create<string>(), | ||
CreateOptional<string>(context), | ||
CreateOptional<string>(context), | ||
CreateOptional<string>(context), | ||
CreateOptional<string>(context), | ||
CreateOptional<string>(context), | ||
CreateOptional<string>(context), | ||
CreateOptional<Uri>(context)); | ||
} | ||
|
||
return new NoSpecimen(); | ||
} | ||
|
||
private static T? CreateOptional<T>(ISpecimenContext context) where T : notnull | ||
{ | ||
return context.Create<bool>() ? context.Create<T>() : default; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters