Created
March 26, 2021 01:18
-
-
Save nth-commit/549b389cfe0bfb6c03cd463f8e202ceb to your computer and use it in GitHub Desktop.
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
public class MyTest : IClassFixture<MyTest.Fixture> | |
{ | |
// Somehow this thing is in scope, as well as the values that come out of it. Also somehow, the generated values gets into the fixture. | |
public static readonly IGen<List<Person>> Users = Gen.Type<Person>(); | |
private readonly Fixture _fixture; | |
public MyTest(Fixture fixture) | |
{ | |
_fixture = fixture; | |
} | |
[Property] | |
public void SomethingAboutUsers() | |
{ | |
// Can access _fixture.Users or whatever | |
} | |
[Property] | |
public IGen<Test> SomethingAboutUsers() => | |
from nonExistentUserId in Gen.Guid() | |
select Property.ForThese(() => | |
{ | |
// Can access _fixture.Users or whatever, and they are the same users as the other test (one insert) | |
// Can also generate your own stuff local to the test which won't be shared. | |
}); | |
private class Fixture : IAsyncLifetime | |
{ | |
public Task InitializeAsync() | |
{ | |
// Insert all the users | |
return Task.CompletedTask; | |
} | |
public Task DisposeAsync() => Task.CompletedTask; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment