How do you use Moq to mock a simple interface?

前端 未结 1 786
伪装坚强ぢ
伪装坚强ぢ 2021-02-06 21:45

Okay, I have a business logic class like this:

Note: For context, Vendor Briefs are simple entities that describe a \"download\" for a PDF document.

///          


        
相关标签:
1条回答
  • 2021-02-06 22:09

    Something like this would test DeleteVendorBrief, for example.

    Mock<IVendorBriefRepository> mock = new Mock<IVendorBriefRepository>();
    
    VendorBriefController controller = new VendorBriefController(mock.Object);
    
    VendorBrief brief = new VendorBrief();
    
    controller.DeleteVendorBrief(brief);
    
    mock.Verify(f=>f.DeleteVendorBrief(brief));
    mock.Verify(f=>f.SaveChanges());
    
    0 讨论(0)
提交回复
热议问题