public void ShouldThrowExceptionWithEmptyOrDefaultValue_Case1() { var type = default(PhoneNumberTypeEnum); var value = "599684567"; var ex = Assert.Throws <DomainException>(() => PhoneNumberVO.Create(type, value)); Assert.That(ex.Code, Is.EqualTo(DomainExceptionCode.InvalidPhoneNumber)); }
public void ShouldBeCastableToString() { var type = PhoneNumberTypeEnum.Home; var value = "599684567"; var vo = PhoneNumberVO.Create(type, value); Assert.AreEqual(vo.ToString(), $"Type - {type}, LastName - {value}"); }
public void ShouldThrowExceptionWithInvalidRegex() { var type = PhoneNumberTypeEnum.Home; var value = "5996G4567"; var ex = Assert.Throws <DomainException>(() => PhoneNumberVO.Create(type, value)); Assert.That(ex.Code, Is.EqualTo(DomainExceptionCode.InvalidPhoneNumber)); }
public void ShouldReturnCorrectValue() { var type = PhoneNumberTypeEnum.Home; var value = "599684567"; var vo = PhoneNumberVO.Create(type, value); Assert.AreEqual(vo.Type, type); Assert.AreEqual(vo.Value, value); }
public void ShouldBeEqual() { var type = PhoneNumberTypeEnum.Home; var value = "599684567"; var vo1 = PhoneNumberVO.Create(type, value); var vo2 = PhoneNumberVO.Create(type, value); Assert.AreEqual(vo1, vo2); }
public void ShouldNotBeEqual_Case3() { var type1 = PhoneNumberTypeEnum.Mobile; var value1 = "599684567"; var type2 = PhoneNumberTypeEnum.Office; var value2 = "599684569"; var vo1 = PhoneNumberVO.Create(type1, value1); var vo2 = PhoneNumberVO.Create(type2, value2); Assert.AreNotEqual(vo1, vo2); }
public static PhoneNumber Create(string value, PhoneNumberTypeEnum type, int personId) { var number = PhoneNumberVO.Create(type, value); var instance = new PhoneNumber { Value = number.Value, PhoneNumberTypeId = number.Type, PersonId = personId }; Validate(instance); instance.DomainEvents.Add(new PersonPhoneNumberCreatedEvent(instance)); return(instance); }