示例#1
0
        public void SubmitOrder_InvalidOrder_DoesNotCallSaveOrder()
        {
            // arrange
            var mockRepository = new MockOrderRepository();
            var stubValidator  = new StubOrderValidator(false);
            var service        = new OrderService(mockRepository, stubValidator);
            var order          = new Order
            {
                Id = Guid.NewGuid()
            };

            // act
            service.SubmitOrder(order);

            // assert
            Assert.IsNull(mockRepository.SavedOrder);
        }
示例#2
0
        public void SubmitOrder_ValidOrder_CallsSaveOrder()
        {
            // arrange
            var mockRepository = new MockOrderRepository();
            var stubValidator  = new StubOrderValidator(true);
            var service        = new OrderService(mockRepository, stubValidator);
            var order          = new Order
            {
                Id = Guid.NewGuid()
            };

            // act
            service.SubmitOrder(order);

            // assert
            Assert.IsNotNull(mockRepository.SavedOrder);
            Assert.AreEqual(mockRepository.SavedOrder.Id, order.Id);
        }