-
Notifications
You must be signed in to change notification settings - Fork 2
Using Ergo
Yan Justino edited this page Dec 26, 2019
·
1 revision
Ergo is an amazing feature of Polyjuice. With Ergo you can register your stubs and use then when necessary. See how use Ergo bellow:
Describes a default stub model.
/// Setup
Ergo<Person>.Current.SetDefault(new Person
{
FirstName = Name.FirstName,
LastName = Name.LastName,
FullName = Name.FullName ,
NameWithPrefix = Name.NameWithPrefix,
Gender = Gender.Random,
Birthday = DateAndTime.Birthday
});
[Test]
public void TestPersonA()
{
var person = Ergo<Person>.Current.GetDefault()
...
}
[Test]
public void TestPersonB()
{
var person = Ergo<Person>.Current.GetDefault()
...
}
Describes a contextualized stub model.
/// Setup
Ergo<Person>.Current["Regular Customer"] = new Person
{
FirstName = Name.FirstName,
LastName = Name.LastName,
FullName = Name.FullName ,
NameWithPrefix = Name.NameWithPrefix,
Gender = Gender.Random,
Birthday = DateAndTime.Birthday
};
[Test]
public void TestPersonA()
{
var stub = Ergo<Person>.Current["Regular Customer"];
...
}
[Test]
public void TestPersonB()
{
var stub = Ergo<Person>.Current["Regular Customer"];
...
}