public Cookbookology.Domain.Cookbook ConvertToCommon(Cookbookology.Formats.MyCookbook.Cookbook mcb)
        {
            var cookbook = new Cookbookology.Domain.Cookbook
            {
                Version = mcb.Version.ToString(),
            };

            foreach (var mcbRecipe in mcb.Recipes)
            {
                var recipe = new Cookbookology.Domain.Recipe()
                {
                    Categories = (mcbRecipe.Categories == null) ? new List<string>() : new List<string>(mcbRecipe.Categories.Split(new [] {','})),
                    AdditionalComments = mcbRecipe.Comments,
                    CookingTime = mcbRecipe.CookTime,
                    ImagePath = mcbRecipe.ImagePath,
                    Ingredients = (mcbRecipe.Ingredients == null) ? new List<string>() : mcbRecipe.Ingredients.Select(i =>i.NameAndAmount).ToList(),
                    PreparationTime = mcbRecipe.PrepTime,
                    Servings = mcbRecipe.Quantity,
                    SourceUri = mcbRecipe.SourceUri,
                    Instructions = string.Join("\r\n", mcbRecipe.TextLines),
                    Title = mcbRecipe.Title,
                };

                cookbook.Recipes.Add(recipe);
            }

            return cookbook;
        }
        public Cookbookology.Domain.Cookbook Read(Stream inputStream)
        {
            if (inputStream == null) throw new ArgumentNullException("inputStream");

            var cookbook = new Cookbookology.Domain.Cookbook();

            using (var zip = new ZipFile(inputStream))
            {
                var decompressed = zip.GetInputStream(0); // Only one file in a MCB zip.

                var s = new XmlSerializer(typeof(Cookbook));
                var mcb = (Cookbook) s.Deserialize(decompressed);

                var converter = new MyCookbookConverter();
                cookbook = converter.ConvertToCommon(mcb);
            }

            return cookbook;
        }
        public void RoundTripConversionTestCommonToMcb()
        {
            // arrange
            var cookbook = new Cookbookology.Domain.Cookbook { Version = "4" };

            cookbook.Recipes.Add
            (
                new Cookbookology.Domain.Recipe
                {
                    AdditionalComments = "These taste great on a cold morning!",
                    Categories = new List<string> { "Breakfast", "French" },
                    CookingTime = "20 min",
                    ImagePath = @"/mnt/sdcard/MyCookBook/images/crepes.png",
                    Ingredients = new List<string> { "1 1/2 c. flour", "2 c. milk", "2 eggs", "1 1/2 tbsp. oil", "1 tbsp. sugar", "Little salt melted" },
                    Instructions = @"Pour the milk into the flour. Stir.
            Add the oil, the beaten eggs and the sugar. Stir again.
            Let the batter rest for 2 hours. The batter must be fluid. If not, add a little more milk.

            Take a frying pan, oil it and pour a small amount of batter and spread it on the bottom. Cook it on one side, then the other.
            The ""French Crepes"" must be very thin.
            You can put butter or sugar or jelly or melted chocolate on them.",
                    PreparationTime = "10 min",
                    Servings = "10 crepes",
                    SourceUri = "http://test.com",
                    Title = "Crepes",
                }
            );

            // act
            var converter = new MyCookbookConverter();
            var mcb = converter.ConvertFromCommon(cookbook);
            var resultCookbook = converter.ConvertToCommon(mcb);

            // assert
            CookbookAssert.AreEqual(cookbook, resultCookbook);
        }