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); }
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); }
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); }
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)); }
public void ShouldBeNullOrEmpty() { var anonymousClanOfSlackJawedTroglodytes = new Person() { Name = "The Simpsons" }; anonymousClanOfSlackJawedTroglodytes.Name.ShouldBeNullOrEmpty(); }
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; }); }
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; }); }