public void SubmittingBadTransactionDoesNotEmitEvent()
        {
            var emitter = new FakeEventEmitter();
            var service = new OrderCommandImpl(emitter, null);
            var tx      = GenerateFakeTransaction(false);

            var result = service.SubmitOrder(tx, null).Result;

            Assert.False(result.Accepted);
            Assert.Equal(0, emitter.EmittedTransactions.Count);
        }
        public void FailureToEmitResultsInUnacceptedTransaction()
        {
            var emitter = new FakeEventEmitter();

            emitter.NextEmitResult = false;
            var service = new OrderCommandImpl(emitter, null);
            var tx      = GenerateFakeTransaction(true);

            var result = service.SubmitOrder(tx, null).Result;

            Assert.False(result.Accepted);
            Assert.Equal(0, emitter.EmittedTransactions.Count);
        }
        public void SubmittingValidTransactionInvokesEmitter()
        {
            var emitter = new FakeEventEmitter();
            var service = new OrderCommandImpl(emitter, null);
            var tx      = GenerateFakeTransaction(true);

            var result = service.SubmitOrder(tx, null).Result;

            Assert.True(result.Accepted);
            Assert.NotNull(result.OrderID);
            Assert.Equal(1, emitter.EmittedTransactions.Count);
            Assert.Equal(2, emitter.EmittedInventoryReservedEvents.Count);
            Assert.Equal("ABC123", emitter.EmittedInventoryReservedEvents[0].SKU);
            Assert.Equal("FYI555", emitter.EmittedInventoryReservedEvents[1].SKU);
            Assert.Equal((uint)5, emitter.EmittedInventoryReservedEvents[1].Quantity);
        }