示例#1
0
 public void ShouldNotBeInRange()
 {
     DocExampleWriter.Document(() =>
     {
         var mrBurns = new Person() { Name = "Mr. Burns", Salary = 30000 };
         mrBurns.Salary.ShouldNotBeInRange(30000, 40000);
     }, _testOutputHelper);
 }
 public void ShouldBeGreaterThanOrEqualTo()
 {
     DocExampleWriter.Document(() =>
     {
         var mrBurns = new Person() { Name = "Mr. Burns", Salary = 299999999 };
         mrBurns.Salary.ShouldBeGreaterThanOrEqualTo(300000000);
     }, _testOutputHelper);
 }
 public void ShouldBeLessThanOrEqualTo()
 {
     DocExampleWriter.Document(() =>
     {
         var homer = new Person() { Name = "Homer", Salary = 30001 };
         homer.Salary.ShouldBeLessThanOrEqualTo(30000);
     }, _testOutputHelper);
 }
 public void ShouldBeAssignableTo()
 {
     DocExampleWriter.Document(() =>
     {
         var theSimpsonsDog = new Person() { Name = "Santas little helper" };
         theSimpsonsDog.ShouldBeAssignableTo<Pet>();
     }, _testOutputHelper);
 }
示例#5
0
 public void ShouldBeInRange()
 {
     DocExampleWriter.Document(() =>
     {
         var homer = new Person() { Name = "Homer", Salary = 300000000 };
         homer.Salary.ShouldBeInRange(30000, 40000);
     }, _testOutputHelper);
 }
 public void ShouldBeEmpty()
 {
     DocExampleWriter.Document(() =>
     {
         var homer = new Person() { Name = "Homer" };
         var powerPlantOnTheWeekend = new List<Person>() { homer };
         powerPlantOnTheWeekend.ShouldBeEmpty();
     }, _testOutputHelper);
 }
        public void ShouldBeSameAs()
        {
            DocExampleWriter.Document(() =>
            {
                var principleSkinner = new Person() { Name = "Armin Tamzarian"};
                var symourSkinner = new Person() { Name = "Seymour Skinner" };

                principleSkinner.ShouldBeSameAs(symourSkinner);
            }, _testOutputHelper);
        }
 public void ShouldHaveSingleItem()
 {
     DocExampleWriter.Document(() =>
     {
         var maggie = new Person() { Name = "Maggie" };
         var homer = new Person() { Name = "Homer" };
         var simpsonsBabies = new List<Person>() { homer, maggie };
         simpsonsBabies.ShouldHaveSingleItem();
     }, _testOutputHelper);
 }
 public void ShouldSatisfyAllConditions()
 {
     DocExampleWriter.Document(() =>
     {
         var mrBurns = new Person() { Name = null };
         mrBurns.ShouldSatisfyAllConditions
             (
                 () => mrBurns.Name.ShouldNotBeNullOrEmpty(),
                 () => mrBurns.Name.ShouldBe("Mr.Burns")
             );
     }, _testOutputHelper);
 }
        public void ShouldNotContain_Predicate()
        {
            DocExampleWriter.Document(() =>
            {
                var mrBurns = new Person() { Name = "Mr.Burns", Salary = 3000000 };
                var kentBrockman = new Person() { Name = "Homer", Salary = 3000000 };
                var homer = new Person() { Name = "Homer", Salary = 30000 };
                var millionares = new List<Person>() { mrBurns, kentBrockman, homer };

                millionares.ShouldNotContain(m => m.Salary < 1000000);
            }, _testOutputHelper);
        }
        public void ShouldContain()
        {
            DocExampleWriter.Document(() =>
            {
                var mrBurns = new Person() { Name = "Mr.Burns", Salary = 3000000 };
                var kentBrockman = new Person() { Name = "Kent Brockman", Salary = 3000000 };
                var homer = new Person() { Name = "Homer", Salary = 30000 };
                var millionares = new List<Person>() { kentBrockman, homer };

                millionares.ShouldContain(mrBurns);
            }, _testOutputHelper);
        }
        public void ShouldBeUnique()
        {
            DocExampleWriter.Document(() =>
            {
                var lisa = new Person() { Name = "Lisa" };
                var bart = new Person() { Name = "Bart" };
                var maggie = new Person() { Name = "Maggie" };
                var simpsonsKids = new List<Person>() { bart, lisa, maggie, maggie};

                simpsonsKids.ShouldBeUnique();
            }, _testOutputHelper);
        }
 public void ShouldNotThrowAction()
 {
     DocExampleWriter.Document(() =>
     {
         var homer = new Person() { Name = "Homer", Salary = 30000 };
         var denominator = 0;
         Should.NotThrow(() =>
         {
             var y = homer.Salary / denominator;
         });
     }, _testOutputHelper);
 }
        public void ShouldBe()
        {
            DocExampleWriter.Document(() =>
            {
                var apu = new Person() { Name = "Apu" };
                var homer = new Person() { Name = "Homer" };
                var skinner = new Person() { Name = "Skinner" };
                var barney = new Person() { Name = "Barney" };
                var theBeSharps = new List<Person>() { homer, skinner, barney };

                theBeSharps.ShouldBe(new[] { apu, homer, skinner, barney });
            }, _testOutputHelper);
        }
        public void ShouldNotContain()
        {
            DocExampleWriter.Document(() =>
            {
                var homerSimpson = new Person() { Name = "Homer" };
                var homerGlumplich = new Person() { Name = "Homer" };
                var lenny = new Person() { Name = "Lenny" };
                var carl = new Person() { Name = "carl" };
                var clubOfNoHomers = new List<Person>() { homerSimpson, homerGlumplich, lenny, carl };

                clubOfNoHomers.ShouldNotContain(homerSimpson);
            }, _testOutputHelper);
        }
        public void ShouldContain_Predicate()
        {
            DocExampleWriter.Document(() =>
            {
                var homer = new Person() { Name = "Homer", Salary = 30000 };
                var moe = new Person() { Name = "Moe", Salary = 20000 };
                var barney = new Person() { Name = "Barney", Salary = 0 };
                var millionares = new List<Person>() { homer, moe, barney };

                // Check if at least one element in the IEnumerable satisfies the predicate
                millionares.ShouldContain(m => m.Salary > 1000000);
            }, _testOutputHelper);
        }
 public void ShouldNotThrowFunc()
 {
     DocExampleWriter.Document(() =>
     {
         var homer = new Person() { Name = "Homer", Salary = 30000 };
         var denominator = 0;
         Should.NotThrow(() =>
         {
             var task = Task.Factory.StartNew(() => { var y = homer.Salary / denominator; });
             return task;
         });
     }, _testOutputHelper);
 }
        public void ShouldBeSubsetOf()
        {
            DocExampleWriter.Document(() =>
            {
                var lisa = new Person() { Name = "Lisa" };
                var bart = new Person() { Name = "Bart" };
                var maggie = new Person() { Name = "Maggie" };
                var homer = new Person() { Name = "Homer" };
                var marge = new Person() { Name = "Marge" };
                var ralph = new Person() { Name = "Ralph" };
                var simpsonsKids = new List<Person>() { bart, lisa, maggie, ralph };
                var simpsonsFamily = new List<Person>() { lisa, bart, maggie, homer, marge };

                simpsonsKids.ShouldBeSubsetOf(simpsonsFamily);
            }, _testOutputHelper);
        }