public void GetTab_Should_Return_A_Tab_from_database_when_cache_is_empty_and_then_caches_it()
		{
			var cache = new Mock<ICache>();
			var database = new Mock<IDatabase>();
			ITabRepository pageRepository = new TabRepository(database.Object, cache.Object);

			const int pageId = 1;
			var page = default(Tab);
			var sampleTab = new Tab() { ID = pageId, Title = "Test Tab", ColumnCount = 3, LayoutType = 3, VersionNo = 1, PageType = (int)Enumerations.PageType.PersonalTab, CreatedDate = DateTime.Now };

			database
					.Expect<IQueryable<Tab>>(d => d.Query<int, Tab>(CompiledQueries.TabQueries.GetTabById, 1))
					.Returns(new Tab[] { sampleTab }.AsQueryable()).Verifiable();

			"Given TabRepository and empty cache".Context(() =>
			{
				// cache is empty
				cache.Expect(c => c.Get(It.IsAny<string>())).Returns(default(object));
				// It will cache the Tab object afte loading from database
				cache.Expect(c => c.Add(It.Is<string>(cacheKey => cacheKey == CacheKeys.TabKeys.TabId(pageId)),
						It.Is<Tab>(cacheTab => object.ReferenceEquals(cacheTab, sampleTab)))).Verifiable();
			});

			"when GetTabById is called".Do(() =>
					page = pageRepository.GetTabById(1));

			"it checks in the cache first and finds nothing and then caches it".Assert(() =>
					cache.VerifyAll());


			"it loads the page from database".Assert(() =>
					database.VerifyAll());

			"it returns the page as expected".Assert(() =>
			{
				Assert.Equal<int>(pageId, page.ID);
			});
		}
		public void GetTab_Should_Return_A_Tab_from_cache_when_it_is_already_cached()
		{
			var cache = new Mock<ICache>();
			var database = new Mock<IDatabase>();
			ITabRepository pageRepository = new TabRepository(database.Object, cache.Object);

			const int pageId = 1;
			var page = default(Tab);
			var sampleTab = new Tab() { ID = pageId, Title = "Test Tab", ColumnCount = 3, LayoutType = 3, VersionNo = 1, 
                PageType = (int)Enumerations.PageType.PersonalTab, CreatedDate = DateTime.Now };

			"Given TabRepository and the requested page in cache".Context(() =>
			{
				cache.Expect(c => c.Get(CacheKeys.TabKeys.TabId(sampleTab.ID)))
						.Returns(sampleTab).AtMostOnce();
			});

			"when GetTabById is called".Do(() =>
					page = pageRepository.GetTabById(1));

			"it checks in the cache first and finds the object is in cache".Assert(() =>
			{
				cache.VerifyAll();
			});

			"it returns the page as expected".Assert(() =>
			{
				Assert.Equal<int>(pageId, page.ID);
			});
		}