AutoFixture mock sut inner method

Viewed 220

We would like to mock inner method of the sut object. For example, we want to mock CustomerHasLimitObligation when we are testing CheckCustomerAssessmentType. How we can mock this method with AutoFixture?

public class OfferAssessmentBusiness: IOfferAssessmentBusiness
{
                               
        public bool CheckCustomerAssessmentType(int offerId)
        {
            return this.CustomerHasLimitObligation(offerI);
        }
                               
                               
        public bool CustomerHasLimitObligation(int offerId)
        {
            //....
            //....

        }
}

[TestMethod]
public void CheckCustomerAssessmentType_CheckIndividualLimit_Success()
{
    //Arrange
    var sut = Fixture.Freeze<OfferAssessmentBusiness>();

    //Act
    var result = sut.CheckCustomerAssessmentType(It.IsAny<int>());

    //Assert
    Assert.IsTrue(result);
}
0 Answers
Related