[Fact]//xUnit测试方法只用带[Fact]Attribute就可以了
        public void GetStringSampleExceptions()
        {
            var sample = new StringSample(String.Empty);

            Assert.Throws <ArgumentNullException>(() => sample.GetStringDemo(null, "a"));
            Assert.Throws <ArgumentNullException>(() => sample.GetStringDemo("a", null));
            Assert.Throws <ArgumentException>(() => sample.GetStringDemo(string.Empty, "a"));
        }
Пример #2
0
        public void TestGetStringDemoExceptions()
        {
            var sample = new StringSample(string.Empty);

            Assert.Throws <ArgumentNullException>(() => sample.GetStringDemo(null, "a"));     //first=null
            Assert.Throws <ArgumentNullException>(() => sample.GetStringDemo("a", null));     //second=null
            Assert.Throws <ArgumentException>(() => sample.GetStringDemo(string.Empty, "a")); //first=string.empty
        }
Пример #3
0
        public void GetStringDemoExceptions()
        {
            var sample = new StringSample(string.Empty);

            Assert.Throws <ArgumentNullException>(() => sample.GetStringDemo(null, "a"));
            Assert.Throws <ArgumentNullException>(() => sample.GetStringDemo("a", null));
            Assert.Throws <ArgumentException>(() =>
                                              sample.GetStringDemo(string.Empty, "a"));
            const string first  = "a";
            const string second = "bb";

            Assert.Throws <ArgumentOutOfRangeException>(() => sample.GetStringDemo(first, second));
        }
        public void TestGetStringDemoUsingMember(string init, string a, string b, string expected)
        {
            var    sample = new StringSample(init);
            string actual = sample.GetStringDemo(a, b);

            Assert.Equal(expected, actual);
        }
 public void GetStringDemoABCDBC()
 {
     string expected = "removed bc from abcd: ad";
     var sample = new StringSample(String.Empty);
     string actual = sample.GetStringDemo("abcd", "bc");
     Assert.AreEqual(expected, actual);
 }
 public void GetStringDemoAB()
 {
     string expected = "b not found in a";
     var sample = new StringSample(String.Empty);
     string actual = sample.GetStringDemo("a", "b");
     Assert.AreEqual(expected, actual);
 }
Пример #7
0
        public void GetStringDemoInlineData(string init, string a, string b, string expected)
        {
            var    sample = new StringSample(init);
            string actual = sample.GetStringDemo(a, b);

            Assert.Equal(expected, actual);
        }
Пример #8
0
        public void GetStringDemoABCDBC()
        {
            string       expected = "removed bc from abcd: ad";
            StringSample sample   = new StringSample(String.Empty);
            string       actual   = sample.GetStringDemo("abcd", "bc");

            Assert.AreEqual(expected, actual);
        }
Пример #9
0
        public void GetStringDemoAB()
        {
            string       expected = "b not found in a";
            StringSample sample   = new StringSample(String.Empty);
            string       actual   = sample.GetStringDemo("a", "b");

            Assert.AreEqual(expected, actual);
        }
Пример #10
0
        public void TestGetStringDemoUsingMember(string init, string first, string second, string expected)
        {
            var sample = new StringSample(init);

            string actual = sample.GetStringDemo(first, second);

            Assert.Equal(expected, actual);
        }
Пример #11
0
        public void GetStringDemoRemoveBCFromABCD()
        {
            var expected = "removed bc from abcd: ad";
            var sample   = new StringSample(String.Empty);
            var actual   = sample.GetStringDemo("abcd", "bc");

            Assert.AreEqual(expected, actual);
        }
Пример #12
0
        public void GetStringDemoBNotInA()
        {
            var expected = "b not found in a";
            var sample   = new StringSample(String.Empty);
            var actual   = sample.GetStringDemo("a", "b");

            Assert.AreEqual(expected, actual);
        }
Пример #13
0
        public void GetStringDemoOnIndexBiggerThanFive()
        {
            var expected = "INIT";
            var sample   = new StringSample("InIt");
            var actual   = sample.GetStringDemo("abcdefgh", "f");

            Assert.AreEqual(expected, actual);
        }
Пример #14
0
        public void GetStringDemoAB()
        {
            //Arrange
            string expected = "b not found in a";


            //Act
            var    sample = new StringSample(string.Empty);
            string actual = sample.GetStringDemo("a", "b");


            //Assert
            Assert.AreEqual(expected, actual);
        }
Пример #15
0
        public void GetStringDemoThrowOnFirstNull()
        {
            var sample = new StringSample(String.Empty);

            sample.GetStringDemo(null, "second");
        }
Пример #16
0
        public void GetStringDemoThrowOnFirstIsEmpty()
        {
            var sample = new StringSample(String.Empty);

            sample.GetStringDemo("", "abcd");
        }
Пример #17
0
        public void GetStringDemoThrowOnFirstShorterThanSecond()
        {
            var sample = new StringSample(String.Empty);

            sample.GetStringDemo("abc", "abcd");
        }
Пример #18
0
        public void GetStringDemoThrowOnSecondNull()
        {
            var sample = new StringSample(String.Empty);

            sample.GetStringDemo("first", null);
        }