예제 #1
0
        public void Convert_ConvertsNonExistingServiceModelToEntity_ReturnsConvertedEntity()
        {
            // ARRANGE
            DbContextOptions <TestDatabaseContext> options = new DbContextOptionsBuilder <TestDatabaseContext>()
                                                             .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                                                             .Options;
            IDatabaseContext   dbContext       = new TestDatabaseContext(options);
            TaskBoardConverter converter       = new TaskBoardConverter(dbContext);
            TaskBoardPublic    taskBoardPublic = new TaskBoardPublic()
            {
                ID     = 1,
                Name   = "Test",
                UserID = 1
            };

            // ACT
            TaskBoard taskBoard = converter.Convert(taskBoardPublic);

            // ASSERT
            taskBoard.Should().BeEquivalentTo <TaskBoard>(new TaskBoard()
            {
                ID = 0, Name = "Test", UserID = 1
            });
            taskBoard.User.Should().BeNull();
        }
예제 #2
0
        /// <inheritdoc/>
        public TaskBoardPublic CreateTaskBoard(TaskBoardPublic taskBoard)
        {
            Ensure.ParamNotNull(taskBoard, nameof(taskBoard));

            mTaskBoards.Add(taskBoard);

            return(taskBoard);
        }
예제 #3
0
 public TaskBoardContainer(TaskBoardPublic taskBoard, ITerminalContext context)
 {
     Ensure.ParamNotNull(taskBoard, nameof(taskBoard));
     Ensure.ParamNotNull(context, nameof(context));
     this.TaskBoard = taskBoard;
     this.Name      = taskBoard.Name;
     this.mContext  = context;
 }
예제 #4
0
        public virtual IActionResult CreateTaskBoard([FromBody] TaskBoardPublic taskBoard)
        {
            Ensure.ParamNotNull(taskBoard, nameof(taskBoard));

            TaskBoardPublic createdTaskBoard = mRepository.CreateTaskBoard(taskBoard);

            return(base.Created($"/taskboards/{createdTaskBoard.ID}", createdTaskBoard));
        }
예제 #5
0
        /// <inheritdoc/>
        public TaskBoardPublic UpdateTaskBoard(TaskBoardPublic taskBoard)
        {
            Ensure.ParamNotNull(taskBoard, nameof(taskBoard));

            TaskBoardConverter converter = new TaskBoardConverter(mDBContext);
            TaskBoardLogic     logic     = new TaskBoardLogic(mDBContext);

            TaskBoard createdTaskBoard = logic.UpdateTaskBoard(converter.Convert(taskBoard));

            mDBContext.SaveChanges();

            return(converter.Convert(createdTaskBoard));
        }
예제 #6
0
        public virtual IActionResult UpdateTaskBoard([FromBody] TaskBoardPublic taskBoard)
        {
            Ensure.ParamNotNull(taskBoard, nameof(taskBoard));

            TaskBoardPublic updatedTaskBoard = mRepository.UpdateTaskBoard(taskBoard);

            if (updatedTaskBoard == null)
            {
                return(base.NotFound());
            }

            return(base.Created($"/taskboards/{updatedTaskBoard.ID}", updatedTaskBoard));
        }
예제 #7
0
        /// <summary>
        /// Konstruktor
        /// </summary>
        public WorkItemManagementViewModel(ITerminalContext context, TaskBoardPublic taskBoard)
        {
            Ensure.ParamNotNull(context, nameof(context));

            mContext = context;
            mContext.WorkItemMediator.CollectionUpdatedEvent += new WorkItemMediator.OnCollectionUpdated(DeleteContainer);
            mContext.WorkItemMediator.CollectionAddItemEvent += new WorkItemMediator.OnCollectionAddItem(AddWorkItemToContainer);

            mTaskBoard          = taskBoard;
            AddContainerCommand = new AsyncCommand(this.AddContainer);
            ContainerCollection = new ObservableCollection <CtrlWorkItemContainer>();

            Task.Run(() => GetContainers());
        }
예제 #8
0
        public void GetTaskBoard_OnNonExistingTaskBoard_ReturnsNull()
        {
            // ARRANGE
            DbContextOptions <TestDatabaseContext> options = new DbContextOptionsBuilder <TestDatabaseContext>()
                                                             .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                                                             .Options;
            IDatabaseContext    dbContext  = new TestDatabaseContext(options);
            TaskBoardRepository repository = new TaskBoardRepository(dbContext);

            // ACT
            TaskBoardPublic taskBoardPublic = repository.GetTaskBoard(1);

            // ASSERT
            taskBoardPublic.Should().BeNull();
        }
예제 #9
0
        public void CreateTaskBoard_OnProperBody_ReturnsCreatedTaskboard()
        {
            // ARRANGE
            ITaskBoardRepository taskBoardRepository = new MemoryTaskBoardRepository();
            TaskBoardController  controller          = new TaskBoardController(taskBoardRepository);
            TaskBoardPublic      taskBoard           = new TaskBoardPublic()
            {
                ID = 1, Name = Guid.NewGuid().ToString(), UserID = 1
            };

            // ACT
            TaskBoardPublic result = (controller.CreateTaskBoard(taskBoard) as CreatedResult).Value as TaskBoardPublic;

            // ASSERT
            result.Should().NotBeNull();
            result.Should().BeEquivalentTo <TaskBoardPublic>(taskBoard);
        }
예제 #10
0
        /// <inheritdoc/>
        public async Task <TaskBoardPublic> GetTaskboard(int ID)
        {
            TaskBoardPublic taskboard = null;

            using (HttpClient httpClient = base.CreateClient())
            {
                HttpResponseMessage response = await httpClient.GetAsync(string.Format("/taskboards/{0}", ID));

                if (response.IsSuccessStatusCode)
                {
                    string json = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                    taskboard = JsonConvert.DeserializeObject <TaskBoardPublic>(json);
                }
            }

            return(taskboard);
        }
예제 #11
0
        public IActionResult GetTaskBoard(int ID)
        {
            try
            {
                if (ID <= 0)
                {
                    return(base.Problem("Parameter has to be grater than 0"));
                }

                TaskBoardPublic taskBoard = mRepository.GetTaskBoard(ID);

                if (taskBoard == null)
                {
                    return(base.NotFound(taskBoard));
                }

                return(base.Ok(taskBoard));
            }
            catch (Exception ex)
            {
                return(base.Problem(ex.Message));
            }
        }
예제 #12
0
        /// <inheritdoc/>
        public async Task <TaskBoardPublic> UpdateTaskBoard(TaskBoardPublic taskBoard)
        {
            Ensure.ParamNotNull(taskBoard, nameof(taskBoard));

            TaskBoardPublic taskBoardResponse = null;

            using (HttpClient httpClient = base.CreateClient())
            {
                string jsonString = JsonConvert.SerializeObject(taskBoard);
                Uri    postUri    = new Uri(httpClient.BaseAddress, "/taskboards/");

                HttpResponseMessage response = await httpClient.PutAsync(postUri, new StringContent(jsonString, Encoding.UTF8, "application/json"));

                if (response.IsSuccessStatusCode)
                {
                    string json = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                    taskBoardResponse = JsonConvert.DeserializeObject <TaskBoardPublic>(json);
                }
            }

            return(taskBoardResponse);
        }
예제 #13
0
        public void GetTaskBoard_OnValidRequest_ReturnTaskBoardPublic()
        {
            // ARRANGE
            ITaskBoardRepository taskBoardRepository = new MemoryTaskBoardRepository();

            taskBoardRepository.CreateTaskBoard(new TaskBoardPublic()
            {
                ID = 1, Name = "Test", UserID = 1
            });
            TaskBoardController controller = new TaskBoardController(taskBoardRepository);

            controller.ProblemDetailsFactory = new MockProblemDetailsFactory();

            // ACT
            TaskBoardPublic result = (controller.GetTaskBoard(1) as OkObjectResult).Value as TaskBoardPublic;

            // ASSERT
            result.Should().NotBeNull();
            result.Should().BeEquivalentTo <TaskBoardPublic>(new TaskBoardPublic()
            {
                ID = 1, Name = "Test", UserID = 1
            });
        }
