Exemple #1
0
        public void IEnumerable_ShouldContain()
        {
            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>() { kentBrockman, homer };

            millionares.ShouldContain(mrBurns);
        }
Exemple #2
0
        public void IEnumerable_ShouldAllBe_Predicate()
        {
            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.ShouldAllBe(m => m.Salary > 1000000);
        }
Exemple #3
0
        public void IEnumerable_ShouldContain_Predicate()
        {
            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);
        }
Exemple #4
0
 public void CompleteIn()
 {
     var homer = new Person() { Name = "Homer", Salary = 30000 };
     var denominator = 1;
     Should.CompleteIn(() =>
     {
         Thread.Sleep(2000);
         var y = homer.Salary / denominator;
     }, TimeSpan.FromSeconds(1));
 }
Exemple #5
0
 public void ShouldBeNullOrEmpty()
 {
     var anonymousClanOfSlackJawedTroglodytes = new Person() { Name = "The Simpsons" };
     anonymousClanOfSlackJawedTroglodytes.Name.ShouldBeNullOrEmpty();
 }
Exemple #6
0
 public void ShouldThrowFuncOfTask()
 {
     var homer = new Person() { Name = "Homer", Salary = 30000 };
     var denominator = 1;
     Should.Throw<DivideByZeroException>(() =>
     {
         var task = Task.Factory.StartNew(() => { var y = homer.Salary / denominator; });
         return task;
     });
 }
Exemple #7
0
 public void ShouldNotThrowFuncOfTask()
 {
     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;
     });
 }