AutoBogus icon indicating copy to clipboard operation
AutoBogus copied to clipboard

[Bug] Faking List<MemoryStream> throws ArgumentOutOfRangeException

Open ledux opened this issue 2 years ago • 2 comments

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; }
    }
  • Expected: Green Test
  • Actual: ArgumentOutOfRangeException
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 avatar Mar 10 '22 10:03 ledux

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>>()

ledux avatar Mar 10 '22 12:03 ledux

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

soenneker avatar Mar 11 '24 01:03 soenneker