示例#1
0
        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));
        }
示例#2
0
        public void ShouldBeCastableToString()
        {
            var type  = PhoneNumberTypeEnum.Home;
            var value = "599684567";

            var vo = PhoneNumberVO.Create(type, value);

            Assert.AreEqual(vo.ToString(), $"Type - {type}, LastName - {value}");
        }
示例#3
0
        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));
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }