Exemplo n.º 1
0
        public void UpdateWorkItem_OnValidWorkItem_UpdatesEntity()
        {
            // ARRANGE
            DbContextOptions <TestDatabaseContext> options = new DbContextOptionsBuilder <TestDatabaseContext>()
                                                             .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                                                             .Options;
            IDatabaseContext context = new TestDatabaseContext(options);
            WorkItemLogic    logic   = new WorkItemLogic(context);

            WorkItemCollection wic = new WorkItemCollection()
            {
                ID          = 1,
                TaskBoardId = 1
            };

            context.WorkItems.Add(new WorkItem()
            {
                ID = 1,
                WorkItemCollectionId = 1
            });

            context.WorkItemCollections.Add(wic);

            context.TaskBoards.Add(new TaskBoard()
            {
                ID     = 1,
                UserID = 1
            });

            context.Users.Add(new User()
            {
                ID = 1
            });

            context.SaveChanges();

            WorkItem request = new WorkItem()
            {
                ID                   = 1,
                Name                 = Guid.NewGuid().ToString(),
                Color                = Guid.NewGuid().ToString(),
                Description          = Guid.NewGuid().ToString(),
                WorkItemCollectionId = 1,
                WorkItemCollection   = wic,
                WorkItemStart        = DateTime.Now.AddDays(-1),
                WorkItemEnd          = DateTime.Now
            };

            // ACT
            logic.UpdateWorkItem(request);
            WorkItem result = logic.GetWorkItem(1);

            // ASSERT
            result.Should().BeEquivalentTo <WorkItem>(request);
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public WorkItemPublic UpdateWorkItem(WorkItemPublic workItem)
        {
            Ensure.ParamNotNull(workItem, nameof(workItem));

            WorkItemLogic     workItemLogic = new WorkItemLogic(mDBContext);
            WorkItemConverter converter     = new WorkItemConverter(mDBContext);

            WorkItem result = workItemLogic.UpdateWorkItem(converter.Convert(workItem));

            mDBContext.SaveChanges();

            return(converter.Convert(result));
        }
Exemplo n.º 3
0
        public void DeleteWorkItem_OnInValidWorkItemID_ThrowsArgumentException()
        {
            // ARRANGE
            DbContextOptions <TestDatabaseContext> options = new DbContextOptionsBuilder <TestDatabaseContext>()
                                                             .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                                                             .Options;
            IDatabaseContext context = new TestDatabaseContext(options);
            WorkItemLogic    logic   = new WorkItemLogic(context);

            WorkItem request = new WorkItem()
            {
                ID = 0,
            };

            // ACT
            Action act = () => logic.UpdateWorkItem(request);

            // ASSERT
            act.Should().Throw <ArgumentException>().Where(e => e.Message.Contains("grater than 0"));
        }