public void GetAge_Test_how_many_time_invoke() { //arrange int times = 0; ICusnew customer = Substitute.For <ICusnew>(); customer.GetAge() .Returns(20) .AndDoes(info => times++); //Act customer.GetAge(); customer.GetAge(); //assert times.ShouldBe(2); }
public void Validate_When_age_grather_then_18_Return_true() { //arrange ICusnew customer = Substitute.For <ICusnew>(); customer.GetAge().Returns(20); //act var validate = _customerVal.Validate(customer); validate.ShouldBeTrue(); }
public void Validate_when_age_less_then_18_Return_fail() { //arrange ICusnew customer = Substitute.For <ICusnew>(); customer.GetAge().Returns(16); //act var validate = _customerVal.Validate(customer); validate.ShouldBeFalse(); }
//public bool Validate (ICustomer customer) first //{ // if (customer == null) throw new ArgumentNullException(); // else if (customer.GetAge() < _minimumAge) return false; // return true; //} public bool Validate(ICusnew customer) { if (customer == null) { throw new ArgumentNullException(); } else if (customer.GetAge() < _minimumAge) { return(false); } return(true); }
public void Throw_Exception() { ICusnew customer = Substitute.For <ICusnew>(); customer.GetAge().Throws <NotSupportedException>(); }