本文整理汇总了C#中TestableBundle类的典型用法代码示例。如果您正苦于以下问题:C# TestableBundle类的具体用法?C# TestableBundle怎么用?C# TestableBundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestableBundle类属于命名空间,在下文中一共展示了TestableBundle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ConcatenateAssetsMergesAssetReferences
public void ConcatenateAssetsMergesAssetReferences()
{
var bundle = new TestableBundle("~");
var asset1 = new Mock<IAsset>();
var asset2 = new Mock<IAsset>();
asset1.Setup(a => a.OpenStream()).Returns(() => "asset1".AsStream());
asset1.SetupGet(a => a.References).Returns(new[]
{
new AssetReference("~\\other1.js", asset1.Object, 0, AssetReferenceType.DifferentBundle)
});
asset2.Setup(a => a.OpenStream()).Returns(() => "asset2".AsStream());
asset2.SetupGet(a => a.References).Returns(new[]
{
new AssetReference("~\\other1.js", asset2.Object, 0, AssetReferenceType.DifferentBundle),
new AssetReference("~\\other2.js", asset2.Object, 0, AssetReferenceType.DifferentBundle)
});
bundle.Assets.Add(asset1.Object);
bundle.Assets.Add(asset2.Object);
var processor = new ConcatenateAssets();
processor.Process(bundle, new CassetteSettings(""));
bundle.Assets[0].References
.Select(r => r.Path)
.OrderBy(f => f)
.SequenceEqual(new[] { "~\\other1.js", "~\\other1.js", "~\\other2.js" })
.ShouldBeTrue();
}
开发者ID:nlerikheemskerk,项目名称:cassette,代码行数:28,代码来源:ConcatenateAssets.cs
示例2: DiskBackedBundleCache_Tests
public DiskBackedBundleCache_Tests()
{
//The directory should never be called, always just passed into FileHelper which is mocked also, so strict
//with nothing setup
directory = new Mock<IDirectory>(MockBehavior.Strict);
fileHelper = new Mock<IFileHelper>(MockBehavior.Strict);
fileHelper.Setup(fh => fh.PrepareCachingDirectory(It.IsAny<string>(), It.IsAny<string>()));
fileHelper.Setup(fh => fh.CreateDirectory(It.IsAny<string>()));
uncachedToCachedFiles = new Mock<IDictionary<string, string>>(MockBehavior.Strict);
diskBackedBundleCache = new DiskBackedBundleCache(fileHelper.Object);
unprocessedAssetPaths = new List<string>();
fileBundle = new TestableBundle("~/file");
concatenatedBundle = new TestableBundle("~/concatenated");
emptyBundle = new TestableBundle("~/empty");
var stubFileCreation = typeof(Asset_Tests).GetMethod("StubFile", BindingFlags.NonPublic | BindingFlags.Instance);
fileAsset = new FileAsset((IFile)stubFileCreation.Invoke(new Asset_Tests(), new object[] { "asset content", Type.Missing }), fileBundle);
fileBundle.Assets.Add(fileAsset);
var file = (IFile)stubFileCreation.Invoke(new Asset_Tests(), new object[] { "asset content", Type.Missing });
fileHelper.Setup(fh => fh.GetFileSystemFile(It.IsAny<IDirectory>(), It.IsAny<string>(), It.IsAny<string>()))
.Returns(file);
concatenatedAsset = new ConcatenatedAsset(new List<IAsset> {fileAsset} );
concatenatedBundle.Assets.Add(concatenatedAsset);
AddToDiskMethodInfo = typeof(DiskBackedBundleCache).GetMethod("AddToDisk", BindingFlags.NonPublic | BindingFlags.Instance);
GetFromDiskMethodInfo = typeof(DiskBackedBundleCache).GetMethod("GetFromDisk", BindingFlags.NonPublic | BindingFlags.Instance);
}
开发者ID:Zocdoc,项目名称:cassette,代码行数:25,代码来源:DiskBackedBundleCache.cs
示例3: GivenCacheIsUpToDate_WhenInitializeBundlesFromCacheIfUpToDate_ThenBundleAssetsReplacedWithCachedAsset
public void GivenCacheIsUpToDate_WhenInitializeBundlesFromCacheIfUpToDate_ThenBundleAssetsReplacedWithCachedAsset()
{
using (var cacheDir = new TempDirectory())
{
File.WriteAllText(
Path.Combine(cacheDir, "container.xml"),
"<?xml version=\"1.0\"?><Container Version=\"VERSION\" AssetCount=\"1\"><Bundle Path=\"~/test\" Hash=\"01\"/></Container>"
);
File.WriteAllText(
Path.Combine(cacheDir, "test.bundle"),
"asset"
);
var bundleWithAsset = new TestableBundle("~/test");
var asset = StubAsset();
bundleWithAsset.Assets.Add(asset.Object);
var sourceBundles = new[] { bundleWithAsset };
var settings = new CassetteSettings
{
SourceDirectory = Mock.Of<IDirectory>(),
CacheDirectory = new FileSystemDirectory(cacheDir)
};
var cache = new BundleCache("VERSION", settings);
var result = cache.InitializeBundlesFromCacheIfUpToDate(sourceBundles);
result.ShouldBeTrue();
bundleWithAsset.Assets[0].OpenStream().ReadToEnd().ShouldEqual("asset");
}
}
开发者ID:prasanths,项目名称:cassette,代码行数:29,代码来源:BundleCache.cs
示例4: GivenBundleAdded_WhenGetByPartialPath_ThenBundleReturned
public void GivenBundleAdded_WhenGetByPartialPath_ThenBundleReturned()
{
var bundle = new TestableBundle("~/test");
bundles.Add(bundle);
var actualBundle = bundles.Get("test");
actualBundle.ShouldBeSameAs(bundle);
}
开发者ID:nlerikheemskerk,项目名称:cassette,代码行数:9,代码来源:BundleCollection.cs
示例5: GivenBundleAdded_WhenAddAnotherWithSamePath_ThenExceptionIsThrown
public void GivenBundleAdded_WhenAddAnotherWithSamePath_ThenExceptionIsThrown()
{
var bundle = new TestableBundle("~/test");
bundles.Add(bundle);
Assert.Throws<ArgumentException>(
() => bundles.Add(new TestableBundle("~/test"))
);
}
开发者ID:nlerikheemskerk,项目名称:cassette,代码行数:9,代码来源:BundleCollection.cs
示例6: SetupTestBundle
protected void SetupTestBundle()
{
var bundle = new TestableBundle("~/test");
var asset = new StubAsset("~/asset.js", "asset-content");
bundle.Assets.Add(asset);
bundle.Hash = new byte[] { 1, 2, 3 };
bundles.Add(bundle);
bundles.BuildReferences();
bundle.Process(new CassetteSettings());
}
开发者ID:jlopresti,项目名称:cassette,代码行数:10,代码来源:BundleRequestHandler.cs
示例7: ProcessAddsAssetMinifierToAssetInBundle
public void ProcessAddsAssetMinifierToAssetInBundle()
{
var bundle = new TestableBundle("~");
var asset = new Mock<IAsset>();
bundle.Assets.Add(asset.Object);
processor.Process(bundle);
asset.Verify(a => a.AddAssetTransformer(minifier.Object));
}
开发者ID:jlopresti,项目名称:cassette,代码行数:10,代码来源:MinifyAssets.cs
示例8: GivenBundlesAdded_WhenEnumerated_ThenBundlesReturned
public void GivenBundlesAdded_WhenEnumerated_ThenBundlesReturned()
{
var bundle1 = new TestableBundle("~/test1");
var bundle2 = new TestableBundle("~/test2");
bundles.Add(bundle1);
bundles.Add(bundle2);
var set = new HashSet<Bundle>(bundles);
set.SetEquals(new[] { bundle1, bundle2 }).ShouldBeTrue();
}
开发者ID:nlerikheemskerk,项目名称:cassette,代码行数:11,代码来源:BundleCollection.cs
示例9: GivenCacheOutOfDate_WhenCreateWithBundle_ThenContainerSavedToCache
public void GivenCacheOutOfDate_WhenCreateWithBundle_ThenContainerSavedToCache()
{
var bundles = new TestableBundle[0];
var application = CreateSettings();
CacheIsOutOfDate(bundles);
var factory = CreateFactory();
factory.Create(bundles, application);
cache.Verify(c => c.SaveBundleContainer(It.IsAny<IBundleContainer>()));
}
开发者ID:JamesTryand,项目名称:cassette,代码行数:11,代码来源:CachedBundleContainerFactory.cs
示例10: GivenCacheOutOfDate_WhenCreateWithBundle_ThenBundleIsProcessed
public void GivenCacheOutOfDate_WhenCreateWithBundle_ThenBundleIsProcessed()
{
var bundle = new TestableBundle("~/test");
var bundles = new[] { bundle };
var application = CreateSettings();
CacheIsOutOfDate(bundles);
var factory = CreateFactory();
factory.Create(bundles, application);
bundle.WasProcessed.ShouldBeTrue();
}
开发者ID:JamesTryand,项目名称:cassette,代码行数:12,代码来源:CachedBundleContainerFactory.cs
示例11: RawFileRequestHandler_Tests
public RawFileRequestHandler_Tests()
{
var bundle = new TestableBundle("~");
var asset = new Mock<IAsset>();
asset.Setup(a => a.Accept(It.IsAny<IBundleVisitor>()))
.Callback<IBundleVisitor>(v => v.Visit(asset.Object));
asset.SetupGet(a => a.References).Returns(new[]
{
new AssetReference("~/test.png", asset.Object, -1, AssetReferenceType.RawFilename)
});
bundle.Assets.Add(asset.Object);
bundles = new[] { bundle };
}
开发者ID:Zocdoc,项目名称:cassette,代码行数:13,代码来源:RawFileRequestHandler.cs
示例12: GivenCacheOutOfDate_WhenCreateWithBundle_ThenBundlesInitializedFromNewCache
public void GivenCacheOutOfDate_WhenCreateWithBundle_ThenBundlesInitializedFromNewCache()
{
var bundles = new TestableBundle[0];
var application = CreateSettings();
CacheIsOutOfDate(bundles);
var factory = CreateFactory();
factory.Create(bundles, application);
// InitializeBundlesFromCacheIfUpToDate should be called a second time.
// This is to make the bundles get their content from the cached, optimized, data.
// Otherwise the first time the app runs the bundles are running from their original sources.
cache.Verify(c => c.InitializeBundlesFromCacheIfUpToDate(bundles), Times.Exactly(2));
}
开发者ID:JamesTryand,项目名称:cassette,代码行数:14,代码来源:CachedBundleContainerFactory.cs
示例13: WhenProcessBundleContainingJavaScriptAsset_ThenNoTransformsAreAddedToAsset
public void WhenProcessBundleContainingJavaScriptAsset_ThenNoTransformsAreAddedToAsset()
{
var bundle = new TestableBundle("~");
var coffeeScriptAsset = new Mock<IAsset>();
coffeeScriptAsset.SetupGet(a => a.SourceFile.FullPath).Returns("test.js");
bundle.Assets.Add(coffeeScriptAsset.Object);
step.Process(bundle, new CassetteSettings(""));
coffeeScriptAsset.Verify(
a => a.AddAssetTransformer(
It.IsAny<IAssetTransformer>()
),
Times.Never()
);
}
开发者ID:nlerikheemskerk,项目名称:cassette,代码行数:16,代码来源:CompileCoffeeScript.cs
示例14: WhenProcessBundleContainingCoffeeScriptAsset_ThenCompileCoffeeScriptAssetTransformIsAddedToAsset
public void WhenProcessBundleContainingCoffeeScriptAsset_ThenCompileCoffeeScriptAssetTransformIsAddedToAsset()
{
var bundle = new TestableBundle("~");
var coffeeScriptAsset = new Mock<IAsset>();
coffeeScriptAsset.SetupGet(a => a.SourceFile.FullPath).Returns("test.coffee");
bundle.Assets.Add(coffeeScriptAsset.Object);
step.Process(bundle, new CassetteSettings(""));
coffeeScriptAsset.Verify(
a => a.AddAssetTransformer(
It.Is<IAssetTransformer>(
t => t is CompileAsset
)
)
);
}
开发者ID:nlerikheemskerk,项目名称:cassette,代码行数:17,代码来源:CompileCoffeeScript.cs
示例15: GivenTwoAssetsWhereADependsOnB_WhenSorted_ThenBIsBeforeAInBundle
public void GivenTwoAssetsWhereADependsOnB_WhenSorted_ThenBIsBeforeAInBundle()
{
var bundle = new TestableBundle("~/test");
var assetA = new Mock<IAsset>();
assetA.SetupGet(a => a.SourceFile.FullPath).Returns("~/test/a.js");
assetA.SetupGet(a => a.References)
.Returns(new[] { new AssetReference("~/test/b.js", assetA.Object, 1, AssetReferenceType.SameBundle) });
var assetB = new Mock<IAsset>();
assetB.SetupGet(a => a.SourceFile.FullPath).Returns("~/test/b.js");
bundle.Assets.Add(assetA.Object);
bundle.Assets.Add(assetB.Object);
var sorter = new SortAssetsByDependency();
sorter.Process(bundle, new CassetteSettings());
bundle.Assets[0].ShouldBeSameAs(assetB.Object);
bundle.Assets[1].ShouldBeSameAs(assetA.Object);
}
开发者ID:prasanths,项目名称:cassette,代码行数:18,代码来源:SortAssetsByDependency.cs
示例16: BundleCollection_Add_Tests
public BundleCollection_Add_Tests()
{
tempDirectory = new TempDirectory();
CreateDirectory("test");
factory = new Mock<IBundleFactory<TestableBundle>>();
factory.Setup(f => f.CreateBundle(It.IsAny<string>(), It.IsAny<IEnumerable<IFile>>(), It.IsAny<BundleDescriptor>()))
.Returns<string, IEnumerable<IFile>, BundleDescriptor>(
(path, files, d) => (createdBundle = new TestableBundle(path))
);
defaultFileSource = new Mock<IFileSearch>();
settings = new CassetteSettings("")
{
SourceDirectory = new FileSystemDirectory(tempDirectory),
BundleFactories = { { typeof(TestableBundle), factory.Object } },
DefaultFileSearches = { { typeof(TestableBundle), defaultFileSource.Object } }
};
bundles = new BundleCollection(settings);
}
开发者ID:nlerikheemskerk,项目名称:cassette,代码行数:18,代码来源:BundleCollection.Add.cs
示例17: ConcatenateAssetsWithSeparatorPutsSeparatorBetweenEachAsset
public void ConcatenateAssetsWithSeparatorPutsSeparatorBetweenEachAsset()
{
var bundle = new TestableBundle("~");
var asset1 = new Mock<IAsset>();
var asset2 = new Mock<IAsset>();
asset1.Setup(a => a.OpenStream()).Returns(() => "asset1".AsStream());
asset2.Setup(a => a.OpenStream()).Returns(() => "asset2".AsStream());
bundle.Assets.Add(asset1.Object);
bundle.Assets.Add(asset2.Object);
var processor = new ConcatenateAssets { Separator = ";" };
processor.Process(bundle);
using (var reader = new StreamReader(bundle.Assets[0].OpenStream()))
{
reader.ReadToEnd().ShouldEqual("asset1;asset2");
}
(bundle.Assets[0] as IDisposable).Dispose();
}
开发者ID:jlopresti,项目名称:cassette,代码行数:19,代码来源:ConcatenateAssets.cs
示例18: WhenBundleHasSortedAssets_ThenProcessDoesNotReorderAssets
public void WhenBundleHasSortedAssets_ThenProcessDoesNotReorderAssets()
{
var bundle = new TestableBundle("~/test");
var assetA = new Mock<IAsset>();
assetA.SetupGet(a => a.SourceFile.FullPath).Returns("~/test/a.js");
assetA.SetupGet(a => a.References)
.Returns(new[] { new AssetReference("~/TEST/B.js", assetA.Object, 1, AssetReferenceType.SameBundle) });
var assetB = new Mock<IAsset>();
assetB.SetupGet(a => a.SourceFile.FullPath).Returns("~/test/b.js");
bundle.Assets.Add(assetA.Object);
bundle.Assets.Add(assetB.Object);
bundle.IsSorted = true;
var sorter = new SortAssetsByDependency();
sorter.Process(bundle, new CassetteSettings(""));
bundle.Assets[0].ShouldBeSameAs(assetA.Object);
bundle.Assets[1].ShouldBeSameAs(assetB.Object);
}
开发者ID:nlerikheemskerk,项目名称:cassette,代码行数:19,代码来源:SortAssetsByDependency.cs
示例19: GivenAssetWithCircularReferences_WhenProcess_ThenExceptionThrown
public void GivenAssetWithCircularReferences_WhenProcess_ThenExceptionThrown()
{
var bundle = new TestableBundle("~/test");
var assetA = new Mock<IAsset>();
assetA.SetupGet(a => a.SourceFile.FullPath).Returns("~/test/a.js");
assetA.SetupGet(a => a.References)
.Returns(new[] { new AssetReference("~/test/b.js", assetA.Object, 1, AssetReferenceType.SameBundle) });
var assetB = new Mock<IAsset>();
assetB.SetupGet(a => a.SourceFile.FullPath).Returns("~/test/b.js");
assetB.SetupGet(a => a.References)
.Returns(new[] { new AssetReference("~/test/a.js", assetB.Object, 1, AssetReferenceType.SameBundle) });
bundle.Assets.Add(assetA.Object);
bundle.Assets.Add(assetB.Object);
var sorter = new SortAssetsByDependency();
Assert.Throws<InvalidOperationException>(
() => sorter.Process(bundle, new CassetteSettings())
);
}
开发者ID:prasanths,项目名称:cassette,代码行数:20,代码来源:SortAssetsByDependency.cs
示例20: TestableBundle
public void GivenBundleWithTwoAssets_WhenConcatenateAssetsProcessesBundle_ThenASingleAssetReplacesTheTwoOriginalAssets()
{
var bundle = new TestableBundle("~");
var asset1 = new Mock<IAsset>();
var asset2 = new Mock<IAsset>();
asset1.Setup(a => a.OpenStream()).Returns(() => ("asset1" + Environment.NewLine + "content").AsStream());
asset2.Setup(a => a.OpenStream()).Returns(() => ("asset2" + Environment.NewLine + "content").AsStream());
bundle.Assets.Add(asset1.Object);
bundle.Assets.Add(asset2.Object);
var processor = new ConcatenateAssets();
processor.Process(bundle, new CassetteSettings(""));
bundle.Assets.Count.ShouldEqual(1);
using (var reader = new StreamReader(bundle.Assets[0].OpenStream()))
{
reader.ReadToEnd().ShouldEqual("asset1" + Environment.NewLine + "content" + Environment.NewLine + "asset2" + Environment.NewLine + "content");
}
(bundle.Assets[0] as IDisposable).Dispose();
}
开发者ID:nlerikheemskerk,项目名称:cassette,代码行数:20,代码来源:ConcatenateAssets.cs
注:本文中的TestableBundle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论