public async Task BranchWorkspaceTest()
        {
            Workspace workspaceTemplate = CreateWorkspaceTemplate();
            Workspace result            = await service.CreateWorkspace(workspaceTemplate);

            Workspace myBranch = await service.BranchWorkspace(result.Id, new WorkspaceBranchRequest("myBranch"));

            Assert.True(result.Id == myBranch.Origin.Id);
            Assert.True("myBranch" == myBranch.Name);
            Assert.True(result.VersionCounter == myBranch.Origin.VersionCounter);

            // rolling back
            await service.DeleteWorkspace(result.Id);
        }
예제 #2
0
        public async void BranchWorkspaceTest()
        {
            Workspace workspaceTemplate = CreateWorkspaceTemplate();
            Workspace result            = await service.CreateWorkspace(workspaceTemplate);

            Workspace myBranch = await service.BranchWorkspace(result.Id, new WorkspaceBranchRequest("myBranch"));

            Assert.True(result.Id == myBranch.Origin.Id);
            Assert.True("myBranch" == myBranch.Name);

            Assert.True(result.VersionCounter == myBranch.Origin.VersionCounter);
            List <WorkspaceBranch> branches = await service.GetBranches(result.Id);

            Assert.True(1 == branches.Count);
            Assert.True(myBranch.Name == branches[0].BranchName);

            // rolling back
            await service.DeleteWorkspace(result.Id);
        }
        public IActionResult CreateWorkspace([FromBody] CreateWorkspaceRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new
                {
                    Errors = ModelState.Values.SelectMany(x => x.Errors.Select(xx => xx.ErrorMessage))
                }));
            }

            bool result = _workspaceService.CreateWorkspace(request.Name, _user.Id);

            if (!result)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  new { Error = "Server error" }));
            }
            return(Ok());
        }