我需要创建一个HttpPostedFileBase类对象的实例并将其传递给一个方法,但我找不到任何方法来实例化它.我正在创建一个测试用例来测试我的fileupload方法.
这是我的方法,它采取一个HttpPostedFileBase对象.我需要从我的测试用例类中调用它.我没有使用任何模拟库.
有一个简单的方法吗?
[HttpPost]
public JsonResult AddVariation(HttpPostedFileBase file, string name, string comment, string description, decimal amount, string accountLineTypeID)
{
var accountLineType = _fileService.GetAccountLineType(AccountLineType.Debit);
if (Guid.Parse(accountLineTypeID) == _fileService.GetAccountLineType(AccountLineType.Credit).AccountLineTypeID)
{
amount = 0 - amount;
}
var info = new File()
{
FileID = Guid.NewGuid(),
Name = name,
Description = description,
FileName = file.FileName,
BuildID = Guid.Parse(SelectedBuildID),
MimeType = file.ContentType,
CreatedUserID = CurrentUser.UserID,
UpdatedUserID = CurrentUser.UserID,
Amount = amount,
};
var cmmnt = new Comment()
{
CommentDate = …Run Code Online (Sandbox Code Playgroud)