Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to write unit test for this method
    primarykey
    data
    text
    <p>I am writing unit test for this method. I have tried lot of times but still can not write any code for it. Please suggest me how to unit test it. I am using C# , nunit framework and rhino mock.</p> <p>Thanks in advance.</p> <pre><code> public FileUploadJsonResult AjaxUploadProfile(int id, string branchName, string filepath, HttpPostedFileBase file) { // TODO: Add your business logic here and/or save the file string statusCode = "1"; string profilePicture = string.Empty; string fileExtension = System.IO.Path.GetExtension(file.FileName.ToLower()); string fileName = id + "_" + branchName; string fileNameWithOriginalExtension = fileName + fileExtension; string fileNameWithJPGExtension = fileName + ".jpg"; string fileServerPath = this.Server.MapPath("~/LO_ProfilePicture/" + fileNameWithJPGExtension); string statusMessage = string.Empty; if (string.IsNullOrEmpty(fileExtension) || !Utility.isCorrectExtension(fileExtension)) { statusMessage = "Profile picture should be of JPG, BMP, PNG, GIF or JPEG format."; return new FileUploadJsonResult { Data = new { message = string.Format(statusMessage, fileNameWithOriginalExtension), filename = string.Empty, profilepic = profilePicture, statusCode = "0" } }; } if (file.ContentLength &gt; PageConstants.PROFILE_PICTURE_FILE_SIZE) { statusMessage = "Profile picture size should be less than 2MB"; return new FileUploadJsonResult { Data = new { message = string.Format(statusMessage, fileNameWithOriginalExtension), filename = string.Empty, profilepic = profilePicture, statusCode = "0" } }; } Utility.SaveThumbnailImage(fileServerPath, file.InputStream, PageConstants.BRANCH_PROFILE_PICTURE_FILE_HEIGTH, PageConstants.BRANCH_PROFILE_PICTURE_FILE_WIDTH); profilePicture = PageConstants.IMAGE_PATH + "LO_ProfilePicture/" + fileNameWithJPGExtension; // Return JSON return new FileUploadJsonResult { Data = new { message = string.Format("Profile Picture is successfully uploaded.", fileNameWithOriginalExtension), filename = fileNameWithJPGExtension, profilepic = profilePicture, statusCode } }; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload