public void UploadFileFaildTest(string fileName, string fileContentType, long fileSize, string allowedExtensions, string allowedContentType, long?maxSize, FileCheckLayers layers) { var fileMock = new Mock <IFormFile>(); fileMock.Setup(_ => _.FileName).Returns(fileName); fileMock.Setup(_ => _.Length).Returns(fileSize); fileMock.Setup(_ => _.ContentType).Returns(fileContentType); var file = fileMock.Object; //Act var response = file.IsAllowed(allowedExtensions, allowedContentType, maxSize, layers); //Assert Assert.False(response.IsAllowed); _output.WriteLine(response.ErrorMessage); }
public void UploadFileTest(string fileName, string fileContentType, long fileSize, string allowedExtensions, string allowedContentType, long?maxSize, FileCheckLayers layers) { var fileMock = new Mock <IFormFile>(); fileMock.Setup(_ => _.FileName).Returns(fileName); fileMock.Setup(_ => _.Length).Returns(fileSize); fileMock.Setup(_ => _.ContentType).Returns(fileContentType); var file = fileMock.Object; //Act var isAllowed = file.IsFileAllowed(allowedExtensions, allowedContentType, maxSize, layers); //Assert Assert.True(isAllowed); }