public void when_matching_for_an_exact_match_and_the_description_is_not_an_exact_match_should_return_false() { var transaction_match = new TransactionMatch { TransactionMatchType = TransactionMatchType.ExactMatch, Description = "Dividend" }; var description = "dividend and stuff"; var actual = new TransactionTypeService(null).Matches(description, transaction_match); actual.Should().BeFalse(); }
public void when_matching_for_a_contains_match_and_the_description_is_not_contained_should_return_false() { var transaction_match = new TransactionMatch { TransactionMatchType = TransactionMatchType.ContainsMatch, ContainsMatchString = "Dividend" }; var description = "a diviZdend b"; var actual = new TransactionTypeService(null).Matches(description, transaction_match); actual.Should().BeFalse(); }
public virtual bool Matches(string transaction_description, TransactionMatch match) { if(match.TransactionMatchType == TransactionMatchType.ExactMatch) return match.Description.ToLowerInvariant() == transaction_description.ToLowerInvariant(); if(match.TransactionMatchType == TransactionMatchType.ContainsMatch) return transaction_description.ToLowerInvariant().Contains(match.ContainsMatchString.ToLowerInvariant()); return false; }
public virtual void Execute(TransactionMatch match) { foreach (var transaction in context.BrokerageTransactions) { if (service.Matches(transaction.TransactionDescription, match) && transaction.TransactionType == TransactionType.Missing) transaction.TransactionType = match.TransactionType; } context.SaveChanges(); }
public virtual void Execute(int transaction_id, TransactionMatch transaction_match) { var transaction = context.BrokerageTransactions.Find(transaction_id); if (transaction == null) return; context.TransactionMatches.Add(transaction_match); transaction.TransactionType = transaction_match.TransactionType; context.SaveChanges(); command.Execute(transaction_match); }