本文整理汇总了C#中Bridge.QUnit.Assert.Equal方法的典型用法代码示例。如果您正苦于以下问题:C# Assert.Equal方法的具体用法?C# Assert.Equal怎么用?C# Assert.Equal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bridge.QUnit.Assert
的用法示例。
在下文中一共展示了Assert.Equal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test
public static void Test(Assert assert)
{
assert.Expect(6);
// TEST
int[] numbers = new int[] { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
int i = 0;
var aQuery = from n in numbers select ++i;
assert.Equal(i, 0, "Query is not executed until you enumerate over them");
// TEST
aQuery.ToList();
assert.Equal(i, 10, "Query is executed after you enumerate over them");
i = 0;
// TEST
var bQuery = (from n in numbers select ++i).Max();
assert.Equal(i, 10, "Max() executes immediately");
// TEST
var smallNumbers = from n in numbers where n <= 3 select n;
var smallerEvenNumbers = from n in smallNumbers where n % 2 == 0 select n;
assert.DeepEqual(smallerEvenNumbers.ToArray(), new[] { 2, 0 }, "Query in a query");
// TEST
numbers.ForEach((x, index) => numbers[index] = -numbers[index]);
assert.DeepEqual(numbers.ToArray(), new int[] { -5, -4, -1, -3, -9, -8, -6, -7, -2, 0 }, "ForEach()");
// TEST
assert.DeepEqual(smallerEvenNumbers.ToArray(), new[] { -4, -8, -6, -2, 0 }, "Second query run on a modified source");
}
示例2: TesForeach
public static void TesForeach(Assert assert)
{
assert.Expect(2);
string[] keys = new[] { "1", "2", "3" };
Action[] handlers = new Action[3];
int i = 0;
string result = "";
foreach (var itm in keys)
handlers[i++] = () => result += itm;
foreach (var handler in handlers)
{
handler();
}
assert.Equal(result, "123", "Bridge563 No block foreach loop");
i = 0;
result = "";
foreach (var itm in keys)
{
handlers[i++] = () => result += itm;
}
foreach (var handler in handlers)
{
handler();
}
assert.Equal(result, "123", "Bridge563 block foreach loop");
}
示例3: TestCloneCompare
public static void TestCloneCompare(Assert assert)
{
assert.Expect(13);
var v1 = new Version(1, 2, 3, (4 << 16) + 5);
var o = v1.Clone();
assert.Ok(o != null, "v1 Cloned");
var v2 = o as Version;
assert.Ok(v2 != null, "v1 Cloned as Version");
assert.Equal(v2.Major, 1, "v2.Major 1");
assert.Equal(v2.Minor, 2, "v2.Minor 2");
assert.Equal(v2.Build, 3, "v2.Build 3");
assert.Equal(v2.Revision, 262149, "v2.Revision (4 << 16) + 5 = 262149");
assert.Equal(v2.MajorRevision, 4, "v2.MajorRevision 4");
assert.Equal(v2.MinorRevision, 5, "v2.MinorRevision 5");
var v3 = new Version(1, 2, 2, (4 << 16) + 5);
assert.Equal(v1.CompareTo(v3), 1, "v1.CompareTo(v3)");
var v4 = new Version(1, 3, 3, (4 << 16) + 5);
assert.Equal(v1.CompareTo(v4), -1, "v1.CompareTo(v4)");
assert.Equal(v1.CompareTo(o), 0, "v1.CompareTo(o)");
assert.Equal(v1.CompareTo(v2), 0, "v1.CompareTo(v2)");
assert.NotEqual(v1.CompareTo(null), 0, "v1.CompareTo(null)");
}
示例4: TestUseCase
public static void TestUseCase(Assert assert)
{
assert.Expect(2);
assert.Equal(Bridge537B.TestB1(), 2, "Bridge537 TestB1");
assert.Equal(Bridge537B.TestB2(), 1, "Bridge537 TestB2");
}
示例5: TestUseCase
public static void TestUseCase(Assert assert)
{
assert.Expect(2);
var inst = new Bridge597A();
assert.Equal(inst.Get(), "0:a", "Bridge597 Without instance member access");
assert.Equal(inst.GetWithMember(), "HI!:0:a", "Bridge597 With instance member access");
}
示例6: Test
public static void Test(Assert assert)
{
assert.Expect(3);
assert.Equal(TestMethodParametersClass.MethodDefault(), 5, "Default parameter - 5");
assert.Equal(TestMethodParametersClass.MethodDefault(10), 10, "Default parameter - 10");
assert.Equal(TestMethodParametersClass.MethodParams(new[] { 1, 2, 3 }), 6, "params int[]");
}
示例7: TestExplicitInterfaceMethodAndProperty
public static void TestExplicitInterfaceMethodAndProperty(Assert assert)
{
assert.Expect(3);
ISimple b = new B();
assert.Ok(b != null, "Instance of B created through ISimple interface explicitly");
assert.Equal(b.GetString(), "explicit B.ISimple", "b.GetString() = explicit B.ISimple");
assert.Equal(b.Data, 2, "a.Data = 2");
}
示例8: TestUseCase
public static void TestUseCase(Assert assert)
{
assert.Expect(3);
var pair = new KeyValuePair<int, string>(1, "value");
assert.Equal(pair.Key, 1, "Bridge479 Key");
assert.Equal(pair.Value, "value", "Bridge479 Value");
assert.Equal(pair.ToString(), "[1, value]", "Bridge479 ToString");
}
示例9: TestB
public static void TestB(Assert assert)
{
assert.Expect(3);
var b = new B();
assert.Ok(b != null, "Instance of B created");
assert.Equal(b.GetString(), "B", "b.GetString() = 'B'");
assert.Equal(b.Data, 1, "b.Data = 1");
}
示例10: TestC
public static void TestC(Assert assert)
{
assert.Expect(3);
var c = new C();
assert.Ok(c != null, "Instance of C created");
assert.Equal(c.GetString(), "C", "c.GetString() = 'C'");
assert.Equal(c.Data, -1, "c.Data = -1");
}
示例11: TestUseCase
public static void TestUseCase(Assert assert)
{
assert.Expect(2);
double d1 = 5.43;
assert.Equal(Math.Sign(d1), 1, "Bridge514 Sign(double 5.43)");
double d2 = -7.1;
assert.Equal(Math.Sign(d2), -1, "Bridge514 Sign(double -7.1)");
}
示例12: TestRelated
public static void TestRelated(Assert assert)
{
assert.Expect(2);
decimal d1 = 5.43M;
assert.Equal(Math.Sign(d1), 1, "Bridge514 Sign(decimal 5.43)");
decimal d2 = -7.1M;
assert.Equal(Math.Sign(d2), -1, "Bridge514 Sign(decimal -7.1)");
}
示例13: TestUseCase
public static void TestUseCase(Assert assert)
{
assert.Expect(2);
int i = 0;
object o = null;
assert.Equal(o.Method1(), "object", "Bridge615 object");
assert.Equal(i.Method1(), "int", "Bridge615 int");
}
示例14: TestA
public static void TestA(Assert assert)
{
assert.Expect(4);
var a = new A(10);
assert.Ok(a != null, "Instance of A created");
assert.Equal(a.X, 10, "a.X = 10");
assert.Equal(a.HandleNumber(100), 100, "a.HandleNumber(100) = 100");
assert.Equal(a.HandleString("Hundred"), "Hundred", "a.HandleString('Hundred') = 'Hundred'");
}
示例15: TestAB
public static void TestAB(Assert assert)
{
assert.Expect(4);
A b = new B(10, 20);
assert.Ok(b != null, "Instance of B created as A type");
assert.Equal(b.X, 10, "b.X = 10");
assert.Equal(b.HandleNumber(10), 10, "b.HandleNumber(10) = 10");
assert.Equal(b.HandleString("Hundred"), "Hundred", "b.HandleString('Hundred') = 'Hundred'");
}