예제 #1
0
    public void TryGetBookInfoValidTitleLowercase()
    {
        string title    = "watchmen";
        string result   = Challenge2.BookInfo(title);
        string expected = "{\"title\":\"Watchmen\",\"isbn\":\"978-1779501127\",\"authors\":[\"Alan Moore\",\"Dave Gibbons\"]}";

        Assert.AreEqual(expected, result);
    }
        public static void SolveChallenge_ShouldSolveChallenge()
        {
            string hex1     = "1c0111001f010100061a024b53535009181c";
            string hex2     = "686974207468652062756c6c277320657965";
            string expected = "746865206b696420646f6e277420706c6179";

            string actual = new Challenge2(hex1, hex2).SolveChallenge();

            Assert.Equal(expected, actual);
        }
예제 #3
0
        public void CalculatesCorrectly()
        {
            var result = Challenge2.RotLeft(new[] { 1, 2, 3, 4, 5 }, 4);

            Assert.AreEqual(5, result[0]);
            Assert.AreEqual(1, result[1]);
            Assert.AreEqual(2, result[2]);
            Assert.AreEqual(3, result[3]);
            Assert.AreEqual(4, result[4]);
        }
        public void CheckIfPalindrome_InputString_EvenCharacters_False()
        {
            //Arrange
            Challenge2 challenge2    = new Challenge2();
            string     stringToCheck = "abbaabbb";
            bool       expected      = false;

            //Act
            bool actual = challenge2.CheckIfPalindrome(stringToCheck);

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void CheckIfPalindrome_InputString_OddCharacters_True()
        {
            //Arrange
            Challenge2 challenge2    = new Challenge2();
            string     stringToCheck = "madam";
            bool       expected      = true;

            //Act
            bool actual = challenge2.CheckIfPalindrome(stringToCheck);

            //Assert
            Assert.AreEqual(expected, actual);
        }
예제 #6
0
        public void TestFixedXOR()
        {
            // Arrange
            string input1   = "1c0111001f010100061a024b53535009181c";
            string input2   = "686974207468652062756c6c277320657965";
            string expected = "746865206b696420646f6e277420706c6179";

            // Act
            string actual = Challenge2.FixedXOR(input1, input2);

            // Assert
            Assert.Equal(expected, actual);
        }
예제 #7
0
    public void TryGetBookInfoWithEmptyTitle()
    {
        string title = string.Empty;

        Challenge2.BookInfo(title);
    }
예제 #8
0
    public void TryGetBookInfoInvalidTitle()
    {
        string title = "Code Like a Pro in C#";

        Challenge2.BookInfo(title);
    }
예제 #9
0
 public void Xor_InvalidData_Throws(int?bytesALength, int?bytesBLenth, Type exceptionType)
 {
     Assert.Throws(exceptionType,
                   () =>
                   Challenge2.Xor(GetSequentialByteArrayOrNull(bytesALength), GetSequentialByteArrayOrNull(bytesBLenth)));
 }
예제 #10
0
 public void HexXor_InvalidInputs_Throws(string hexA, string hexB, Type exceptionType)
 {
     Assert.Throws(exceptionType, () => Challenge2.HexXor(hexA, hexB));
 }
예제 #11
0
 public void HexXor_ValidData_ValidReturn(string hexA, string hexB, string hexResult)
 {
     Assert.Equal(hexResult, Challenge2.HexXor(hexA, hexB));
 }
예제 #12
0
 public void ToHex_ValidSingleByte_ValidResults(byte testByte, string result)
 {
     Assert.Equal(result, Challenge2.ToHex(new [] { testByte }));
 }
예제 #13
0
 public void ToHex_NUllByte_Throws()
 {
     Assert.Throws <ArgumentNullException>(() => Challenge2.ToHex(null));
 }