public void CanCreateItem() { string itemName = "Test Item Name ".RandomLetters(4); CatalogService svc = _serviceRegistry.Get <CatalogService>(); ItemDefinition item = svc.CreateItem(itemName); Expect.IsNotNull(item); Expect.AreEqual(itemName, item.Name); }
public void CanAddItemToCatalog() { string itemName = "Test AddItem ".RandomLetters(6); CatalogService svc = _serviceRegistry.Get <CatalogService>(); CatalogDefinition catalog = svc.CreateCatalog(5.RandomLetters()); ItemDefinition item = svc.CreateItem(6.RandomLetters()); svc.AddItem(catalog.Cuid, item.Cuid); catalog = svc.GetCatalog(catalog.Cuid); Expect.IsTrue(catalog.Items.Select(i => i.Cuid.Equals(item.Cuid)).Count() == 1); }
public void CanDeleteItem() { string itemName = "Test RenameItem ".RandomLetters(8); string newName = "New Name ".RandomLetters(8); CatalogService svc = _serviceRegistry.Get <CatalogService>(); CatalogDefinition catalog = svc.CreateCatalog(5.RandomLetters()); ItemDefinition item = svc.CreateItem(itemName); svc.DeleteItem(item.Cuid); ItemDefinition shouldBeNull = svc.GetItem(item.Cuid); Expect.IsNull(shouldBeNull); }
public void CanGetItem() { string itemName = "Test RenameItem ".RandomLetters(8); string newName = "New Name ".RandomLetters(8); CatalogService svc = _serviceRegistry.Get <CatalogService>(); CatalogDefinition catalog = svc.CreateCatalog(5.RandomLetters()); ItemDefinition item = svc.CreateItem(itemName); ItemDefinition gotItem = svc.GetItem(item.Cuid); Expect.IsNotNull(gotItem); Expect.AreEqual(item.Cuid, gotItem.Cuid); Expect.AreEqual(item.Name, gotItem.Name); }
public void CanCreateAndGetItem() { string testCatalogName = nameof(CanCreateAndGetItem); string testItemName = "testItem_".RandomLetters(6); CatalogService svc = GetTestCatalogService(testCatalogName); ItemDefinition itemDefinition = svc.CreateItem(testItemName); Expect.AreEqual(testItemName, itemDefinition.Name); Expect.IsNotNullOrEmpty(itemDefinition.Uuid); Expect.IsNotNullOrEmpty(itemDefinition.Cuid); ItemDefinition retrieved = svc.GetItem(itemDefinition); Expect.AreEqual(itemDefinition, retrieved); }
public void ShouldFindItemCatalogs() { string itemName = "Test RenameItem ".RandomLetters(8); string newName = "New Name ".RandomLetters(8); CatalogService svc = _serviceRegistry.Get <CatalogService>(); CatalogDefinition catalog = svc.CreateCatalog(5.RandomLetters()); CatalogDefinition catalog2 = svc.CreateCatalog(6.RandomLetters()); ItemDefinition item = svc.CreateItem(itemName); svc.AddItem(catalog.Cuid, item.Cuid); svc.AddItem(catalog2.Cuid, item.Cuid); string[] catalogCuids = svc.FindItemCatalogs(item.Cuid); Expect.AreEqual(2, catalogCuids.Length); }
public void CanRemoveItemFromCatalog() { string itemName = "Test AddItem ".RandomLetters(6); CatalogService svc = _serviceRegistry.Get <CatalogService>(); CatalogDefinition catalog = svc.CreateCatalog(5.RandomLetters()); ItemDefinition item = svc.CreateItem(6.RandomLetters()); svc.AddItem(catalog.Cuid, item.Cuid); catalog = svc.GetCatalog(catalog.Cuid); List <ItemDefinition> items = catalog.Items.Where(i => i.Cuid.Equals(item.Cuid)).ToList(); Expect.IsTrue(items.Count == 1, $"Expected 1 catalog item but there were {items.Count}"); svc.RemoveItem(catalog.Cuid, item.Cuid); catalog = svc.GetCatalog(catalog.Cuid); items = catalog.Items.Where(i => i.Cuid.Equals(item.Cuid)).ToList(); Expect.IsTrue(items.Count == 0, $"Expected 0 catalog items but there were {items.Count}"); }
public void CanRenameItem() { string itemName = "Test RenameItem ".RandomLetters(8); string newName = "New Name ".RandomLetters(8); CatalogService svc = _serviceRegistry.Get <CatalogService>(); CatalogDefinition catalog = svc.CreateCatalog(5.RandomLetters()); ItemDefinition item = svc.CreateItem(itemName); svc.AddItem(catalog.Cuid, item.Cuid); catalog = svc.GetCatalog(catalog.Cuid); List <ItemDefinition> namedItems = catalog.Items.Where(i => i.Name.Equals(itemName)).ToList(); Expect.IsTrue(namedItems.Count == 1, $"expected 1 item in catalog but there were {namedItems.Count}"); svc.RenameItem(item.Cuid, newName); catalog = svc.GetCatalog(catalog.Cuid); List <ItemDefinition> oldNamedItems = catalog.Items.Where(i => i.Name.Equals(itemName)).ToList(); Expect.IsTrue(oldNamedItems.Count == 0); List <ItemDefinition> newNamedItems = catalog.Items.Where(i => i.Name.Equals(newName)).ToList(); Expect.IsTrue(newNamedItems.Count == 1, $"Expected 1 new item but there were {newNamedItems.Count}"); }