private static void GuardAgainstNullOrEmptyPhoneNumber(HeadMasterPhoneNumber phoneNumber) { if (string.IsNullOrEmpty(phoneNumber.Value)) { throw new NullReferenceException(); } }
private static void Validate(HeadMasterName name, HeadMasterNationalCode nationalCode, HeadMasterPhoneNumber phoneNumber, HeadMasterEmail email) { GuardAgainstInvalidName(name); GuardAgainstInvalidNationalCode(nationalCode); GuardAgainstNullOrEmptyPhoneNumber(phoneNumber); GuardAgainsNullOrEmptyEmail(email); }
public void Constructor_Should_Throw_Exception_When_Email_Is_NullOrEmpty(string value) { //Arrange var phoneNumber = new HeadMasterPhoneNumber(value); var headMasterBuilder = _aHeadMaster.But().With(phoneNumber); //Act Action headMaster = () => headMasterBuilder.Build(); //Assert headMaster.Should().ThrowExactly <NullReferenceException>(); }
public HeadMaster(long id, HeadMasterName name, HeadMasterNationalCode nationalCode, HeadMasterPhoneNumber phoneNumber, HeadMasterEmail email, string degree, string major) : base(id) { Validate(name, nationalCode, phoneNumber, email); Name = name; NationalCode = nationalCode; PhoneNumber = phoneNumber; Email = email; Degree = degree; Major = major; }
public HeadMasterTestBuilder With(HeadMasterPhoneNumber phoneNumber) { PhoneNumber = phoneNumber; return(this); }