Exemple #1
0
 public void SaveUserWithContact()
 {
     try
     {
         var options = CreateNewContextOptions(); using (var db = new UserContextExt(options))
         {
             var repository = new UserRepository(db);
             UserTestHelper.PopulateDefaultMenuDataUserCtx(db);
             var item    = UserTestHelper.GenerateModel();
             var contact = UserTestHelper.GenerateContact();
             var result  = new KeyValuePair <Contact, UserM>(contact, item);
             Assert.DoesNotThrow(() => result = repository.SaveUserWithContact(item, contact));
             Assert.DoesNotThrow(() => item   = repository.GetById(item.Id));
             Assert.DoesNotThrow(() => repository.Delete(item));
             Assert.NotNull(result.Key);
             Assert.NotNull(result.Value);
             Assert.Greater(result.Key.Id, 0);
             Assert.Greater(result.Value.Id, 0);
         }
     }
     catch (Exception ex)
     {
         LogEventManager.Logger.Error(ex);
         throw;
     }
 }
Exemple #2
0
        public void SaveContactAsync2()
        {
            try
            {
                var options = CreateNewContextOptions(); using (var db = new UserContextExt(options))
                {
                    var repository = new UserRepository(db);
                    UserTestHelper.PopulateDefaultMenuDataUserCtx(db);
                    var item    = UserTestHelper.GenerateModel();
                    var contact = UserTestHelper.GenerateContact();

                    Assert.DoesNotThrow(() => repository.Save(item));
                    Assert.DoesNotThrow(() => contact = repository.SaveContactAsync(item.Id, contact).Result);

                    Assert.NotNull(contact);
                    Assert.True(contact.Id > 0);
                }
            }
            catch (Exception ex)
            {
                LogEventManager.Logger.Error(ex);
                throw;
            }
        }