Example #1
0
        public async Task WhenCreate_ThenSuccess()
        {
            var headers = await _defaultRequestHeadersService.GetAsync();

            var attribute = await _create.TaskAttribute.BuildAsync();

            var type = await _create.TaskType.BuildAsync();

            var taskStatus = await _create.TaskStatus.BuildAsync();

            var task = new CrmTask
            {
                Id               = Guid.NewGuid(),
                TypeId           = type.Id,
                StatusId         = taskStatus.Id,
                Name             = "Test".WithGuid(),
                Description      = "Test".WithGuid(),
                Result           = "Test".WithGuid(),
                Priority         = TaskPriority.Medium,
                StartDateTime    = DateTime.UtcNow,
                EndDateTime      = DateTime.UtcNow.AddDays(1),
                DeadLineDateTime = DateTime.UtcNow.AddDays(2),
                IsDeleted        = true,
                AttributeLinks   = new List <TaskAttributeLink>
                {
                    new ()
                    {
                        TaskAttributeId = attribute.Id,
                        Value           = "Test".WithGuid()
                    }
                }
            };

            var taskId = await _tasksClient.CreateAsync(task, headers);

            var createdTask = await _tasksClient.GetAsync(taskId, headers);

            Assert.NotNull(createdTask);
            Assert.Equal(taskId, createdTask.Id);
            Assert.Equal(task.TypeId, createdTask.TypeId);
            Assert.Equal(task.StatusId, createdTask.StatusId);
            Assert.Equal(task.CustomerId, createdTask.CustomerId);
            Assert.Equal(task.OrderId, createdTask.OrderId);
            Assert.True(!createdTask.CreateUserId.IsEmpty());
            Assert.Equal(task.ResponsibleUserId, createdTask.ResponsibleUserId);
            Assert.Equal(task.Name, createdTask.Name);
            Assert.Equal(task.Description, createdTask.Description);
            Assert.Equal(task.Result, createdTask.Result);
            Assert.Equal(task.Priority, createdTask.Priority);
            Assert.Equal(task.StartDateTime?.Date, createdTask.StartDateTime?.Date);
            Assert.Equal(task.EndDateTime?.Date, createdTask.EndDateTime?.Date);
            Assert.Equal(task.DeadLineDateTime?.Date, createdTask.DeadLineDateTime?.Date);
            Assert.Equal(task.IsDeleted, createdTask.IsDeleted);
            Assert.True(createdTask.CreateDateTime.IsMoreThanMinValue());
            Assert.NotEmpty(createdTask.AttributeLinks);
        }
Example #2
0
        public async Task <CrmTask> BuildAsync()
        {
            var headers = await _defaultRequestHeadersService.GetAsync();

            if (_task.TypeId.IsEmpty())
            {
                throw new InvalidOperationException(nameof(_task.TypeId));
            }

            if (_task.StatusId.IsEmpty())
            {
                throw new InvalidOperationException(nameof(_task.StatusId));
            }

            var id = await _tasksClient.CreateAsync(_task, headers);

            return(await _tasksClient.GetAsync(id, headers));
        }