示例#1
0
        public void PrintGreeting_CustomWithEncryption_BadLength()
        {
            // Create an abnormally long string.
            string longString = null;

            for (int i = 0; i < 1024; i++)
            {
                longString += "x";
            }

            // Create our API object.
            HelloWorldAPI api = new HelloWorldAPI();

            // Run our test.
            api.PrintGreeting(longString, true);

            // Check our exceptions and assert.
            if (api.Errors.Count > 0)
            {
                Assert.IsInstanceOfType(api.Errors[0], typeof(CryptographicException));
            }
            else
            {
                throw new ApplicationException("No errors were found.");
            }
        }
示例#2
0
        public void PrintGreeting_CustomWithEncryption()
        {
            /* Encrypted output is indeterministic so we'll just run the method, and since we
             * have included error handling in our code our test will work regardless; otherwise
             * if there was any kind of error the test would fail. */
            HelloWorldAPI api = new HelloWorldAPI();

            api.PrintGreeting("Hoy es miercoles.", true);
        }
示例#3
0
        public void PrintGreeting_Default()
        {
            // Listen for the contents of the console.
            using (var co = new ConsoleOutput())
            {
                // Construct our API object and print a greeting.
                HelloWorldAPI api = new HelloWorldAPI();
                api.PrintGreeting();

                // Split up our output since we have a bunch of bells and whistles.
                string[] split = co.GetOuput().Split(':');

                // Check if we have our standard "Hello World" output.
                Assert.AreEqual("Hello World!", split[split.Length - 1].Trim(null));
            }
        }
示例#4
0
        public void PrintGreeting_CustomNoEncryption()
        {
            // Create a new greeting string.
            string greeting = "This is a custom greeting!";

            // Listen for the contents of the console.
            using (var co = new ConsoleOutput())
            {
                // Construct our API object and print a greeting.
                HelloWorldAPI api = new HelloWorldAPI();
                api.PrintGreeting(greeting);

                // Split up our output because of formatting.
                string[] split = co.GetOuput().Split(':');

                // Check our assertion.
                Assert.AreEqual(greeting, split[split.Length - 1].Trim(null));
            }
        }