Ejemplo n.º 1
0
        public void LoadTextFile_ValidNameShouldWork()
        {
            // Act
            string actual = ExampleMethods.LoadTextFile("this is a valid file path");

            // Assert
            Assert.True(actual.Length >= 10);
        }
 public void ShouldExample2Test1()
 {
     //Declare Input Array
     int[] arrayOfInts = new int[5] {
         1, 2, 3, 4, 5
     };
     //Run Method
     ExampleMethods.Example2(arrayOfInts);
 }
        public void ShouldExample1Test2()
        {
            //Declare Input Array
            int[] arrayOfInts = new int[1] {
                101
            };
            //Run Method
            int actualResult = ExampleMethods.Example1(arrayOfInts, 1);

            //Check if expected and actual results match
            Assert.That(actualResult, Is.EqualTo(101));
        }
        public void ShouldExample1Test1()
        {
            //Declare Input Array
            int[] arrayOfInts = new int[10] {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            //Run Method
            int actualResult = ExampleMethods.Example1(arrayOfInts, 10);

            //Check if expected and actual results match
            Assert.That(actualResult, Is.EqualTo(1));
        }
Ejemplo n.º 5
0
        public void ReturnBleepedString_ShouldBleepOutSubstring(
            string input,
            string bleepableWord,
            string expected)
        {
            // Arrange

            // Act
            string actual = ExampleMethods.ReturnBleepedString(input, bleepableWord);

            // Arrange
            Assert.Equal(expected, actual);
        }
        public void ShouldExample2Test2()
        {
            //Declare Input Array
            int[] arrayOfInts = new int[200];
            //Declare StringWriter to catch Console output for comparison
            var sw = new StringWriter();

            Console.SetOut(sw);
            //Run Method
            ExampleMethods.Example2(arrayOfInts);
            string actualResult = sw.ToString();

            //Each Line will be "0\n" for a total of 3 characters per line
            //200 values should result in a total result length of 600 characters
            Assert.AreEqual(actualResult.Length, 600);
        }
        public void ShouldExample3Test2()
        {
            //Declare Input Array
            int[] arrayOfInts = new int[2] {
                5, 10
            };
            //Declare StringWriter to catch Console output for comparison
            var sw = new StringWriter();

            Console.SetOut(sw);
            //Run Method
            ExampleMethods.Example3(arrayOfInts);
            string actualResult = sw.ToString();

            //Check if expected and actual results match
            Assert.AreEqual(actualResult, "The value of a was found in int array.\r\nThe value of b was found in int array.\r\n");
        }
Ejemplo n.º 8
0
 public void ReturnBleepedString_EmptyBleepWordShouldThrowException()
 {
     // Assert
     Assert.Throws <ArgumentException>("bleepedWord", () => ExampleMethods.ReturnBleepedString("McChicken", ""));
 }
Ejemplo n.º 9
0
 public void ReturnBleepedString_EmptyInputShouldThrowException()
 {
     // Assert
     Assert.Throws <ArgumentException>("input", () => ExampleMethods.ReturnBleepedString("", "duck"));
 }
Ejemplo n.º 10
0
 public void LoadTextFile_InvalidArgumentShouldThrowException()
 {
     // Assert
     Assert.Throws <ArgumentException>("filePath", () => ExampleMethods.LoadTextFile(""));
 }