public void GetMessages2() { try { var options = CreateNewContextOptions(); using (var db = new ConversationContext(options)) { ConversationTestHelper.PopulateDefaultDataCtx(db); } using (var db = new ConversationContext(options)) { var repository = new ConversationRepository(db); var item = GenerateModel(); var member = new User { Id = 1 }; var mess = GenerateMessage(); IEnumerable <Message> result = null; Assert.DoesNotThrow(() => repository.Save(item)); Assert.DoesNotThrow(() => repository.AddMessage(mess, item, member)); Assert.DoesNotThrow(() => result = repository.GetMessages(item.Id)); Assert.True(result != null && result.Any()); } } catch (Exception ex) { LogEventManager.Logger.Error(ex); throw; } }
public void RemoveMessage() { try { var options = CreateNewContextOptions(); using (var db = new ConversationContext(options)) { ConversationTestHelper.PopulateDefaultDataCtx(db); } using (var db = new ConversationContext(options)) { var repository = new ConversationRepository(db); var item = GenerateModel(); var mess = GenerateMessage(); Assert.DoesNotThrow(() => repository.Save(item)); Assert.DoesNotThrow(() => repository.AddMessage(mess, item, new User { Id = 1 })); Assert.DoesNotThrow(() => repository.RemoveMessage(mess, item)); } } catch (Exception ex) { LogEventManager.Logger.Error(ex); throw; } }