public void AddCacheDependencies_NoCacheItem_CreatesAndAddsNewList()
        {
            // Arrange
            var context = new HttpContextWrapper(new HttpContext(new HttpRequest(null, "http://tempuri.org/", null), new HttpResponse(null)));

            var controller   = new DesignerController();
            var dependencies = new List <CacheDependencyKey>();

            var depKey1 = new CacheDependencyKey {
                Key = "mykey1", Type = this.GetType()
            };
            var depKey2 = new CacheDependencyKey {
                Key = "mykey2", Type = this.GetType()
            };

            dependencies.Add(depKey1);
            dependencies.Add(depKey2);

            // Act
            SystemManager.RunWithHttpContext(context, () => controller.AddCacheDependencies(dependencies));

            // Assert
            var cacheObject = context.Items[PageCacheDependencyKeys.PageData];

            Assert.IsNotNull(cacheObject, "No cache object was set in the context.");
            Assert.IsTrue(cacheObject is IList <CacheDependencyKey>, "The cache object was not of the expected type.");

            var cacheList = (IList <CacheDependencyKey>)cacheObject;

            Assert.IsTrue(cacheList.Contains(depKey1), "The first cache dependency was not added.");
            Assert.IsTrue(cacheList.Contains(depKey2), "The second cache dependency was not added.");
            Assert.AreEqual(dependencies.Count, cacheList.Count, "There is an unexpected count of cache dependency keys.");
        }
        public void AddCacheDependencies_NullKeys_ThrowsArgumentNullException()
        {
            Controller controller = new DesignerController();

            /// TODO: fix always is null expression
            controller.AddCacheDependencies(null);
        }
        public void AddCacheDependencies_NullContext_ThrowsInvalidOperationException()
        {
            Assert.IsNull(SystemManager.CurrentHttpContext, "Current HttpContext is expected to be null in unit tests but here it is not!");

            Controller controller = new DesignerController();

            controller.AddCacheDependencies(new CacheDependencyKey[0]);
        }
        public void AddCacheDependencies_NullKeys_ThrowsArgumentNullException()
        {
            Controller controller = new DesignerController();

            controller.AddCacheDependencies(null);
        }