Esempio n. 1
0
        public void Cancel_calls_event_bus_with_assertions()
        {
            var entityUnderTest = new PurchaseOrderController(_mockedRepository, _mockedBus, _mockedSessionData);

            entityUnderTest.Cancel(100);

            _mockedBus.Received(1)
            .PushPurchaseOrderCanceledEvent(
                Arg.Is <PurchaseOrderCanceledInfo>(x => PurchaseOrderCancelInfoIsExpected(x)));
        }
Esempio n. 2
0
        public void Cancel_saves_PurchaseOrder()
        {
            var entityUnderTest = new PurchaseOrderController(_mockedRepository, _mockedBus, _mockedSessionData);

            entityUnderTest.Cancel(100);

            // NSubstitute checks its mocked object and throws an exception if no such a call was received
            // If the lambda expression is evaluated to true, it will be successful, otherwise an exception is thrown
            _mockedRepository.Received(1).SavePurchaseOrder(Arg.Is <PurchaseOrder>(x => x.Canceled && x.Id == 100));
        }
Esempio n. 3
0
        public void Cancel_calls_event_bus_lambda()
        {
            var entityUnderTest = new PurchaseOrderController(_mockedRepository, _mockedBus, _mockedSessionData);

            entityUnderTest.Cancel(100);

            _mockedBus.Received(1).PushPurchaseOrderCanceledEvent(Arg.Is <PurchaseOrderCanceledInfo>(x =>
                                                                                                     x.PurchaseOrderId == 100 &&
                                                                                                     x.CustomerId == 5 &&
                                                                                                     x.Amount == 1200 &&
                                                                                                     x.SessionId == 5550 &&
                                                                                                     x.Timestamp.Date == DateTime.Now.Date));
        }