public void GetById()
        {
            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();
                    Assert.DoesNotThrow(() => repository.Save(item));

                    Assert.DoesNotThrow(() => item = repository.GetById(item.Id));
                    Assert.DoesNotThrow(() => repository.Delete(item));
                    Assert.NotNull(item);
                    Assert.Greater(item.Id, 0);
                }
            }
            catch (Exception ex)
            {
                LogEventManager.Logger.Error(ex);
                throw;
            }
        }
Пример #2
0
        public async Task GetById_NotFound()
        {
            //assemble
            var queryContext     = AssembleMocks.GetQueryContext();
            var commandContext   = AssembleMocks.GetCommandContext();
            var conversationRepo = new ConversationRepository(queryContext.Object, commandContext.Object);

            //act
            var conversation = await conversationRepo.GetById(15, null);

            //assert
            Assert.IsNull(conversation);
        }
Пример #3
0
        public async Task Persist()
        {
            //assemble
            var queryContext     = AssembleMocks.GetQueryContext();
            var commandContext   = AssembleMocks.GetCommandContext();
            var conversationRepo = new ConversationRepository(queryContext.Object, commandContext.Object);
            var conversation     = await conversationRepo.GetById(1, null);

            string newTopic = Guid.NewGuid().ToString();

            //act
            conversation.Topic = newTopic;
            var response = await conversationRepo.Persist(conversation);

            //assert
            Assert.IsTrue(response.Topic == newTopic);
        }