Beispiel #1
0
        public void Remove_ContactWithSameContactType_Success()
        {
            this.user.Add(UserContact.Create(this.user, Contact.PrimaryNumber, "000"));
            this.user.Remove(UserContact.Create(this.user, Contact.PrimaryNumber, "000"));

            this.user.Contacts.Should().BeEmpty();
        }
Beispiel #2
0
        public void Create_AllInformationProvided_Success()
        {
            Mock <User> user = new Mock <User>();

            Mock <UserContact> expected = new Mock <UserContact>();

            expected.SetupGet(x => x.Type).Returns(Contact.PrimaryNumber);
            expected.SetupGet(x => x.Value).Returns("000");

            UserContact actual = UserContact.Create(user.Object, Contact.PrimaryNumber, "000");

            actual.ShouldBeEquivalentTo(expected.Object, opt =>
                                        opt.Excluding(
                                            prop =>
                                            prop.PropertyPath == "Id"
                                            ));
        }
        public UserDto Add(string idpID, string email, string fullName, List <ContactDto> contacts, bool isAdmin)
        {
            this.unitOfWork.BeginTransaction();

            User user = User.Create(idpID, email, fullName, isAdmin);

            foreach (ContactDto contact in contacts)
            {
                user.Add(UserContact.Create(user, (Domain.Users.Contact)contact.Type, contact.Value));
            }

            this.userDomainService.Add(user);

            UserDto userDto = Mapper.Map <UserDto>(user);

            this.unitOfWork.Commit();

            return(userDto);
        }
        public void ChangeContact(Guid userId, ContactDto contact)
        {
            this.unitOfWork.BeginTransaction();

            User user = this.userRepository.FindById(userId);

            UserContact userContact =
                user.Contacts.FirstOrDefault(x => x.Type == (Domain.Users.Contact)contact.Type);

            UserContact userContactNew =
                UserContact.Create(user, (Domain.Users.Contact)contact.Type, contact.Value);

            if (userContact != null)
            {
                user.Remove(userContact);
                user.Add(userContactNew);
            }
            else
            {
                user.Add(userContactNew);
            }

            this.unitOfWork.Commit();
        }
Beispiel #5
0
 public void Create_UserIsNull_ThrowsException()
 {
     UserContact.Create(null, Contact.PrimaryNumber, "000");
 }
Beispiel #6
0
        public void Create_ValueInformationIsMissing_ThrowsException()
        {
            Mock <User> user = new Mock <User>();

            UserContact.Create(user.Object, Contact.PrimaryNumber, null);
        }
Beispiel #7
0
 public void Add_DuplicateContactWithSameContactType_ThrowsException()
 {
     this.user.Add(UserContact.Create(this.user, Contact.PrimaryNumber, "000"));
     this.user.Add(UserContact.Create(this.user, Contact.PrimaryNumber, "000"));
 }