// Returns true if the expected result is right // Returns false if the expected result is wrong public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest2: Create a new instance of KeyValuePair.key is string and value is int"); try { string ExpectValue1 = "HELLO"; int ExpectValue2 = 1; KeyValuePair<int, string> myKeValuePair = new KeyValuePair<int, string>(ExpectValue2, ExpectValue1); string expectValue = "[1, HELLO]"; string actualValue = myKeValuePair.ToString(); if (actualValue != expectValue) { TestLibrary.TestFramework.LogError("002.1", "calling tostring method should return " + expectValue); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e); retVal = false; } return retVal; }
public static void TestUseCase() { var pair = new KeyValuePair<int, string>(1, "value"); Assert.AreEqual(pair.Key, 1, "Bridge479 Key"); Assert.AreEqual(pair.Value, "value", "Bridge479 Value"); Assert.AreEqual(pair.ToString(), "[1, value]", "Bridge479 ToString"); }
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"); }
// Returns true if the expected result is right // Returns false if the expected result is wrong public bool PosTest3() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest3: Create a new instance of KeyValuePair,key is 0 and value is null."); try { KeyValuePair<int, string> myKeValuePair = new KeyValuePair<int, string>(); string expectValue = "[0, ]"; string actualValue = myKeValuePair.ToString(); if (expectValue != actualValue) { TestLibrary.TestFramework.LogError("003.1", "the key of KeyValuePair should return " + actualValue); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("003.0", "Unexpected exception: " + e); retVal = false; } return retVal; }
public void KVPToString() { KeyValuePair<Char, String> input1 = new KeyValuePair<char, string>('A', "alpha"); Assert.AreEqual("A -> alpha", input1.ToString(" -> ", true)); Assert.AreEqual("alphaA", input1.ToString("", false)); }
public KeyValuePair<Move, RotationDirection> getMove() { KeyValuePair<Move, RotationDirection> retval = new KeyValuePair<Move,RotationDirection>(Move.None, RotationDirection.None); if(swipedFaces.Count < 3){ return retval; } CubeFace f = getDominantFace(); if (f == CubeFace.None) { return retval; } filterMoves(f); SwipeDirection dir = getSingleDirection(); if (dir == SwipeDirection.None) { return retval; } SwipedFace swipedFace = getSingleSwipedFace(dir); //Debug.Print("face: {0}{1}{2}", swipedFace.face, swipedFace.direction, swipedFace.layer); Move m = Move.None; switch(swipedFace.face){ case CubeFace.F: case CubeFace.B: switch(swipedFace.direction){ case SwipeDirection.H: switch(swipedFace.layer){ case 0: m = Move.U; break; case 1: m = Move.E; break; case 2: m = Move.D; break; } break; case SwipeDirection.V: switch (swipedFace.layer) { case 0: m = Move.L; break; case 1: m = Move.M; break; case 2: m = Move.R; break; } break; } break; case CubeFace.R: case CubeFace.L: switch (swipedFace.direction) { case SwipeDirection.H: switch(swipedFace.layer){ case 0: m = Move.D; break; case 1: m = Move.E; break; case 2: m = Move.U; break; } break; case SwipeDirection.V: switch (swipedFace.layer) { case 0: m = Move.B; break; case 1: m = Move.S; break; case 2: m = Move.F; break; } break; } break; case CubeFace.U: case CubeFace.D: switch (swipedFace.direction) { case SwipeDirection.H: switch (swipedFace.layer) { case 0: m = Move.B; break; case 1: m = Move.S; break; case 2: m = Move.F; break; } break; case SwipeDirection.V: switch (swipedFace.layer) { case 0: m = Move.L; break; case 1: m = Move.M; break; case 2: m = Move.R; break; } break; } break; } retval = new KeyValuePair<Move,RotationDirection>(m, getRotationDirection(swipedFace)); Debug.Print("Move: " + retval.ToString()); return retval; }