Inheritance: IStreamStorage
        public void Given_Existing_10_Items_GetLatest_Returns_All_10_Items()
        {
            var noLimit = int.MaxValue;
            var items = BuildItems(count: 10);
            this.Items.InsertBatch(items);

            var storage = new StreamStorage(ConnectionString, DatabaseName);

            var gotItems = storage.GetLatest(noLimit).ToList();

            Assert.That(items.Count, Is.EqualTo(gotItems.Count));
        }
        public void Given_Existing_10_Items_GetLatest_Returns_Limited_Number_Of_5_Items()
        {
            var limit = 5;
            var items = BuildItems(count: 10);
            this.Items.InsertBatch(items);

            var storage = new StreamStorage(ConnectionString, DatabaseName);

            var gotItems = storage.GetLatest(limit).ToList();

            Assert.AreEqual(limit, gotItems.Count);
        }
        public void Given_Existing_10_Items_GetNewer_Returns_Items_Newer_Than_Given_Oldest_Item()
        {
            var items = BuildItems(count: 10);
            var oldestItem = items.First();
            var numberOfItems = items.Count - 1;
            this.Items.InsertBatch(items);

            var storage = new StreamStorage(ConnectionString, DatabaseName);

            var gotItems = storage.GetNewer(oldestItem, items.Count).ToList();

            Assert.AreEqual(numberOfItems, gotItems.Count);
        }
        public void Given_Existing_10_Items_GetLatest_Returns_Them_Sorted_By_Date_Descending()
        {
            var noLimit = int.MaxValue;
            var items = BuildItems(count: 10);
            this.Items.InsertBatch(items);

            var storage = new StreamStorage(ConnectionString, DatabaseName);

            var gotItems = storage.GetLatest(noLimit).ToList();

            Assert.That(gotItems, Is.Ordered.Descending.By("Published"));
        }
        public void ItemStorage_Can_Save_5_Modified_Items_And_Retrieve_Them_Back()
        {
            this.Items.InsertBatch(BuildItems(count: 5));

            var items = this.Items.AsQueryable().ToList();
            foreach (var item in items)
            {
                item.Tags = new[] { "test" };
            }

            var storage = new StreamStorage(ConnectionString, DatabaseName);

            storage.Save(items);

            var savedItems = this.Items.AsQueryable().ToList();

            foreach (var item in savedItems)
            {
                Assert.IsTrue(item.Tags.Contains("test"));
            }
        }
        public void ItemStorage_Can_Save_5_New_And_5_Modified_Items()
        {
            this.Items.InsertBatch(BuildItems(count: 5));

            var existingItems = this.Items.AsQueryable().ToList();
            foreach (var item in existingItems)
            {
                item.Tags = new[] { "test" };
            }

            var newItems = BuildItems(count: 5);
            var items = existingItems.Union(newItems).ToList();

            var storage = new StreamStorage(ConnectionString, DatabaseName);

            storage.Save(items);

            var savedItems = this.Items.AsQueryable().ToList();

            Assert.That(items.Count(), Is.EqualTo(savedItems.Count));
        }
        public void ItemStorage_Can_Save_10_New_Items()
        {
            var items = BuildItems(count: 10);

            var storage = new StreamStorage(ConnectionString, DatabaseName);

            storage.Save(items);

            var savedItems = this.Items.AsQueryable().ToList();

            Assert.That(items.Count, Is.EqualTo(savedItems.Count));
        }
        public void Given_Non_Valid_Id_Get_Returns_Null()
        {
            var storage = new StreamStorage(ConnectionString, DatabaseName);

            var gotItem = storage.Get("id");

            Assert.IsNull(gotItem);
        }
 public void Given_MongoDB_Is_Running_ItemStorage_Can_Successfully_Connect()
 {
     var storage = new StreamStorage(ConnectionString, DatabaseName);
     Assert.IsNotNull(storage);
 }
Esempio n. 10
0
        public void Given_Existing_Item_Get_Returns_It_By_Id()
        {
            var item = BuildItems(count: 1).Single();
            this.Items.Insert(item);

            var storage = new StreamStorage(ConnectionString, DatabaseName);

            var gotItem = storage.Get(item.Id);

            Assert.IsNotNull(gotItem);
            Assert.AreEqual(item.Url, gotItem.Url);
        }
Esempio n. 11
0
        public void Given_Existing_10_Items_Top_Returns_Most_Recent_Item()
        {
            var items = BuildItems(count: 10);
            var latestItem = items.Last();
            this.Items.InsertBatch(items);

            var storage = new StreamStorage(ConnectionString, DatabaseName);

            var gotItem = storage.Top();

            Assert.That(latestItem.Id, Is.EqualTo(gotItem.Id));
        }