/// <summary> /// Start the matcher. The rocess is the following: /// /// 1. start matcher service /// 2. register matcher at partition module /// 3. ask for a partition /// 4. ask for a job /// 5. send ready signal to parititon module /// 6. wait for and 'done' signal /// </summary> private void Start(string[] argv) { CompositionService.Default.Initialize(); MatcherStartArguments startArgs = new MatcherStartArguments(argv); this.partitionServiceUri = startArgs.PartitionServiceUri; MatcherService service = new MatcherService(startArgs.Port); service.Start(); var client = new PartitionBrokerServiceClient(startArgs.PartitionServiceUri); Info = new MatcherInfo { Id = this.id, Port = startArgs.Port, Host = GetHost() }; if (!client.RegisterMatcher(Info)) { logger.Fatal("Could not register with partitioning module. Shutting down."); return; } this.model = client.GetPartition(this.id); // get a job, and signal back AcquireJob(); // wait for an exis signal this.done.WaitOne(); service.Close(); }
static void Main(string[] args) { try { IPaymentReaderService paymentReaderService = new PaymentReaderService(); IPriceReaderService priceReaderService = new PriceReaderService(); IPurchaseReaderService purchaseReaderService = new PurchaseReaderService(); IMatcherService matcherService = new MatcherService(); var format = args.Length > 0 ? args[0] : "json"; IMatchWriter matchWriter = CreateMatcher(format); var payments = paymentReaderService.Read(@"Data\Payments.json"); var prices = priceReaderService.Read(@"Data\Prices.xml"); var purchases = purchaseReaderService.Read(@"Data\Purchases.dat"); var matches = matcherService.Match(payments, prices, purchases); var fileName = args.Length > 1 ? args[1] : "PaymentsNotMatched." + format; matchWriter.Write(fileName, matches); } catch (Exception exception) { Console.WriteLine(exception.Message); } }
private void TokenizeAndGetSuggestions(string markup) { var generator = new DisplayHtmlGenerator(); var matcherService = new MatcherService(); var tokenizer = new AspxTokenizer(); Tokens = tokenizer.Tokenize(markup).ToList(); suggestionsMap = matcherService.GetSuggestions(Tokens); (DisplayHtml, Suggestions) = generator.GenerateDisplayHtml(Tokens, suggestionsMap); }
public void MatchTest() { IMatcherService matcherService = new MatcherService(); var payments = new List <Payment>() { new Payment() { Customer = 1, Year = 2020, Month = 1, Amount = 5 } }; var prices = new List <ItemPrice>() { new ItemPrice() { Item = 1, Price = 10 }, new ItemPrice() { Item = 2, Price = 100 } }; var purchases = new List <Purchase>() { new Purchase() { Customer = 1, DateTime = new DateTime(2020, 1, 13), Items = { 1, 2 } } }; var actualMatches = matcherService.Match(payments, prices, purchases); var expectedMatches = new List <PaymentMatch>() { new PaymentMatch() { Customer = 1, Year = 2020, Month = 1, AmountDue = 110, AmountPayed = 5, Difference = 105 } }; Assert.AreEqual(expectedMatches.Count, actualMatches.Count); for (int i = 0; i < expectedMatches.Count; i++) { var expectedMatch = expectedMatches[i]; var actualMatch = actualMatches[i]; Assert.IsTrue(PaymentMatchesEqual(expectedMatch, actualMatch)); } }
public void Run() { // Arrange var response = new ObjectResult(new JObject()) { StatusCode = 200 }; ResponseService.Run().Returns(response); var command = new Command("text", "subtext"); command.Container = Container; // Act var result = command.Run(); // Assert TableGeneratorService.Received().Run(); MatcherService.Received().Run(); ResponseService.Received().Run(); Assert.Equal(result, response); }