Exemplo n.º 1
0
        public void ShouldCreateRepositoryItemWithDefaultValues()
        {
            string repositoryFile             = Path.GetTempFileName();
            RegexRepositoryService repository = new RegexRepositoryService(repositoryFile);
            RegexRepositoryItem    item       = repository.CreateItem("foo", "bar");

            Assert.IsNotNull(item);

            Assert.AreEqual("foo", item.Title);
            Assert.AreEqual(Environment.UserName, item.Author);
            Assert.AreEqual("default", item.Category);
            Assert.AreEqual("foo", item.Description);
            Assert.AreEqual("", item.Matches);
            Assert.AreEqual("bar", item.Regex);
        }
Exemplo n.º 2
0
        public void ShouldSaveNewRepositoryItem()
        {
            string repositoryFile             = Path.GetTempFileName();
            RegexRepositoryService repository = new RegexRepositoryService(repositoryFile, false);

            RegexRepositoryItem item = repository.CreateItem("foo", "bar");

            repository.Save(item);

            // Create the repository again to check if it loads the saved item
            repository = new RegexRepositoryService(repositoryFile, true);

            Assert.IsNotNull(repository.Items);
            Assert.AreEqual(1, repository.Items.Count());
            Assert.AreEqual("foo", repository.Items.First().Title);
            Assert.AreEqual("bar", repository.Items.First().Regex);
        }