예제 #14
0
        public void CreateTaskBoard_OnValidObject_CreatesEntityInDatabase()
        {
            // ARRANGE
            DbContextOptions <TestDatabaseContext> options = new DbContextOptionsBuilder <TestDatabaseContext>()
                                                             .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                                                             .Options;
            IDatabaseContext    dbContext       = new TestDatabaseContext(options);
            TaskBoardRepository repository      = new TaskBoardRepository(dbContext);
            TaskBoardPublic     taskBoardPublic = new TaskBoardPublic()
            {
                Name   = Guid.NewGuid().ToString(),
                UserID = 1
            };

            // ACT
            TaskBoardPublic taskBoardCreated = repository.CreateTaskBoard(taskBoardPublic);

            // ID powinno się zwiększyć po tym jak entity framework stworzy encje w DB
            taskBoardPublic.ID = 1;

            // ASSERT
            taskBoardCreated.Should().BeEquivalentTo <TaskBoardPublic>(taskBoardPublic);
        }
예제 #15
0
        /// <summary>
        /// Tworzy nowy TaskBoard
        /// </summary>
        private async Task CreateTaskBoard()
        {
            try
            {
                HttpTaskBoardClient client = new HttpTaskBoardClient();

                TaskBoardPublic taskBoard = new TaskBoardPublic()
                {
                    Name   = "Unnamed TaskBoard",
                    UserID = mContext.UserAccount.ID
                };

                TaskBoardPublic response = await client.CreateTaskBoard(taskBoard).ConfigureAwait(false);

                await Application.Current.Dispatcher.BeginInvoke(() =>
                {
                    TaskBoards.Add(new TaskBoardContainer(response, mContext));
                });
            }
            catch (Exception)
            {
                mContext.DialogBuilder.ErrorDialog("Taskboard couldn't be created, due to server error.");
            }
        }
예제 #16
0
        public void GetTaskBoard_OnExistingTaskBoard_ReturnsTaskBoard()
        {
            // ARRANGE
            DbContextOptions <TestDatabaseContext> options = new DbContextOptionsBuilder <TestDatabaseContext>()
                                                             .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                                                             .Options;
            IDatabaseContext    dbContext  = new TestDatabaseContext(options);
            TaskBoardRepository repository = new TaskBoardRepository(dbContext);
            TaskBoardConverter  converter  = new TaskBoardConverter(dbContext);
            TaskBoard           taskBoard  = new TaskBoard()
            {
                Name = Guid.NewGuid().ToString(),
            };

            dbContext.TaskBoards.Add(taskBoard);

            dbContext.SaveChanges();

            // ACT
            TaskBoardPublic taskBoardPublic = repository.GetTaskBoard(1);

            // ASSERT
            taskBoardPublic.Should().BeEquivalentTo <TaskBoardPublic>(converter.Convert(taskBoard));
        }
예제 #17
0
        /// <inheritdoc/>
        public TaskBoardPublic GetTaskBoard(int ID)
        {
            TaskBoardPublic taskBoard = mTaskBoards.FirstOrDefault(tb => tb.ID == ID);

            return(taskBoard);
        }
예제 #18
0
 public CtrlWorkItemManagement(ITerminalContext context, TaskBoardPublic taskBoard)
 {
     InitializeComponent();
     this.DataContext = new WorkItemManagementViewModel(context, taskBoard);
 }
예제 #19
0
 /// <summary>
 /// Przekazuje taskboard z widoku do zmiennej
 /// </summary>
 /// <param name="taskBoard">kliknięty taskboard</param>
 public void SelectTaskBoard(TaskBoardPublic taskBoard)
 {
     SelectedTaskBoard = taskBoard;
     SwapCurrentView();
 }
예제 #20
0
 /// <inheritdoc/>
 public TaskBoardPublic UpdateTaskBoard(TaskBoardPublic taskBoard)
 {
     throw new System.NotImplementedException();
 }