mercredi 1 avril 2020

NSubstitute test for void method

I would like to verify that the parameter idStatus is assigned to the myObj instance. How can I do this with NSubstitute? I thought that if I somehow could verify the parameter to UpdateObject this would be a good test of the method, but not sure how to do this. Any thoughts?

public void SetObjectStatus(int id, int? idStatus)
{
    var myObj = GetObject(id);
    myObj.IdStatus = idStatus;

    UpdateObject(myObj);
}


[TestMethod]
public void SetObjectStatus_Verify()
{
    //Arrange
    int id = 1;
    int? newStatus = 10;

    //Act
    test.SetObjectStatus(id, newStatus);

    //Assert
    //?? I would like to check that myObj.IdStatus equals newStatus (10).
}

Aucun commentaire:

Enregistrer un commentaire