안녕하세요, 저는 Test Driven Development로 시작하고 있습니다. 나는 두 개의 테스트 케이스 NUnit generated Mock Repository가 다른 테스트 케이스에서 같은 객체를 반환합니다.
[Test, Order(3)]
public void Should_Not_Create_ServiceAccountTaxCode_If_BillType_Is_Not_RateReady()
{
//ARRANGE
var customerDetailsViewForBillTYpeRateReady = new CustomerTaxDetailsView
{
BillType = (int)BillTypes.BillReady
};
_repository.Stub(x => x.GetCustomerDetailsForTaxes(Arg<int>.Is.Anything)).Return(dict.Dequeue());
//ACT
var result = _concern.PopulateServiceAccountWithTaxDetails(Arg<int>.Is.Anything);
[Test, Order(4)]
public void Should_Create_ServiceAccountTaxCode_If_BillType_Is_RateReady()
{
//ARRANGE
const int serviceAccountId = 1;
var customerDetailsView = new CustomerTaxDetailsView
{
BillType = (int)BillTypes.RateReady,
ServiceTypeId = (int)ServiceTypes.Electric
};
_repository.Stub(x => x.GetCustomerDetailsForTaxes(serviceAccountId))
.Return(customerDetailsView).Repeat.Once();
var result = _concern.PopulateServiceAccountWithTaxDetails(serviceAccountId);
이 어디에 코드를 가지고 그리고 나는
[OneTimeSetUp]
public void Initialize()
{
_repository = MockRepository.GenerateMock<IServiceAccountTaxCodeRepository>();
유일한 문제에 다음 구문을 사용하여 모의를 생성하고하면 두 번째 테스트 케이스도 내 결과 개체가 있다는 것이다 첫 번째 테스트 케이스에서 customerDetailsViewForBillTYpeRateReady. 왜 이런 일이 일어나는거야? 그리고 이러한 테스트를 독립적으로 실행하면 모든 것이 통과됩니다. 어떤 도움을 주시면 감사하겠습니다 ..
dict.dequeue는 실제로 customerDetailsViewForBillTYpeRateReady 객체를 큐에서 제거합니다. – user1505521