public void AllFoodItemsViewModelContainsAllFoods()
        {
            var data = new MockData();
             var dataRespositoryMock = CreateMockDataRepository( data.Foods() );

             var viewModel = new AllFoodItemsViewModel( dataRespositoryMock.Object );

             AssertViewModelContents( viewModel, data.Foods() );
             dataRespositoryMock.VerifyAll();
        }
        public void FoodItemRemovedFromViewModelWhenRemovedFromRepository()
        {
            var data = new MockData();
             var dataRespositoryMock = CreateMockDataRepository( data.Foods() );

             var viewModel = new AllFoodItemsViewModel( dataRespositoryMock.Object );
             var food = data.Foods().Find( mt => mt.ID == MockData.baconCheeseBurgerID );
             data.Foods().Remove( food );
             dataRespositoryMock.Raise( e => e.ItemDeleted += null, new RepositoryObjectEventArgs( food ) );

             AssertViewModelContents( viewModel, data.Foods() );
        }
        public void FoodItemModifiedInViewModelWhenChangedInRepository()
        {
            var data = new MockData();
             var dataRespositoryMock = CreateMockDataRepository( data.Foods() );
             var viewModel = new AllFoodItemsViewModel( dataRespositoryMock.Object );

             var food = data.Foods().Find( f => f.ID == MockData.baconCheeseBurgerID );
             food.Name += " Unit Test";
             dataRespositoryMock.Raise( e => e.ItemModified += null, new RepositoryObjectEventArgs( food ) );

             AssertViewModelContents( viewModel, data.Foods() );
        }
        public void FoodItemAddedToViewModelWhenAddedToRepository()
        {
            var data = new MockData();
             var dataRespositoryMock = CreateMockDataRepository( data.Foods() );

             var viewModel = new AllFoodItemsViewModel( dataRespositoryMock.Object );
             var food = new FoodItem( Guid.NewGuid(), "New Type", "For a unit test", 42.0M );
             data.Foods().Add( food );
             dataRespositoryMock.Raise( e => e.ItemAdded += null, new RepositoryObjectEventArgs( food ) );

             AssertViewModelContents( viewModel, data.Foods() );
        }