Пример #1
0
        public async Task EmailManipulationWorks()
        {
            _contact.Emails = new[]
            {
                new EmailViewModel
                {
                    Category = EmailCategory.Personal,
                    Value    = "*****@*****.**"
                }
            };
            var data = await ContactService.CreateAsync(_contact);

            Assert.NotEqual(Guid.Empty, data.Id);

            var contactId = data.Id;
            var email     = new Email
            {
                Value     = "*****@*****.**",
                Category  = EmailCategory.Personal,
                IsPrimary = false
            };
            var emailSaved = await EmailRepository.CreateAsync(contactId, email);

            var wtEmail = await ContactService.GetByIdAsync(data.Id);

            Assert.Equal(2, wtEmail.Emails.Length);
            emailSaved.Value = "*****@*****.**";
            var emailUpdated = await EmailRepository.UpdateAsync(contactId, emailSaved);

            var wtEmail2 = await ContactService.GetByIdAsync(data.Id);

            Assert.Contains(wtEmail2.Emails, it => it.Value == emailSaved.Value);
            await EmailRepository.DeleteAsync(contactId, emailUpdated.Id);

            var afterDelete = await ContactService.GetByIdAsync(data.Id);

            Assert.Single(afterDelete.Emails);
        }