public void CreateAppWorkspaceWithAllPropertiesTest() { AppWorkspace appWorkspace = new AppWorkspace() { Title = new AtomTitle() { Text = "aTitle" }, Name = "aName", Theme = "aTheme", Default = false, Collections = new List<AppCollection>(), //TODO: Authors = new List<AtomPerson>(), //TODO: Contributors = new List<AtomPerson>() }; Assert.IsNotNull(appWorkspace); Assert.IsNotNull(appWorkspace.Title, "No title"); Assert.IsNotNull(appWorkspace.Collections); Assert.AreEqual(0, appWorkspace.Collections.Count()); Assert.IsNotNull(appWorkspace.Authors); Assert.AreEqual(0, appWorkspace.Authors.Count()); Assert.IsNotNull(appWorkspace.Contributors); Assert.AreEqual(0, appWorkspace.Contributors.Count()); Assert.AreEqual("aTitle", appWorkspace.Title.Text); Assert.AreEqual("aName", appWorkspace.Name); Assert.AreEqual("aTheme", appWorkspace.Theme); Assert.AreEqual(false, appWorkspace.Default); }
public ActionResult NewWorkspace(AdminSettingsWorkspaceModel m) { try { if (string.IsNullOrEmpty(m.Name)) throw new Exception("Name is required."); if (m.Name.ToLowerInvariant() != m.Name.CleanSlug().ToLowerInvariant()) throw new Exception("Name has invalid characters."); string workspace = m.Name.CleanSlug().ToLowerInvariant(); AppWorkspace w = new AppWorkspace() { Name = workspace }; if (string.IsNullOrEmpty(m.Title)) throw new Exception("Title is required."); w.Title = new AtomTitle() { Text = m.Title }; w.Subtitle = string.IsNullOrEmpty(m.Subtitle) ? null : new AtomSubtitle() { Text = m.Subtitle }; AppService.AddWorkspace(w); AtomPubService.UpdateService(AppService); TempData["new"] = "New Workspace"; return RedirectToAction("Settings", new { workspace = workspace }); } catch (Exception ex) { LogService.Error(ex); m.Errors.Add(ex.Message); } return View("AdminSettingsWorkspace", "Admin", m); }
public void CreateAppWorkspaceWithTitleTest() { AppWorkspace appWorkspace = new AppWorkspace() { Title = new AtomTitle() { Text = "aTitle" } }; Assert.IsNotNull(appWorkspace); Assert.IsNotNull(appWorkspace.Title, "No title"); Assert.AreEqual("aTitle", appWorkspace.Title.Text); }
public void CreateAppWorkspaceWithCollectionsTest() { AppWorkspace appWorkspace = new AppWorkspace() { Title = new AtomTitle() { Text = "aTitle" }, Collections = TestHelper.MakeAppCollections(4), }; Assert.IsNotNull(appWorkspace); Assert.IsNotNull(appWorkspace.Collections); Assert.AreEqual(4, appWorkspace.Collections.Count()); }
public static IEnumerable<AppWorkspace> ReplaceByName(this IEnumerable<AppWorkspace> workspaces, AppWorkspace replaceItem) { if (workspaces == null) { return null; } List<AppWorkspace> result = new List<AppWorkspace>(workspaces); int index = result.IndexOfName(replaceItem.Name); if (index >= 0) { result[index] = replaceItem; } return result; }
protected void MakeTestCollections(bool uniqueNames) { if (uniqueNames) { TestCollection1Name = "TestCollection1_" + Guid.NewGuid(); TestCollection2Name = "TestCollection2_" + Guid.NewGuid(); } else { TestCollection1Name = "TestCollection1"; TestCollection2Name = "TestCollection2"; } IAppServiceRepository repository = GetAppServiceRepository(); AppService service = repository.GetService(); // if the workspace does not exist, make it AppWorkspace testWorkspace = service.Workspaces.FindByName(TestWorkspaceName); if (testWorkspace == null) { testWorkspace = new AppWorkspace { Title = new AtomText { Text = "Test workspace", Type = "text" }, Name = TestWorkspaceName, Default = false }; service.Workspaces = service.Workspaces.Add(testWorkspace); repository.UpdateService(service); } // now check the collection service = repository.GetService(); testWorkspace = service.Workspaces.FindByName(TestWorkspaceName); AppCollection testCollection = testWorkspace.Collections.FindByTitle(TestCollection1Name); if (testCollection == null) { testCollection = MakeTestCollection(TestCollection1Name); testWorkspace.Collections = testWorkspace.Collections.Add(testCollection); service.Workspaces = service.Workspaces.ReplaceByName(testWorkspace); repository.UpdateService(service); } service = repository.GetService(); testWorkspace = service.Workspaces.FindByName(TestWorkspaceName); AppCollection testCollection2 = testWorkspace.Collections.FindByTitle(TestCollection2Name); if (testCollection2 == null) { testCollection2 = MakeTestCollection(TestCollection2Name); testWorkspace.Collections = testWorkspace.Collections.Add(testCollection2); service.Workspaces = service.Workspaces.ReplaceByName(testWorkspace); repository.UpdateService(service); } }
public ContactAppWorkspace(AppWorkspace ws) : base(ws.Xml) { }
public void CreateAppWorkspaceWithContributorsTest() { AppWorkspace appWorkspace = new AppWorkspace() { Title = new AtomTitle() { Text = "aTitle" }, //TODO: Contributors = TestHelper.MakePersonList(4, Atom.AtomNs + "contributor"), Contributors = Enumerable.Repeat<string>("contributor",4) }; Assert.IsNotNull(appWorkspace); Assert.IsNotNull(appWorkspace.Contributors); Assert.AreEqual(4, appWorkspace.Contributors.Count()); }
public IEnumerable<AppCollection> GetMetricCollections(AppWorkspace w, string startsWith) { return ScopesWithMetricsFor(startsWith) .Where(m => m.Scope.Workspace == (w.Name ?? Atom.DefaultWorkspaceName)) .Select(m => Service.GetCollection(m.Scope.Workspace, m.Scope.Collection)); }
public static AppWorkspace MakeTestWorkspace() { AppWorkspace result = new AppWorkspace { Title = new AtomText { Text = "Test workspace title " + Guid.NewGuid(), Type = "text" }, Name = "Test workspace name" + Guid.NewGuid(), Default = false }; return result; }