我有兩個類和一個接口。我想在我的測試中使用模擬。我想設置我的ReadBooklets()方法。但我不知道我該怎麼做。 class FileHandler : IHandler
{
public List<string> ReadBooklets() // A booklets.txt-ben található mérési azonosítókat beolvassa egy str
我想測試查詢第三方庫的方法。該庫返回一個具有IReadOnlyCollection屬性的對象。 沒有構造函數來設置屬性的值,並且對象沒有接口供我模擬。 我已經使用Moq來模擬我調用的服務的接口,但是我無法創建一個模擬的返回值,因爲我無法設置該屬性。 public interface IHitService {
public Hit GetHit();
}
public class
我有一個模擬對象ttLoc爲ILocation。我已將其狀態值設置爲LocationState.Available。 我有一個名爲UpdateLocationState的方法,它將更新我正在編寫測試用例的狀態。 當狀態更新時引發事件。 當事件發生時,我想更新ttLoc.Object.State至LocationState.Reserved。 我該如何做到這一點? var ttLoc = new M
我有我的視圖模型中的代碼如下。 private Generate()
{
// Some code here
var window = new CreateWindow
{
Owner = Application.Current.MainWindow
};
}
我想在我的單元測試中模擬MainWindow對象。我試過 var app
我將使用單元測試項目創建用戶註冊方法測試。請參考下面的代碼 [TestClass]
public class PersonRegistration
{
private ILoggingService _loggingService;
private IUserManager _userManager;
public PersonRegistration(I