예제 #1
0
 public void RegisterInclude_ShouldAskStorageToStoreIt()
 {
     var include = new Include(IncludeType.Js, "foo.js", "alert('');", DateTime.UtcNow);
     _mockReader.Expect(r => r.Read("~/foo.js", include.Type)).Return(include);
     _mockStorage.Expect(s => s.Store(include));
     _combiner.RegisterInclude("~/foo.js", IncludeType.Js);
     _mocks.VerifyAll();
 }
 public void Store(Include include)
 {
     if (include == null)
     {
         throw new ArgumentNullException("include");
     }
     if (!_includes.ContainsKey(include.Source))
     {
         _includes.Add(include.Source, include);
     }
     else
     {
         _includes[include.Source] = include;
     }
 }
예제 #3
0
        public void RenderIncludes_ShouldWriteOutASingleReferenceToTheCompressorController_WhenInReleaseMode(RenderingInRelease data)
        {
            var stubContext = _mocks.Stub<HttpContextBase>();
            stubContext.Replay();
            stubContext.Expect(c => c.IsDebuggingEnabled).Return(false);
            _mockHttp.Expect(s => s.Context).Return(stubContext);
            _mockSettings.Expect(s => s.Types[data.Type]).Return(data.Settings);
            foreach (var kvp in data.Includes)
            {
                var include = new Include(data.Type, kvp.Key, "foo", DateTime.UtcNow);
                _mockReader.Expect(r => r.Read(kvp.Key, data.Type)).Return(include);
                _mockStorage.Expect(s => s.Store(include));
            }
            _mockReader.Expect(r => r.ToAbsolute(Arg<string>.Is.NotNull)).Return(string.Format("/content/{0}/{1}.{0}", data.Type.ToString().ToLowerInvariant(), data.Key));
            string hash = null;
            _mockStorage.Expect(s => hash = s.Store(Arg<IncludeCombination>.Is.NotNull)).Return("foo");

            string reference = _combiner.RenderIncludes(data.Includes.Keys, data.Type, false);
            Assert.AreEqual(data.Expected, reference);
        }