示例#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));
        }
        /// <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();
 }