Ejemplo n.º 1
0
        public void Returns_same_string_when_database_is_empty()
        {
            var adapter = new InMemoryAdapter();
            Database.UseMockAdapter(adapter);

            var slugManager = new SlugManager();

            var input = "a-new-slug";
            var uniqueSlug = slugManager.GetUniqueSlug(input);

            Assert.AreEqual(input, uniqueSlug);
        }
Ejemplo n.º 2
0
        public void Returns_same_string_when_slug_is_not_found()
        {
            var adapter = new InMemoryAdapter();
            Database.UseMockAdapter(adapter);

            var db = Database.Open();
            db.Posts.Insert(Title: "A title", UrlSlug: "a-slug", IsPublised: false, CreatedOn: DateTime.UtcNow, LastUpdatedOn: DateTime.UtcNow);

            var slugManager = new SlugManager();

            var input = "a-new-slug";
            var uniqueSlug = slugManager.GetUniqueSlug(input);

            Assert.AreEqual(input, uniqueSlug);
        }
Ejemplo n.º 3
0
        public void Increments_slug_when_it_already_exists()
        {
            var adapter = new InMemoryAdapter();
            Database.UseMockAdapter(adapter);

            var db = Database.Open();
            db.Posts.Insert(Title: "A title", UrlSlug: "a-slug", IsPublised: false, CreatedOn: DateTime.UtcNow, LastUpdatedOn: DateTime.UtcNow);

            var slugManager = new SlugManager();

            var input = "a-slug";
            var uniqueSlug = slugManager.GetUniqueSlug(input);

            Assert.AreEqual("a-slug-2", uniqueSlug);
        }