Exemple #1
0
        public void Save_After_IsModifiedShouldBeFalse()
        {
            // arrange
            string path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            RecipeRepository repository = new RecipeRepository(path);
            typeof(RecipeRepository).GetProperty("IsModified").SetValue(repository, true);

            try
            {
                // act
                repository.Save();

                // assert
                Assert.IsFalse(repository.IsModified);
            }
            finally
            {
                // clean up
                File.Delete(path);
            }
        }
Exemple #2
0
        public void Save_After_ShouldFireRecipesChangeEvent()
        {
            // arrange
            string path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            RecipeRepository repository = new RecipeRepository(path);
            bool eventHandled = false;
            repository.RecipesChangedEvent += (s, e) => { eventHandled = true; };

            try
            {
                // act
                repository.Save();

                // assert
                Assert.IsTrue(eventHandled);
            }
            finally
            {
                // clean up
                File.Delete(path);
            }
        }
Exemple #3
0
        public void Save_After_FileShouldBeCreated()
        {
            // arrange
            string path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            RecipeRepository repository = new RecipeRepository(path);

            try
            {
                // act
                repository.Save();

                // assert
                Assert.IsTrue(File.Exists(path));
            }
            finally
            {
                // clean up
                File.Delete(path);
            }
        }