public void StartConsuming_ValidInput_ValidOutput() { // Arrange string[] output = new string[] { "html code <a href=\"http://www.google1.com\">link to google</a> html code", "html code <a href=\"http://www.google2.com\">link to google</a> html code", "html code <a href=\"http://www.google3.com\">link to google</a> html code", }; string firstResult = null; IProducerUnit producer = new MockProducerUnit(output); IParser<string> parser = new SyncStringToStringParser(); List<string> results = new List<string>(); IConsumerUnit consumer = new ConsumerUnit(parser, (res) => firstResult = new List<string>(res)[0]); // Act consumer.StartConsuming(producer); // TODO Thread.Sleep(2000); // Assert Assert.IsNotNull(firstResult); }
public void Parse_ValidInput_ValidOutput() { // Arrange string[] output = new string[] { "html code <a href=\"http://www.google1.com\">link to google</a>", "html code <a href=\"http://www.google2.com\">link to google</a> html code <a href=\"http://www.google3.com\">link to google</a> html code", "html code no link", "" }; IProducerUnit producer = new MockProducerUnit(output); IParser<string> parser = new SyncStringToStringParser(); List<string> results = new List<string>(); // Act parser.Parse(producer, results); // Assert Assert.AreEqual(3, results.Count); }