public void HandlesRawHtmlAcquiredEvent() { // Arrange var projection = new AmountByPublicationSetForEachMpProjection(A.Fake <IParseMoneyFromHtml>()); var htmlEvent = new RawHtmlDataAcquiredEvent("https://somewebsite/160111/some_mp.htm", DateTimeOffset.MinValue, "foo"); // Act projection.Handle(htmlEvent); // Assert Assert.AreEqual(1, projection.Result().Count); }
public void Handle(RawHtmlDataAcquiredEvent rawHtmlDataAcquiredEvent) { var rawHtmlData = new RawHtmlData(rawHtmlDataAcquiredEvent.SourceUrl, rawHtmlDataAcquiredEvent.Acquired, rawHtmlDataAcquiredEvent.Html); if (!this.mpTotalsByPublicationSet.ContainsKey(rawHtmlData.MpKey)) { this.mpTotalsByPublicationSet.Add(rawHtmlData.MpKey, new Dictionary <string, PublicationSetTotal>()); } var amount = this.moneyParser.Parse(rawHtmlData.FilteredHtml).Sum(x => x.Amount); this.mpTotalsByPublicationSet[rawHtmlData.MpKey][rawHtmlData.PublicationSet] = new PublicationSetTotal(rawHtmlData.PublicationSet, amount); }
public void SumsResultOfMoneyParsing() { // Arrange var moneyParser = A.Fake <IParseMoneyFromHtml>(); A.CallTo(() => moneyParser.Parse(A <string> .Ignored)).Returns(new List <MoneyParseResult>() { new MoneyParseResult(10m), new MoneyParseResult(20m), }); var projection = new AmountByPublicationSetForEachMpProjection(moneyParser); var htmlEvent = new RawHtmlDataAcquiredEvent("https://somewebsite/160111/john_smith.htm", DateTimeOffset.MinValue, "foo"); // Act projection.Handle(htmlEvent); // Assert Assert.AreEqual(30, projection.Result()["john_smith"]["160111"].Amount); }