Created
January 21, 2016 02:48
-
-
Save vkhorikov/e52e7366a8b3eac98c5b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 UserBuilder | |
{ | |
private readonly string _firstName; | |
private readonly string _lastName; | |
public UserBuilder() | |
: this(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()) | |
{ | |
} | |
private UserBuilder(string firstName, string lastName) | |
{ | |
_lastName = lastName; | |
_firstName = firstName; | |
} | |
public UserBuilder WithFirstName(string firstName) | |
{ | |
return new UserBuilder(firstName, _lastName); | |
} | |
public UserBuilder WithLastName(string lastName) | |
{ | |
return new UserBuilder(_firstName, lastName); | |
} | |
public User Build() | |
{ | |
return new User(_firstName, _lastName); | |
} | |
} |
This file contains hidden or 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
[Fact] | |
public void Some_test() | |
{ | |
// Arrange | |
User user = new UserBuilder() | |
.WithFirstName("Some first name") | |
.Build(); | |
// Act | |
// Assert | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment