本文整理汇总了C#中TestPackage类的典型用法代码示例。如果您正苦于以下问题:C# TestPackage类的具体用法?C# TestPackage怎么用?C# TestPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestPackage类属于命名空间,在下文中一共展示了TestPackage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CorrectRunnerIsUsed
public void CorrectRunnerIsUsed(string files, string domainUsage, Type expectedType)
{
var package = new TestPackage(files.Split(new char[] { ' ' }));
if (domainUsage != null)
package.Settings["DomainUsage"] = domainUsage;
Assert.That(_factory.MakeTestRunner(package), Is.TypeOf(expectedType));
}
示例2: MakeTestRunner
/// <summary>
/// Returns a test runner based on the settings in a TestPackage.
/// Any setting that is "consumed" by the factory is removed, so
/// that downstream runners using the factory will not repeatedly
/// create the same type of runner.
/// </summary>
/// <param name="package">The TestPackage to be loaded and run</param>
/// <returns>An ITestEngineRunner</returns>
public virtual ITestEngineRunner MakeTestRunner(TestPackage package)
{
DomainUsage domainUsage = (DomainUsage)System.Enum.Parse(
typeof(DomainUsage),
package.GetSetting(EnginePackageSettings.DomainUsage, "Default"));
switch (domainUsage)
{
default:
case DomainUsage.Default:
if (package.SubPackages.Count > 1)
return new MultipleTestDomainRunner(this.ServiceContext, package);
else
return new TestDomainRunner(this.ServiceContext, package);
case DomainUsage.Multiple:
return new MultipleTestDomainRunner(ServiceContext, package);
case DomainUsage.None:
return new LocalTestRunner(ServiceContext, package);
case DomainUsage.Single:
return new TestDomainRunner(ServiceContext, package);
}
}
示例3: GetById_ReturnsProject_WithMatchedId
public void GetById_ReturnsProject_WithMatchedId()
{
var p = new TestPackage();
var expectedId = p.ProjectSetMock.Object.First().ProjectId;
var project = p.Tested.Get(expectedId);
Assert.AreEqual(project.ProjectId, expectedId);
}
示例4: CreateDomain
/// <summary>
/// Construct an application domain for running a test package
/// </summary>
/// <param name="package">The TestPackage to be run</param>
public AppDomain CreateDomain( TestPackage package )
{
AppDomainSetup setup = CreateAppDomainSetup(package);
string domainName = "test-domain-" + package.Name;
// Setup the Evidence
Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
if (evidence.Count == 0)
{
Zone zone = new Zone(SecurityZone.MyComputer);
evidence.AddHost(zone);
Assembly assembly = Assembly.GetExecutingAssembly();
Url url = new Url(assembly.CodeBase);
evidence.AddHost(url);
Hash hash = new Hash(assembly);
evidence.AddHost(hash);
}
log.Info("Creating AppDomain " + domainName);
AppDomain runnerDomain = AppDomain.CreateDomain(domainName, evidence, setup);
// Set PrincipalPolicy for the domain if called for in the settings
if (_settingsService != null && _settingsService.GetSetting("Options.TestLoader.SetPrincipalPolicy", false))
{
runnerDomain.SetPrincipalPolicy(_settingsService.GetSetting(
"Options.TestLoader.PrincipalPolicy",
PrincipalPolicy.UnauthenticatedPrincipal));
}
return runnerDomain;
}
示例5: NamespaceSetUpFixtureReplacesNamespaceNodeInTree
public void NamespaceSetUpFixtureReplacesNamespaceNodeInTree()
{
string nameSpace = "NUnit.TestData.SetupFixture.Namespace1";
TestSuiteBuilder builder = new TestSuiteBuilder();
TestPackage package = new TestPackage( testAssembly );
package.TestName = nameSpace;
Test suite= builder.Build( package );
Assert.IsNotNull(suite);
Assert.AreEqual(testAssembly, suite.TestName.Name);
Assert.AreEqual(1, suite.Tests.Count);
string[] nameSpaceBits = nameSpace.Split('.');
for (int i = 0; i < nameSpaceBits.Length; i++)
{
suite = suite.Tests[0] as TestSuite;
Assert.AreEqual(nameSpaceBits[i], suite.TestName.Name);
Assert.AreEqual(1, suite.Tests.Count);
}
Assert.IsInstanceOf(typeof(SetUpFixture), suite);
suite = suite.Tests[0] as TestSuite;
Assert.AreEqual("SomeTestFixture", suite.TestName.Name);
Assert.AreEqual(1, suite.Tests.Count);
}
示例6: ExpandProjectPackage
/// <summary>
/// Expands a TestPackage based on a known project format, populating it
/// with the project contents and any settings the project provides.
/// Note that the package file path must be checked to ensure that it is
/// a known project format before calling this method.
/// </summary>
/// <param name="package">The TestPackage to be expanded</param>
public void ExpandProjectPackage(TestPackage package)
{
Guard.ArgumentNotNull(package, "package");
Guard.ArgumentValid(package.SubPackages.Count == 0, "Package is already expanded", "package");
string path = package.FullName;
if (!File.Exists(path))
return;
IProject project = LoadFrom(path);
Guard.ArgumentValid(project != null, "Unable to load project " + path, "package");
string configName = package.GetSetting(EnginePackageSettings.ActiveConfig, (string)null); // Need RunnerSetting
TestPackage tempPackage = project.GetTestPackage(configName);
// The original package held overrides, so don't change them, but
// do apply any settings specified within the project itself.
foreach (string key in tempPackage.Settings.Keys)
if (!package.Settings.ContainsKey(key)) // Don't override settings from command line
package.Settings[key] = tempPackage.Settings[key];
foreach (var subPackage in tempPackage.SubPackages)
package.AddSubPackage(subPackage);
// If no config is specified (by user or by the proejct loader) check
// to see if one exists in same directory as the package. If so, we
// use it. If not, each assembly will use it's own config, if present.
if (!package.Settings.ContainsKey(EnginePackageSettings.ConfigurationFile))
{
var packageConfig = Path.ChangeExtension(path, ".config");
if (File.Exists(packageConfig))
package.Settings[EnginePackageSettings.ConfigurationFile] = packageConfig;
}
}
示例7: LoadPackage
/// <summary>
/// Load a TestPackage for possible execution
/// </summary>
/// <param name="package">The TestPackage to be loaded</param>
/// <returns>A TestEngineResult.</returns>
protected override TestEngineResult LoadPackage()
{
List<TestPackage> packages = new List<TestPackage>();
foreach (string testFile in TestPackage.TestFiles)
{
TestPackage subPackage = new TestPackage(testFile);
if (Services.ProjectService.IsProjectFile(testFile))
Services.ProjectService.ExpandProjectPackage(subPackage);
foreach (string key in TestPackage.Settings.Keys)
subPackage.Settings[key] = TestPackage.Settings[key];
packages.Add(subPackage);
}
List<TestEngineResult> results = new List<TestEngineResult>();
foreach (TestPackage subPackage in packages)
{
var runner = CreateRunner(subPackage);
_runners.Add(runner);
results.Add(runner.Load());
}
return ResultHelper.Merge(results);
}
示例8: AbstractTestRunner
public AbstractTestRunner(IServiceLocator services, TestPackage package)
{
Services = services;
TestPackage = package;
TestRunnerFactory = Services.GetService<ITestRunnerFactory>();
ProjectService = Services.GetService<IProjectService>();
}
示例9: LoadTestFixtureFromAssembly
public void LoadTestFixtureFromAssembly()
{
TestSuiteBuilder builder = new TestSuiteBuilder();
TestPackage package = new TestPackage( thisDll );
package.TestName = this.GetType().FullName;
Test suite= builder.Build( package );
Assert.IsNotNull(suite, "Should not be Null");
}
示例10: Setup
public void Setup()
{
TestSuiteBuilder builder = new TestSuiteBuilder();
TestPackage package = new TestPackage(AssemblyHelper.GetAssemblyPath(typeof(ActionAttributeExceptionFixture)));
package.TestName = typeof(ActionAttributeExceptionFixture).Namespace;
_Suite = builder.Build(package);
}
示例11: ChangePassword_Validates_And_Saves
public void ChangePassword_Validates_And_Saves()
{
var p = new TestPackage();
p.Tested.ChangePassword(1, "Password", "password123");
p.PasswordSetMock.Verify(x => x.Attach(It.IsAny<Password>()), Times.Once);
p.ContextProviderMock.Verify(x => x.SetEntryModified(It.IsAny<Password>()), Times.Once);
p.ContextProviderMock.Verify(x => x.SaveChanges(), Times.Once);
}
示例12: calling_Reserve_with_2_queues_should_call_BLPop_with_2_queues
public void calling_Reserve_with_2_queues_should_call_BLPop_with_2_queues()
{
var package = new TestPackage(new[] { "queue1", "queue2" });
var job = package.UnderTest.Reserve();
package.RedisMock.Verify(x => x.BLPop(new[] { "queue:queue1", "queue:queue2" }, It.IsAny<int>()));
}
示例13: calling_Reserve_should_get_a_job
public void calling_Reserve_should_get_a_job()
{
var package = new TestPackage(new[] {""});
var job = package.UnderTest.Reserve();
Assert.That(job, Is.Not.Null);
}
示例14: CreateDomain
/// <summary>
/// Creates a new AppDomain for running the test package
/// </summary>
/// <param name="package">The test package to be run</param>
/// <returns></returns>
public static AppDomain CreateDomain(TestPackage package)
{
AppDomainSetup setup = CreateAppDomainSetup(package);
string domainName = "test-domain-" + package.Name;
return AppDomain.CreateDomain(domainName, null, setup);
}
示例15: CreateRunner
// Create a MultipleTestProcessRunner with a fake package consisting of
// some number of assemblies and with an optional MaxAgents setting.
// Zero means that MaxAgents is not specified.
MultipleTestProcessRunner CreateRunner(int assemblyCount, int maxAgents)
{
// Currently, we can get away with null entries here
var package = new TestPackage(new string[assemblyCount]);
if (maxAgents > 0)
package.Settings[EnginePackageSettings.MaxAgents] = maxAgents;
return new MultipleTestProcessRunner(new ServiceContext(), package);
}