Esempio n. 1
0
        public void TestFillingRemovesInventoryIfEnought()
        {
            //Setup - creating data

            //Creating SUT
            Order order = new Order(ProductType.Whiskey, 50);
            //Creates proxy-object a.k.a mock that implements IWarehouse interface.
            IWarehouse warehouse = MockRepository.GenerateStrictMock <IWarehouse>();

            //Setup - adding expectations

            //Setup mock object's expectations at ordered mode - i.e. order of expected calls will be verified too.
            using (warehouse.GetMockRepository().Ordered())
            {
                //Setup expect of call GetInventory with parameter ProductType.Whiskey
                warehouse.Expect(wh => wh.HasInventory(ProductType.Whiskey, 50m)).Return(true).Repeat.Once();
                warehouse.Expect(wh => wh.RemoveInventory(ProductType.Whiskey, 50m)).Repeat.Once();
            }

            order.Fill(warehouse);

            warehouse.VerifyAllExpectations();
            Assert.True(order.IsFilled);
        }