public async Task WhenUpdate_ThenSuccess() { var headers = await _defaultRequestHeadersService.GetAsync(); var type = await _create.TaskType.BuildAsync(); var taskStatus = await _create.TaskStatus.BuildAsync(); var attribute = await _create.TaskAttribute.BuildAsync(); var task = await _create.Task .WithTypeId(type.Id) .WithStatusId(taskStatus.Id) .BuildAsync(); task.Name = "Test".WithGuid(); task.Description = "Test".WithGuid(); task.Result = "Test".WithGuid(); task.Priority = TaskPriority.Medium; task.StartDateTime = DateTime.UtcNow; task.EndDateTime = DateTime.UtcNow.AddDays(1); task.DeadLineDateTime = DateTime.UtcNow.AddDays(1); task.IsDeleted = true; task.AttributeLinks = new List <TaskAttributeLink> { new () { TaskAttributeId = attribute.Id, Value = "Test".WithGuid() } }; await _tasksClient.UpdateAsync(task, headers); var updatedTask = await _tasksClient.GetAsync(task.Id, headers); Assert.Equal(task.AccountId, updatedTask.AccountId); Assert.Equal(task.TypeId, updatedTask.TypeId); Assert.Equal(task.StatusId, updatedTask.StatusId); Assert.Equal(task.CustomerId, updatedTask.CustomerId); Assert.Equal(task.OrderId, updatedTask.OrderId); Assert.Equal(task.ResponsibleUserId, updatedTask.ResponsibleUserId); Assert.Equal(task.Name, updatedTask.Name); Assert.Equal(task.Description, updatedTask.Description); Assert.Equal(task.Result, updatedTask.Result); Assert.Equal(task.Priority, updatedTask.Priority); Assert.Equal(task.StartDateTime?.Date, updatedTask.StartDateTime?.Date); Assert.Equal(task.EndDateTime?.Date, updatedTask.EndDateTime?.Date); Assert.Equal(task.DeadLineDateTime?.Date, updatedTask.DeadLineDateTime?.Date); Assert.Equal(task.IsDeleted, updatedTask.IsDeleted); Assert.Equal(task.AttributeLinks.Single().Value, updatedTask.AttributeLinks.Single().Value); Assert.Equal( task.AttributeLinks.Single().TaskAttributeId, updatedTask.AttributeLinks.Single().TaskAttributeId); }
public async Task WhenGetPagedList_ThenSuccess() { var headers = await _defaultRequestHeadersService.GetAsync(); var type = await _create.TaskType.BuildAsync(); var status = await _create.TaskStatus.BuildAsync(); var task = await _create.Task .WithTypeId(type.Id) .WithStatusId(status.Id) .BuildAsync(); task.Name = "Test".WithGuid(); task.IsDeleted = true; await _tasksClient.UpdateAsync(task, headers); var request = new TaskChangeGetPagedListRequest { TaskId = task.Id, SortBy = "CreateDateTime", OrderBy = "asc" }; var response = await _taskChangesClient.GetPagedListAsync(request, headers); Assert.NotEmpty(response.Changes); Assert.True(response.Changes.All(x => !x.ChangerUserId.IsEmpty())); Assert.True(response.Changes.All(x => x.TaskId == task.Id)); Assert.True(response.Changes.All(x => x.CreateDateTime.IsMoreThanMinValue())); Assert.True(response.Changes.First().OldValueJson.IsEmpty()); Assert.True(!response.Changes.First().NewValueJson.IsEmpty()); Assert.NotNull(response.Changes.First().NewValueJson.FromJsonString <CrmTask>()); Assert.True(!response.Changes.Last().OldValueJson.IsEmpty()); Assert.True(!response.Changes.Last().NewValueJson.IsEmpty()); Assert.False(response.Changes.Last().OldValueJson.FromJsonString <CrmTask>().IsDeleted); Assert.True(response.Changes.Last().NewValueJson.FromJsonString <CrmTask>().IsDeleted); }