Resetting with CallBase = true will not fallback to base class #135
Open
Description
it.only("call base reset fails", () => {
class MockMe {
public a() {
return 5;
}
}
const mockMeMock: TypeMoq.IMock<MockMe> = TypeMoq.Mock.ofInstance(new MockMe());
mockMeMock.callBase = true;
mockMeMock.setup((mm) => mm.a()).returns(() => 10);
chai.assert.equal(mockMeMock.object.a(), 10);
chai.assert.equal(mockMeMock.object.a(), 10);
chai.assert.equal(mockMeMock.object.a(), 10);
mockMeMock.reset();
chai.assert.equal(mockMeMock.object.a(), 5); // FAILS
});
it.only("call base false reset succeeds", () => {
class MockMe {
public a() {
return 5;
}
}
const mockMeMock: TypeMoq.IMock<MockMe> = TypeMoq.Mock.ofInstance(new MockMe());
mockMeMock.callBase = false;
mockMeMock.setup((mm) => mm.a()).returns(() => 10);
chai.assert.equal(mockMeMock.object.a(), 10);
chai.assert.equal(mockMeMock.object.a(), 10);
chai.assert.equal(mockMeMock.object.a(), 10);
mockMeMock.reset();
chai.assert.isUndefined(mockMeMock.object.a()); // PASSES
});
Metadata
Assignees
Labels
No labels