public void Validate_With_Empty_Data_Failure() { var wordCountSearchParameter = new WordCountSearchParameter { File = null }; wordCountSearchParameter.Invoking(x => x.Validate()).Should().Throw <ValidationException>().WithMessage( ExceptionMessages.InvalidInput(nameof(wordCountSearchParameter.File))); }
public void Validate_Text_Property_Is_Empty_Failure() { var path = Path.Combine(Environment.CurrentDirectory, "TestData/TestFileWithNoData.txt"); using var stream = File.OpenRead(path); var file = new FormFile(stream, 0, stream.Length, null, Path.GetFileName(stream.Name)) { Headers = new HeaderDictionary(), ContentType = MimeTypesConstants.Text.Plain }; var wordCountSearchParameter = new WordCountSearchParameter { File = file, }; wordCountSearchParameter.Invoking(x => x.Validate()).Should().Throw <ValidationException>().WithMessage( ExceptionMessages.InvalidInput(nameof(wordCountSearchParameter.Text))); }
public void Validate_Text_With_Invalid_ContentType_Failure() { const string value = "MimeTypesConstants.Application.AtomcatXml"; var path = Path.Combine(Environment.CurrentDirectory, "TestData/TestFile.docx"); using var stream = File.OpenRead(path); var file = new FormFile(stream, 0, stream.Length, null, Path.GetFileName(stream.Name)) { Headers = new HeaderDictionary(), ContentType = value }; var wordCountSearchParameter = new WordCountSearchParameter { File = file }; wordCountSearchParameter.Invoking(x => x.Validate()).Should().Throw <ValidationException>().WithMessage( ExceptionMessages.AllowedInputContentTypes(value, WordCountSearchParameter.AllowedContextTypes)); }