Exemplo n.º 1
0
        public void DeleteFoodItem()
        {
            var configurationMock = new Mock<IConfiguration>();
             configurationMock.Setup( x => x.DataSource ).Returns( DataSourceType.XMLFile );
             configurationMock.Setup( x => x.FileName ).Returns( FullTestData.DataFileName );

             FullTestData.Reset();
             HealthTracker.DataRepository.Services.DataRepository dataRepository = new HealthTracker.DataRepository.Services.DataRepository( configurationMock.Object );

             // Make a deep copy of a food item.
             FoodItem fruitSalad = new FoodItem();
             fruitSalad.InitializeData( dataRepository.FindFoodItem( f => f.Name == "Fruit Salad" ) );

             // Delete the food item.  Show that the food item has been deleted, but none of the
             // other data repository items have not been effected.
             Int32 origFoodGroupCount = dataRepository.GetAllFoodGroups().Count;
             Int32 origFoodItemCount = dataRepository.GetAllFoodItems().Count;
             Int32 origMealTypeCount = dataRepository.GetAllMealTypes().Count;
             Int32 origMealTemplateCount = dataRepository.GetAllMealTemplates().Count;
             Int32 origMealCount = dataRepository.GetAllMeals().Count;
             dataRepository.Remove( fruitSalad );
             Assert.AreEqual( origFoodGroupCount, dataRepository.GetAllFoodGroups().Count );
             Assert.AreEqual( origFoodItemCount - 1, dataRepository.GetAllFoodItems().Count );
             Assert.AreEqual( origMealTypeCount, dataRepository.GetAllMealTypes().Count );
             Assert.AreEqual( origMealTemplateCount, dataRepository.GetAllMealTemplates().Count );
             Assert.AreEqual( origMealCount, dataRepository.GetAllMeals().Count );
             Assert.IsNotNull( fruitSalad.ID );
             Assert.IsNull( dataRepository.FindFoodItem( f => f.ID == fruitSalad.ID ) );
        }
Exemplo n.º 2
0
        public void DeleteMeal()
        {
            var configurationMock = new Mock<IConfiguration>();
             configurationMock.Setup( x => x.DataSource ).Returns( DataSourceType.XMLFile );
             configurationMock.Setup( x => x.FileName ).Returns( FullTestData.DataFileName );

             FullTestData.Reset();
             var dataRepository = new HealthTracker.DataRepository.Services.DataRepository( configurationMock.Object );

             // Make a deep copy of a meal
             var chzBurgerMealID = new Guid( "FEB4A1B2-796F-11E0-BB69-31B74724019B" );
             var chzBurgerMeal = new Meal();
             chzBurgerMeal.InitializeData( dataRepository.FindMeal( m => m.ID == chzBurgerMealID ) );
             Assert.IsNotNull( chzBurgerMeal );

             // Delete the meal.  Show that the meal has been deleted, but none of the
             // other data repository items have not been effected.
             Int32 origFoodGroupCount = dataRepository.GetAllFoodGroups().Count;
             Int32 origFoodItemCount = dataRepository.GetAllFoodItems().Count;
             Int32 origMealTypeCount = dataRepository.GetAllMealTypes().Count;
             Int32 origMealTemplateCount = dataRepository.GetAllMealTemplates().Count;
             Int32 origMealCount = dataRepository.GetAllMeals().Count;
             dataRepository.Remove( chzBurgerMeal );
             Assert.AreEqual( origFoodGroupCount, dataRepository.GetAllFoodGroups().Count );
             Assert.AreEqual( origFoodItemCount, dataRepository.GetAllFoodItems().Count );
             Assert.AreEqual( origMealTypeCount, dataRepository.GetAllMealTypes().Count );
             Assert.AreEqual( origMealTemplateCount, dataRepository.GetAllMealTemplates().Count );
             Assert.AreEqual( origMealCount - 1, dataRepository.GetAllMeals().Count );
             Assert.IsNotNull( chzBurgerMeal.ID );
             Assert.IsNull( dataRepository.FindMealTemplate( mt => mt.ID == chzBurgerMeal.ID ) );
        }
Exemplo n.º 3
0
        public void DeleteMealType()
        {
            var configurationMock = new Mock<IConfiguration>();
             configurationMock.Setup( x => x.DataSource ).Returns( DataSourceType.XMLFile );
             configurationMock.Setup( x => x.FileName ).Returns( FullTestData.DataFileName );

             FullTestData.Reset();
             HealthTracker.DataRepository.Services.DataRepository dataRepository = new HealthTracker.DataRepository.Services.DataRepository( configurationMock.Object );

             // Make a deep copy of a currentMealTemplate type
             MealType lunch = new MealType();
             lunch.InitializeData( dataRepository.FindMealType( mt => mt.Name == "Lunch" ) );
             Assert.IsNotNull( lunch );

             // Delete the meal type.  Show that the meal type has been deleted, but none of the
             // other data repository items have not been effected.
             Int32 origFoodGroupCount = dataRepository.GetAllFoodGroups().Count;
             Int32 origFoodItemCount = dataRepository.GetAllFoodItems().Count;
             Int32 origMealTypeCount = dataRepository.GetAllMealTypes().Count;
             Int32 origMealTemplateCount = dataRepository.GetAllMealTemplates().Count;
             Int32 origMealCount = dataRepository.GetAllMeals().Count;
             dataRepository.Remove( lunch );
             Assert.AreEqual( origFoodGroupCount, dataRepository.GetAllFoodGroups().Count );
             Assert.AreEqual( origFoodItemCount, dataRepository.GetAllFoodItems().Count );
             Assert.AreEqual( origMealTypeCount - 1, dataRepository.GetAllMealTypes().Count );
             Assert.AreEqual( origMealTemplateCount, dataRepository.GetAllMealTemplates().Count );
             Assert.AreEqual( origMealCount, dataRepository.GetAllMeals().Count );
             Assert.IsNotNull( lunch.ID );
             Assert.IsNull( dataRepository.FindMealTemplate( mt => mt.ID == lunch.ID ) );
        }