public void Map_Calls_Parse_And_Log_IsValidNever(string uriString) { // Arrange mockIParser.Setup(m => m.Parse(uriString)).Returns((Uri)null); var mapper = new UriMapper(mockIParser.Object, mockIValidator.Object, mockILogger.Object); // Act mapper.Map(uriString); // Assert mockIParser.Verify(p => p.Parse(uriString), Times.Once); mockIValidator.Verify(v => v.IsValid(null), Times.Never); mockILogger.Verify(l => l.Log($"The line {uriString} is not processed."), Times.Once); }
public void Map_Calls_Parse_And_IsValid_And_LogNever(string uriString) { // Arrange Uri uri = new Uri(uriString); mockIParser.Setup(m => m.Parse(uriString)).Returns(uri); var mapper = new UriMapper(mockIParser.Object, mockIValidator.Object, mockILogger.Object); // Act mapper.Map(uriString); // Assert mockIParser.Verify(p => p.Parse(uriString), Times.Once); mockIValidator.Verify(v => v.IsValid(uri), Times.Once); mockILogger.Verify(l => l.Log("never colled"), Times.Never); }
public void Map_Calls_Parse_And_Log_Is(string uriString) { // Arrange Uri uri = new Uri(uriString); mockIParser.Setup(m => m.Parse(uriString)).Returns(uri); mockIValidator.Setup(v => v.Message).Returns($"The uri {uriString} must contain host of dns type."); var mapper = new UriMapper(mockIParser.Object, mockIValidator.Object, mockILogger.Object); // Act mapper.Map(uriString); // Assert mockIParser.Verify(p => p.Parse(uriString), Times.Once); mockIValidator.Verify(v => v.IsValid(uri), Times.Once); mockILogger.Verify(l => l.Log($"The line {uriString} is not processed - {mockIValidator.Object.Message}"), Times.Once); }