Esempio n. 1
0
        public void ParseReferencesCommand_RunWithNullDocumentAndNullProgramSettings_ShouldThrowArgumentNullException()
        {
            // Arrange
            var parserMock = new Mock <IReferencesParser>();
            var command    = new ParseReferencesCommand(parserMock.Object);

            // Act + Assert
            var exception = Assert.ThrowsAsync <ArgumentNullException>(() =>
            {
                return(command.Run(null, null));
            });

            parserMock.Verify(p => p.Parse(It.IsAny <XmlNode>()), Times.Never);
        }
Esempio n. 2
0
        public void ParseReferencesCommand_RunWithValidDocumentAndNullProgramSettings_ShouldThrowArgumentNullExceptionWithCorrectParamName()
        {
            // Arrange
            var parserMock   = new Mock <IReferencesParser>();
            var command      = new ParseReferencesCommand(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 <XmlNode>()), Times.Never);
        }
Esempio n. 3
0
        public async Task ParseReferencesCommand_RunWithValidDocumentAndValidProgramSettings_ShouldCallParserWithCorrectParameter()
        {
            // Arrange
            var parserMock   = new Mock <IReferencesParser>();
            var command      = new ParseReferencesCommand(parserMock.Object);
            var settingsMock = new Mock <ICommandSettings>();
            var documentMock = new Mock <IDocument>();

            var xmldocumentStub = new XmlDocument();

            xmldocumentStub.LoadXml("<a />");

            documentMock
            .SetupGet(d => d.XmlDocument)
            .Returns(xmldocumentStub);

            // Act
            var result = await command.Run(documentMock.Object, settingsMock.Object);

            // Assert
            parserMock.Verify(p => p.Parse(It.IsAny <XmlNode>()), Times.Once);
            parserMock.Verify(p => p.Parse(xmldocumentStub.DocumentElement), Times.Once);
        }