public void ParseTreatmentMetaWithAphiaCommand_RunWithNullDocumentAndNullProgramSettings_ShouldThrowArgumentNullException() { // Arrange var parserMock = new Mock <ITreatmentMetaParserWithDataService <IAphiaTaxaClassificationResolver> >(); var command = new ParseTreatmentMetaWithAphiaCommand(parserMock.Object); // Act + Assert var exception = Assert.ThrowsAsync <ArgumentNullException>(() => { return(command.Run(null, null)); }); parserMock.Verify(p => p.Parse(It.IsAny <IDocument>()), Times.Never); }
public async Task ParseTreatmentMetaWithAphiaCommand_RunWithValidDocumentAndValidProgramSettings_ShouldCallParserWithCorrectParameter() { // Arrange var parserMock = new Mock <ITreatmentMetaParserWithDataService <IAphiaTaxaClassificationResolver> >(); var command = new ParseTreatmentMetaWithAphiaCommand(parserMock.Object); var settingsMock = new Mock <ICommandSettings>(); var documentMock = new Mock <IDocument>(); // Act var result = await command.Run(documentMock.Object, settingsMock.Object); // Assert parserMock.Verify(p => p.Parse(It.IsAny <IDocument>()), Times.Once); parserMock.Verify(p => p.Parse(documentMock.Object), Times.Once); }
public void ParseTreatmentMetaWithAphiaCommand_RunWithValidDocumentAndNullProgramSettings_ShouldThrowArgumentNullExceptionWithCorrectParamName() { // Arrange var parserMock = new Mock <ITreatmentMetaParserWithDataService <IAphiaTaxaClassificationResolver> >(); var command = new ParseTreatmentMetaWithAphiaCommand(parserMock.Object); var documentMock = new Mock <IDocument>(); // Act + Assert var exception = Assert.ThrowsAsync <ArgumentNullException>(() => { return(command.Run(documentMock.Object, null)); }); Assert.AreEqual(ParameterNames.Settings, exception.ParamName, "ParamName is not correct."); parserMock.Verify(p => p.Parse(It.IsAny <IDocument>()), Times.Never); }