本文整理汇总了C#中Module.AddReferences方法的典型用法代码示例。如果您正苦于以下问题:C# Module.AddReferences方法的具体用法?C# Module.AddReferences怎么用?C# Module.AddReferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module.AddReferences方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GivenModuleHasUrlReference_ThenCreateModuleContainersGeneratesExternalModuleForTheUrl
public void GivenModuleHasUrlReference_ThenCreateModuleContainersGeneratesExternalModuleForTheUrl()
{
var module = new Module("~/test");
module.AddReferences(new[] { "http://test.com/api.js" });
var externalModule = new Module("http://test.com/api.js");
var moduleFactory = new Mock<IModuleFactory<Module>>();
moduleFactory.Setup(f => f.CreateExternalModule("http://test.com/api.js"))
.Returns(externalModule);
var moduleFactories = new Dictionary<Type, object>
{
{ typeof(Module), moduleFactory.Object }
};
var moduleSource = new Mock<IModuleSource<Module>>();
moduleSource
.Setup(s => s.GetModules(It.IsAny<IModuleFactory<Module>>(), It.IsAny<ICassetteApplication>()))
.Returns(new[] { module });
var config = new ModuleConfiguration(
Mock.Of<ICassetteApplication>(),
Mock.Of<IDirectory>(),
Mock.Of<IDirectory>(),
moduleFactories,
""
);
config.Add(moduleSource.Object);
var containers = config.CreateModuleContainers(false, "");
var generatedModule = containers[typeof(Module)].FindModuleContainingPath("http://test.com/api.js");
generatedModule.ShouldBeSameAs(externalModule);
}
示例2: GivenModulesWithCyclicReferences_WhenIncludeReferencesAndSortModules_ThenExceptionThrown
public void GivenModulesWithCyclicReferences_WhenIncludeReferencesAndSortModules_ThenExceptionThrown()
{
var module1 = new Module("~/module1");
var module2 = new Module("~/module2");
module1.AddReferences(new[] { "~/module2" });
module2.AddReferences(new[] { "~/module1" });
var container = new ModuleContainer<Module>(new[] { module1, module2 });
Assert.Throws<InvalidOperationException>(delegate
{
container.IncludeReferencesAndSortModules(new[] { module2, module1 });
});
}
示例3: GivenModuleWithReferenceToAnotherModule_ModulesAreSortedInDependencyOrder
public void GivenModuleWithReferenceToAnotherModule_ModulesAreSortedInDependencyOrder()
{
var module1 = new Module("~/module1");
var module2 = new Module("~/module2");
module1.AddReferences(new[] { "~/module2" });
var container = new ModuleContainer<Module>(new[] { module1, module2 });
var sorted = container.IncludeReferencesAndSortModules(new[] { module1, module2 });
sorted.SequenceEqual(new[] { module2, module1 }).ShouldBeTrue();
}
示例4: GivenModuleWithInvalid_ConstructorThrowsException
public void GivenModuleWithInvalid_ConstructorThrowsException()
{
var module1 = new Module("~/module1");
module1.AddReferences(new[] { "~\\module2" });
var exception = Assert.Throws<AssetReferenceException>(delegate
{
new ModuleContainer<Module>(new[] {module1});
});
exception.Message.ShouldEqual("Reference error in module descriptor for \"~/module1\". Cannot find \"~/module2\".");
}
示例5: UrlIsNotConverted
public void UrlIsNotConverted()
{
var module = new Module("~/module");
module.AddReferences(new[] { "http://test.com/" });
module.References.Single().ShouldEqual("http://test.com/");
}
示例6: TrailingSlashIsRemoved
public void TrailingSlashIsRemoved()
{
var module = new Module("~/module");
module.AddReferences(new[] { "../lib/" });
module.References.Single().ShouldEqual("~/lib");
}
示例7: StoresReferences
public void StoresReferences()
{
var module = new Module("~/module");
module.AddReferences(new[] { "~\\test", "~\\other" });
module.References.SequenceEqual(new[] { "~/test", "~/other" }).ShouldBeTrue();
}
示例8: ReferenceStartingWithSlashIsConvertedToAppRelative
public void ReferenceStartingWithSlashIsConvertedToAppRelative()
{
var module = new Module("~/module");
module.AddReferences(new[] { "/test" });
module.References.Single().ShouldEqual("~/test");
}
示例9: ModuleRelativePathIsConvertedToAppRelative
public void ModuleRelativePathIsConvertedToAppRelative()
{
var module = new Module("~/module");
module.AddReferences(new[] { "../lib" });
module.References.Single().ShouldEqual("~/lib");
}