aboutsummaryrefslogtreecommitdiff
path: root/RhSolutions.SkuParser.Tests/FormFileUtil.cs
blob: aaee7cab26bbc49328c6591691b5710c5912d11b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using Microsoft.AspNetCore.Http;
using Moq;

namespace RhSolutions.SkuParser.Tests;

public static class FormFileUtil
{
	public static Mock<IFormFile> GetMockFormFile(string workbookName)
	{
		string filepath = "./../../../Workbooks/" + workbookName;
		var mockFile = new Mock<IFormFile>();
		var memoryStream = new MemoryStream([.. File.ReadAllBytes(filepath)]);
		mockFile.Setup(x => x.OpenReadStream())
			.Returns(memoryStream);
		return mockFile;
	}
}