예제 #1
0
    public void TryGetBookPropertyWithEmptyISBN()
    {
        string isbn  = string.Empty;
        string field = "title";

        Challenge1.GetBookProperty(isbn, field);
    }
예제 #2
0
    public void TryGetBookPropertyWithInvalidField()
    {
        string isbn  = "978-1779501127";
        string field = "potato";

        Challenge1.GetBookProperty(isbn, field);
    }
예제 #3
0
    public void TryGetBookPropertyWithInvalidISBN()
    {
        string isbn  = "978-1617298028"; // Code Like A Pro in C# (Manning Publications, 2021) - Jort Rodenburg
        string field = "title";

        Challenge1.GetBookProperty(isbn, field);
    }
예제 #4
0
    public void TryGetBookPropertyWithValidISBN()
    {
        string isbn   = "978-1779501127";
        string field  = "title";
        string result = Challenge1.GetBookProperty(isbn, field);

        Assert.AreEqual("Watchmen", result);
    }
        public void SolveChallenge_ShouldSolveChallengeString()
        {
            string input    = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d";
            string expected = "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t";

            string actual = new Challenge1(input).SolveChallenge();

            Assert.Equal(expected, actual);
        }
예제 #6
0
        public void TestHexToBase64Converter()
        {
            // Arrange
            string expected = "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t";
            string input    = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d";

            // Act
            string actual = Challenge1.HexToBase64(input);

            // Assert
            Assert.Equal(expected, actual);
        }
        public void GetIndeces_SolutionArray_Equals_ExpectedOutcome()
        {
            //Arrange
            Challenge1 challenge1 = new Challenge1();

            int[] expected   = { 3, 0 };
            int[] inputArray = { 5, 17, 77, 50 };
            int   target     = 55;

            //Act
            int[] actual = challenge1.GetIndeces(inputArray, target);

            //Assert
            CollectionAssert.AreEqual(expected, actual);
        }
        public void GetIndeces_SecondValue_Equals_0()
        {
            //Arrange
            Challenge1 challenge1 = new Challenge1();

            int[] expected   = { 3, 0 };
            int[] inputArray = { 5, 17, 77, 50 };
            int   target     = 55;

            //Act
            int[] actual = challenge1.GetIndeces(inputArray, target);

            //Assert
            Assert.AreEqual(expected[1], actual[1]);
        }
예제 #9
0
 public void ToBytes_UnPaddedBase64_Throws(string unPaddedBase64)
 {
     Assert.Throws <ArgumentException>(() => Challenge1.ToBytes(unPaddedBase64));
 }
예제 #10
0
        public void RoundtripBase64_EmptyString_EmptyBase64(string base64input)
        {
            var actual = Challenge1.ToBase64(Challenge1.ToBytes(base64input));

            Assert.Equal(base64input, actual);
        }
예제 #11
0
        public void ByteHexToBase64_ValidString_ValidBase64(string hexInput, string base64Output)
        {
            var actualBase64 = Challenge1.ByteHexToBase64(hexInput);

            Assert.Equal(base64Output, actualBase64);
        }
예제 #12
0
 public void ToByte_NullArray_Throws()
 {
     Assert.Throws <ArgumentNullException>(() => Challenge1.ToByte(null));
 }
예제 #13
0
 public void ToByte_ArrayWithOneChar_Throws()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Challenge1.ToByte(new char[1]));
 }
예제 #14
0
 public void ToByte_InvalidHexCharsArray_Throws()
 {
     Assert.Throws <ArgumentException>(() => Challenge1.ToByte('Y', 'u'));
 }
예제 #15
0
 public void ByteHexToByteArray_OddLengthString_Throws()
 {
     Assert.Throws <ArgumentException>(() => Challenge1.ByteHexToByteArray("thisIsOdd"));
 }
예제 #16
0
 public void CalculateSum()
 {
     Assert.AreEqual(19, Challenge1.HourglassSum(ChallengeInput));
 }
예제 #17
0
 public void ToBytes_NullString_Throws()
 {
     Assert.Throws <ArgumentNullException>(() => Challenge1.ToBytes(null));
 }
예제 #18
0
 public void ToByte_UppercaseValidHexCharsArray_Throws()
 {
     Assert.Equal(0xFF, Challenge1.ToByte('F', 'F'));
 }
예제 #19
0
 public void TestCase3()
 {
     Assert.AreEqual(-6, Challenge1.HourglassSum(TestCase3Input));
 }
예제 #20
0
 public void ByteHexToBase64_NullString_Throws()
 {
     Assert.Throws <ArgumentNullException>(() => Challenge1.ByteHexToBase64(null));
 }