public void Execute_Returns_False_Given_Invalid_Command(AddFiscalReceiptCommand command) { var handler = Handler(); var result = handler.Execute(command, new CommandEnvironmentDummy()); Assert.Equal(false, result); }
public bool Execute(AddFiscalReceiptCommand command, ICommandEnvironment environment) { if (command == null || !FiscalReceiptValidator.Validate(command.Receipt)) { return(false); } environment.PublishEvent( new FiscalReceiptAddedEvent( new Data.Events.Dtos.FiscalReceipt( command.Receipt.Number, command.Receipt.TaxPayerName, command.Receipt.TaxPayerAddress, command.Receipt.TaxPayerNip, command.Receipt.AddressOfSalePlace, command.Receipt.NameOfSalePlace, command.Receipt.TimeAndDateOfSale, command.Receipt.Items.Select(ConvertItem).ToList(), command.Receipt.DiscountsAndMarkups.Select(ConvertDiscountOrMarkup).ToList(), command.Receipt.TotalsPerVatRate.ToDictionary(t => t.VatRateLetter, ConvertTotal), command.Receipt.GrossTotal, command.Receipt.VatTotal, command.Receipt.PaymentTotal, command.Receipt.PaymentForm, command.Receipt.CashPaymentChange, command.Receipt.CurrencyCode))); return(true); }
public void Execute_Does_Not_Publish_Events_Given_Invalid_Command(AddFiscalReceiptCommand invalidCommand) { var handler = Handler(); var eventRecorder = new EventRecorder(); handler.Execute(invalidCommand, eventRecorder); eventRecorder.AssertRecordedNoEvents(); }
public FiscalReceiptAddedEventContentsTest() { var handler = Handler(); var eventRecorder = new EventRecorder(); _command = ValidCommand(); handler.Execute(_command, eventRecorder); _event = eventRecorder.FindEvent <FiscalReceiptAddedEvent>(); }