예제 #1
0
        public async Task WorkItemService_PersistWorkItemsAsync_OneItemPersistedOneItemUpdated()
        {
            // Arrange
            var options   = TestDbContext.CreateDbContextOptions();
            var context   = new TestDbContext(options);
            var workItems = GetWorkItems();

            var firstWorkItem = workItems.First();

            firstWorkItem.WorkflowType = "firstCopy";

            await context.WorkItems.AddAsync(firstWorkItem);

            await context.SaveChangesAsync();

            firstWorkItem.WorkflowType = "first";

            var diHelper      = new DITestHelper();
            var loggerFactory = diHelper.GetLoggerFactory();
            ILogger <WorkItemService <TestDbContext> > logger = loggerFactory
                                                                .CreateLogger <WorkItemService <TestDbContext> >();

            var service = new WorkItemService <TestDbContext>(context, logger);

            // Act
            await service.PersistWorkItemsAsync(workItems);

            // Assert
            Assert.AreEqual(2, context.WorkItems.Count());
            Assert.AreEqual("first", context.WorkItems.First().WorkflowType);
        }
예제 #2
0
        public async Task WorkItemService_PersistWorkItemsAsync_TwoItemsPersisted()
        {
            // Arrange
            var options = TestDbContext.CreateDbContextOptions();

            var context  = new TestDbContext(options);
            var diHelper = new DITestHelper();
            var logger   = diHelper.GetLoggerFactory()
                           .CreateLogger <WorkItemService <TestDbContext> >();
            var workItems = GetWorkItems();

            var service = new WorkItemService <TestDbContext>(context, logger);

            // Act
            await service.PersistWorkItemsAsync(workItems);

            // Assert
            Assert.AreEqual(2, context.WorkItems.Count());
        }