本文整理汇总了C#中NUnit.Framework.TestContext类的典型用法代码示例。如果您正苦于以下问题:C# TestContext类的具体用法?C# TestContext怎么用?C# TestContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestContext类属于NUnit.Framework命名空间,在下文中一共展示了TestContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Guid_null
public void Guid_null()
{
var ctx = new TestContext<Models.TestObject>();
Guid? guid = null;
ctx.Queryable.Where(x => x.guidNullProperty == guid).ToList();
Assert.AreEqual("guidNullProperty eq null", ctx.LastRequest.Parsed.Filter);
}
示例2: Guid
public void Guid()
{
var ctx = new TestContext<Models.TestObject>();
var guid = new System.Guid("61CA9677-CABA-44A0-A187-7C86A8E0EAC3");
ctx.Queryable.Where(x => x.guidProperty == guid).ToList();
Assert.AreEqual("guidProperty eq guid'61ca9677-caba-44a0-a187-7c86a8e0eac3'", ctx.LastRequest.Parsed.Filter);
}
示例3: GetExecutionFilepath
/// <summary>
/// Gets the full file path of an existing output file in the execution environment
/// </summary>
/// <returns>The full path to the file.</returns>
/// <param name="testContext">The test context from which to attempt to extract the path</param>
/// <param name="filename">The filename without path</param>
public static string GetExecutionFilepath(string filename, TestContext testContext = null)
{
string[] paths = new string[] {
Path.GetFullPath(filename),
BuildPathFromCodeBaseDir(filename),
BuildPathFromCurrentDir(filename),
BuildPathFromDomainDir(filename),
BuildPathFromStackFrame(filename),
testContext != null ?
BuildPathFromTestDeployment(filename, testContext) :
INEXISTANT_FILE,
testContext != null ?
BuildPathFromTestDir(filename, testContext) :
INEXISTANT_FILE,
};
foreach (string path in paths)
{
if (FileExists(path))
{
return path;
}
}
throw new FileNotFoundException(string.Format("{0} not found.", filename));
}
示例4: CopyAndAttachDatabase
public static void CopyAndAttachDatabase(TestContext context, string databaseName)
{
string destinationPath = CopyDatabase(context, databaseName);
// Attach the copied database to SQL Server
AttachDatabase(databaseName, destinationPath);
}
示例5: When_laird_is_defeated_then_all_kobolds_in_hall_are_defeated
public void When_laird_is_defeated_then_all_kobolds_in_hall_are_defeated()
{
// Arrange
var context = new TestContext();
var player = context.Player;
var laird = context.CreateCard<KoboldHumanoid>("Drakeclan Laird");
var ambusher = context.CreateCard<KoboldHumanoid>("Drakeclan Ambusher");
var cutter = context.CreateCard<KoboldHumanoid>("Drakeclan Cutter");
var shaman = context.CreateCard<KoboldHumanoid>("Drakeclan Shaman");
var kobolds = new[] {laird, ambusher, cutter, shaman};
context.SetTopOfDungeonDeck(kobolds);
context.AdvanceMonsterToFirstRank(laird);
var hand = Enumerable.Range(0, 6).Select(x => context.CreateCard<Criochan>("Criochan Captain")).ToArray();
context.SetPlayerHand(hand);
var startingXp = player.Xp;
var startingVp = player.Vp;
// Act
context.WhenBattling(laird);
player.DetermineBattleResult();
// Assert
kobolds.Each(x => Assert.That(player.Discard.Contains(x), "Discard does not contain {0}".Template(x.Name)));
context.Game.Dungeon.Ranks.Each(r=> Assert.That(r.Card, Is.Not.Null, "Rank {0} is empty".Template(r.Number)));
kobolds.Each(x => Assert.That(context.Game.Dungeon.Ranks.All(rank => rank.Card != x)));
Assert.That(player.Xp, Is.EqualTo(startingXp + laird.Xp));
Assert.That(player.Vp, Is.EqualTo(startingVp + kobolds.Sum(x => x.Vp)));
}
示例6: Contract_Contract
public void Contract_Contract()
{
using (var ctx = new TestContext())
{
var map = ctx.Db<Contract>();
var columns = map.Properties;
Assert.AreEqual(19, columns.Length);
map.Prop(x => x.Id)
.IsIdentity()
.IsFk(false)
.IsDiscriminator(false)
.IsRequired()
.HasColumnName("Id");
map.Prop(x => x.AvpContractNr)
.IsIdentity(false)
.IsFk(false)
.IsDiscriminator(false)
.IsRequired(false)
.HasColumnName("AvpContractNr")
.MaxLength(50);
}
}
示例7: It
public void It()
{
var ctx = new TestContext<string>();
ctx.Queryable.Where(x=>x.EndsWith("")).ToList();
Assert.AreEqual("endswith($it, '')", ctx.LastRequest.Parsed.Filter);
}
示例8: toLower
public void toLower()
{
var ctx = new TestContext<Models.TestObject>();
ctx.Queryable.Where(x => x.stringProperty.ToLower() == "").ToList();
Assert.AreEqual("tolower(stringProperty) eq ''", ctx.LastRequest.Parsed.Filter);
}
示例9: startswith
public void startswith()
{
var ctx = new TestContext<Models.TestObject>();
ctx.Queryable.Where(x => x.stringProperty.StartsWith("big")).ToList();
Assert.AreEqual("startswith(stringProperty, 'big')", ctx.LastRequest.Parsed.Filter);
}
示例10: length
public void length()
{
var ctx = new TestContext<Models.TestObject>();
ctx.Queryable.Where(x => x.stringProperty.Length == 1).ToList();
Assert.AreEqual("length(stringProperty) eq 1", ctx.LastRequest.Parsed.Filter);
}
示例11: GreaterThanOrEqual
public void GreaterThanOrEqual()
{
var ctx = new TestContext<Models.TestObject>();
ctx.Queryable.Where(x => x.intProperty >= x.secondIntProperty).ToList();
Assert.AreEqual("intProperty ge secondIntProperty", ctx.LastRequest.Parsed.Filter);
}
示例12: concat
public void concat()
{
var ctx = new TestContext<Models.TestObject>();
ctx.Queryable.Where(x => x.stringProperty + "test" == "propTest").ToList();
Assert.AreEqual("concat(stringProperty, 'test') eq 'propTest'", ctx.LastRequest.Parsed.Filter);
}
示例13: AndSingleAmp
public void AndSingleAmp()
{
var ctx = new TestContext<Models.TestObject>();
ctx.Queryable.Where(x => x.boolProperty & x.secondBoolProperty).ToList();
Assert.AreEqual("boolProperty and secondBoolProperty", ctx.LastRequest.Parsed.Filter);
}
示例14: round
public void round()
{
var ctx = new TestContext<Models.TestObject>();
ctx.Queryable.Where(x => Math.Round(x.floatProperty) == 0).ToList();
Assert.AreEqual("round(floatProperty) eq 0", ctx.LastRequest.Parsed.Filter);
}
示例15: fractionalseconds
public void fractionalseconds()
{
var ctx = new TestContext<Models.TestObject>();
ctx.Queryable.Where(x => x.dateProperty.Second == 0).ToList();
Assert.AreEqual("fractionalseconds(dateProperty) eq 0", ctx.LastRequest.Parsed.Filter);
}