public void ExportsAndImportsMealsAndMealNamesAndProductsAndCategories()
 {
     var meal = factories.Meals[0];
     var mealName = factories.MealNames[0];
     var product = factories.Products[0];
     var category = factories.Categories[0];
     var sut = new ExportAndImportImpl(factories);
     var data = sut.Export();
     factories.Meals.Clear();
     factories.MealNames.Clear();
     factories.Products.Clear();
     factories.Categories.Clear();
     var empty = new Meal();
     empty.InitializeItems(new List<MealItem>());
     meal.CopyItemsFrom(empty);
     Assert.IsEmpty(meal.Items);
     sut.Import(data);
     Assert.AreEqual(meal.Id, factories.Meals[0].Id);
     Assert.AreEqual(meal.Items[0].Value, factories.Meals[0].Items[0].Value);
     Assert.AreEqual(mealName.Id, factories.MealNames[0].Id);
     Assert.AreEqual(product.Id, factories.Products[0].Id);
     Assert.AreEqual(category.Id, factories.Categories[0].Id);
     sut.Import(data);
     Assert.AreEqual(1, factories.Meals.Count);
     Assert.AreEqual(1, factories.MealNames.Count);
     Assert.AreEqual(1, factories.Products.Count);
     Assert.AreEqual(1, factories.Categories.Count);
 }
 public void ImportsDefaultSettingWhenSettingNotExported()
 {
     factories.Settings.SugarsAfterInsulinHours = 0;
     var sut = new ExportAndImportImpl(factories);
     var data = sut.Export();
     var removeThis = "<SugarsAfterInsulinHours>0</SugarsAfterInsulinHours>";
     Assert.IsTrue(data.Contains(removeThis), "This is requirement to perform test");
     data = data.Replace(removeThis, string.Empty);
     sut.Import(data);
     Assert.AreNotEqual(0, factories.Settings.SugarsAfterInsulinHours);
 }
 public void ExportsAndImportsSugarsAndInsulinsAndInsulinCircumstances()
 {
     var sugar = factories.Sugars[0];
     var insulin = factories.Insulins[0];
     var insulinCircumstance = factories.InsulinCircumstances[0];
     var sut = new ExportAndImportImpl(factories);
     var data = sut.Export();
     factories.Sugars.Clear();
     factories.Insulins.Clear();
     factories.InsulinCircumstances.Clear();
     var empty = new Insulin();
     empty.InitializeCircumstances(new List<Guid>());
     insulin.CopyCircumstancesFrom(empty);
     Assert.IsEmpty(insulin.Circumstances);
     sut.Import(data);
     Assert.AreEqual(sugar.Id, factories.Sugars[0].Id);
     Assert.AreEqual(insulin.Id, factories.Insulins[0].Id);
     Assert.AreSame(factories.InsulinCircumstances[0], factories.Insulins[0].Circumstances.Single());
     Assert.AreEqual(insulinCircumstance.Id, factories.InsulinCircumstances[0].Id);
     sut.Import(data);
     Assert.AreEqual(1, factories.Sugars.Count);
     Assert.AreEqual(1, factories.Insulins.Count);
     Assert.AreEqual(1, factories.InsulinCircumstances.Count);
 }