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(); }
/// <inheritdoc/> public TaskBoardPublic CreateTaskBoard(TaskBoardPublic taskBoard) { Ensure.ParamNotNull(taskBoard, nameof(taskBoard)); mTaskBoards.Add(taskBoard); return(taskBoard); }
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; }
public virtual IActionResult CreateTaskBoard([FromBody] TaskBoardPublic taskBoard) { Ensure.ParamNotNull(taskBoard, nameof(taskBoard)); TaskBoardPublic createdTaskBoard = mRepository.CreateTaskBoard(taskBoard); return(base.Created($"/taskboards/{createdTaskBoard.ID}", createdTaskBoard)); }
/// <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)); }
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()); }
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(); }
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); }
/// <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); }
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)); } }
/// <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); }
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 }); }
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); }
/// <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."); } }
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)); }
/// <inheritdoc/> public TaskBoardPublic GetTaskBoard(int ID) { TaskBoardPublic taskBoard = mTaskBoards.FirstOrDefault(tb => tb.ID == ID); return(taskBoard); }
public CtrlWorkItemManagement(ITerminalContext context, TaskBoardPublic taskBoard) { InitializeComponent(); this.DataContext = new WorkItemManagementViewModel(context, taskBoard); }
/// <summary> /// Przekazuje taskboard z widoku do zmiennej /// </summary> /// <param name="taskBoard">kliknięty taskboard</param> public void SelectTaskBoard(TaskBoardPublic taskBoard) { SelectedTaskBoard = taskBoard; SwapCurrentView(); }
/// <inheritdoc/> public TaskBoardPublic UpdateTaskBoard(TaskBoardPublic taskBoard) { throw new System.NotImplementedException(); }