Ejemplo n.º 1
0
        public void CanCreateAndEditWorkspace()
        {
            using (TestSession test = CreateSession())
            {
                _options.DefaultWorkspaceLimit = 3;
                test.AddActor("*****@*****.**");
                WorkspaceService mgr  = test.GetTopologyManager();
                Workspace        topo = mgr.Create(new NewWorkspace {
                    Name        = "JamOn",
                    Description = "original"
                }).Result;

                Assert.True(topo.Id > 0);
                Assert.True(topo.CanManage);
                Assert.True(topo.CanEdit);

                topo = mgr.Update(new ChangedWorkspace {
                    Id          = topo.Id,
                    Name        = topo.Name + "Changed",
                    Description = topo.Description
                }).Result;
                Assert.Matches("Changed", topo.Name);
                Assert.Equal("original", topo.Description);
            }
        }
Ejemplo n.º 2
0
        public void CanLinkTemplate()
        {
            using (TestSession test = CreateSession())
            {
                //test.AddActor("*****@*****.**");
                WorkspaceService topoman = test.GetTopologyManager();
                Workspace        topo    = topoman.Create(new NewWorkspace {
                    Name = "jamTopo"
                }).Result;
                TemplateService mgr = test.GetTemplateManager();
                for (int i = 1; i < 6; i++)
                {
                    TemplateDetail template = mgr.Create(new TemplateDetail {
                        Name = "JamOn" + i.ToString(),
                        // Detail = "",
                        IsPublished = (i % 2 == 1)
                    }).Result;
                }

                Template t = mgr.Link(new TemplateLink {
                    TemplateId = 5, WorkspaceId = topo.Id
                }).Result;
                t = mgr.Unlink(new TemplateLink {
                    TemplateId = t.Id
                }).Result;
                var list = mgr.List(new Search {
                    Take = 50,
                    //Term = "2",
                    Filter = new string[] {
                        //"published"
                    }
                }).Result;
                Assert.True(list.Length == 6);
            }
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <Workspace> > CreateWorkspace([FromBody] NewWorkspace model)
        {
            await Validate(model);

            AuthorizeAny(
                () => Actor.IsAdmin,
                () => Actor.IsCreator,
                () => _svc.CheckWorkspaceLimit(Actor.Id).Result
                );

            return(Ok(
                       await _svc.Create(model, Actor.Id, Actor.Name)
                       ));
        }
Ejemplo n.º 4
0
        public void ListReturnsList()
        {
            using (TestSession test = CreateSession())
            {
                test.AddActor("*****@*****.**");
                WorkspaceService mgr = test.GetTopologyManager();
                for (int i = 0; i < 5; i++)
                {
                    Workspace topo = mgr.Create(new NewWorkspace {
                        Name        = "JamOn" + i.ToString(),
                        Description = i.ToString()
                    }).Result;

                    if (i > 2)
                    {
                        topo.IsPublished = true;
                        mgr.Update(new ChangedWorkspace
                        {
                            Id            = topo.Id,
                            Name          = topo.Name,
                            Description   = topo.Description,
                            Author        = topo.Author,
                            IsPublished   = true,
                            Audience      = topo.Audience,
                            TemplateLimit = topo.TemplateLimit
                        }).Wait();
                        // mgr.Publish(topo.Id, false).Wait();
                    }
                }

                var list = mgr.List(new Search {
                    Take = 50,
                    //Term = "2",
                    Filter = new string[] {
                        "published",
                        "mine"
                    }
                }).Result;
                Assert.True(list.Length == 2);
            }
        }
Ejemplo n.º 5
0
        public async Task <ActionResult <Workspace> > Create([FromBody] NewWorkspace model)
        {
            Workspace workspace = await _workspaceService.Create(model);

            return(Created(Url.Action("Load", new { Id = workspace.Id }), workspace));
        }