nickdodd79 / AutoBogus

A C# library complementing the Bogus generator by adding auto creation and population capabilities.
MIT License
423 stars 49 forks source link

[Bug] Faking List<MemoryStream> throws ArgumentOutOfRangeException #82

Open ledux opened 2 years ago

ledux commented 2 years ago

Given the following code

    [Fact]
    public void TestAutoBogus()
    {
        var testData = AutoFaker.Generate<TestData>();
        testData.Should().NotBeNull();
    }

    private class TestData
    {
        public List<MemoryStream> BinaryListValues { get; set; }
    }
System.ArgumentOutOfRangeException
The initialCount argument must be non-negative and less than or equal to the maximumCount. (Parameter 'initialCount')
Actual value was -1985685215.
   at System.Threading.SemaphoreSlim..ctor(Int32 initialCount, Int32 maxCount)
   at System.Threading.SemaphoreSlim..ctor(Int32 initialCount)

AutoBogus.FakeItEasy: 2.13.1 AutoBogus: 2.13.1 Bogus: 31.0.3

ledux commented 2 years ago

Looks like it fails when it instantiates the SemaphoreSlim _asyncActiveSemaphore of the MemoryStream. It only accepts a positive int as parameter. Not sure, if this can easily fixed. I "solved" it by .WithSkip<MemoryStream>().WithSkip<List<MemoryStream>>()

soenneker commented 4 months ago

@ledux FYI I just implemented a MemoryStreamGenerator in soenneker.utils.autobogus which actually generates MemoryStreams. Thanks