Код: Выделить всё
public class when_creating_an_account
{
static Mock _mockedRepository;
static AccountCreator _accountCreator;
static NewAccount _newAccount;
static Account _result;
static Account _account;
Establish context = () =>
{
_mockedRepository = new Mock();
_accountCreator = new AccountCreator(_mockedRepository.Object);
_newAccount = new NewAccount();
_account = new Account();
_mockedRepository
.Setup(x => x.Create(Moq.It.IsAny()))
.Returns(_account);
};
Because of = () => _result = _accountCreator.Create(_newAccount);
It should_create_the_account_in_the_repository = () => _result.ShouldEqual(_account);
}
Код: Выделить всё
public class when_creating_an_account
{
static Mock _mockedRepository;
static AccountCreator _accountCreator;
static NewAccount _newAccount;
static Account _result;
static Account _account;
Establish context = () =>
{
_mockedRepository = new Mock();
_accountCreator = new AccountCreator(_mockedRepository.Object);
_newAccount = new NewAccount
{
//full of populated properties
};
_account = new Account
{
//matching properties to verify correct mapping
};
_mockedRepository
.Setup(x => x.Create(Moq.It.IsLike(_account)))
.Returns(_account);
};
Because of = () => _result = _accountCreator.Create(_newAccount);
It should_create_the_account_in_the_repository = () => _result.ShouldEqual(_account);
}
Итак, оно уже существует? Или, может быть, вы уже делали это раньше и не против поделиться кодом?
Подробнее здесь: https://stackoverflow.com/questions/112 ... s-argument