-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
I see some great use cases for the library in unit testing, to create some fake objects and convert them into my models. It would be nice if steps were skippable, such that the long lists such as:
CreateFakeStudent
.WithRandomId()
.WithRandomName()
.WithRandomPhone()
.WithBudget(100)
could be replaced with: CreateFakeStudent.WithBudget(100). This makes the intent of the faked object clearer. The WithRandomX methods I have shown are FluentDefaults so they would be implicit. A possible implementation would allow doing that:
[FluentApi]
class FakeStudent {
[FluentMember(0)]
[FluentSkippable]
public Guid Id {get;set;} = Guid.NewGuid();
[FluentMember(1)]
[FluentSkippable]
public string Name {get;set;} = "John Doe"; // not random but you get the point
[FluentMember(2)]
[FluentSkippable]
public string Phome {get;set;} = "123";
[FluentMember(3)]
public int Budget {get;set;}
}
and generate:
// no interface for Id because it is the first step
interface INameSkippable : IPhoneSkippable {
void WithName();
}
interface IPhoneSkippable : IBudget {
void WithPhone();
}
interface IBudget {
FakeStudent WithBudget();
}
static class CreateFakeStudent {
static INameSkippable WithId() { ... }
static IPhoneSkippable WithPhone() { ... }
static IBudget WithBudget() { ... }
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request