private void DoNegAOORTest(ASCIIEncoding ascii, int byteCount)
 {
     Assert.Throws<ArgumentOutOfRangeException>(() =>
     {
         ascii.GetMaxCharCount(byteCount);
     });
 }
 private void DoNegAOORTest(ASCIIEncoding ascii, int byteCount)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
     {
         ascii.GetMaxCharCount(byteCount);
     });
 }
 private void DoPosTest(ASCIIEncoding ascii, int byteCount, int expectedValue)
 {
     int actualValue;
     ascii = new ASCIIEncoding();
     actualValue = ascii.GetMaxCharCount(byteCount);
     Assert.Equal(expectedValue, actualValue);
 }
示例#4
0
    public static void Main()
    {
        ASCIIEncoding ascii  = new ASCIIEncoding();
        int           maxSum = int.MinValue;
        string        name   = string.Empty;
        string        winner = string.Empty;

        while (true)
        {
            int currentSum = 0;
            name = Console.ReadLine();
            if (name == "STOP")
            {
                break;
            }
            byte[] encodedBytes = ascii.GetBytes(name);
            foreach (byte b in encodedBytes)
            {
                currentSum += b;
                if (currentSum > maxSum)
                {
                    maxSum = currentSum;
                    winner = ascii.GetMaxCharCount(encodedBytes);
                }
            }
        }
        Console.WriteLine($"Winner is {winner} - {maxSum}!");
    }
        private void DoPosTest(ASCIIEncoding ascii, int byteCount, int expectedValue)
        {
            int actualValue;

            ascii       = new ASCIIEncoding();
            actualValue = ascii.GetMaxCharCount(byteCount);
            Assert.Equal(expectedValue, actualValue);
        }
示例#6
0
        public void GetMaxCharCountTest()
        {
            ASCIIEncoding target    = new ASCIIEncoding(); // TODO: Initialize to an appropriate value
            int           byteCount = 0;                   // TODO: Initialize to an appropriate value
            int           expected  = 0;                   // TODO: Initialize to an appropriate value
            int           actual;

            actual = target.GetMaxCharCount(byteCount);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
示例#7
0
    public static void Main()
    {
        ASCIIEncoding ascii        = new ASCIIEncoding();
        int           byteCount    = 8;
        int           maxCharCount = ascii.GetMaxCharCount(byteCount);

        Console.WriteLine(
            "Maximum of {0} characters needed to decode {1} bytes.",
            maxCharCount,
            byteCount
            );
    }