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 CanGetCatalogItems() { string catalogName = $"{nameof(CanGetCatalogItems)}_TestCatalog"; string testItemName = $"{nameof(CanGetCatalogItems)}_TestItem"; string testItemName2 = $"{nameof(CanGetCatalogItems)}_TestItem2"; CatalogService svc = GetTestCatalogService(catalogName, nameof(CanGetCatalogItems)); CatalogDefinition catalogDefinition = svc.FindCatalog(catalogName); ItemDefinition itemOne = svc.AddItem(catalogDefinition, testItemName, out CatalogItem xref); Expect.IsNotNull(xref); ItemDefinition itemTwo = svc.AddItem(catalogDefinition, testItemName2, out CatalogItem xref2); Expect.IsNotNull(xref2); CatalogDefinition retrievedCatalog = svc.GetCatalog(catalogDefinition); Expect.AreEqual(2, retrievedCatalog.Items.Count); retrievedCatalog.Items.Contains(itemOne).IsTrue(); retrievedCatalog.Items.Contains(itemTwo).IsTrue(); }
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 CanAddItemToCatalog() { string testCatalogName = nameof(CanAddItemToCatalog); string testItemName = "testItem_".RandomLetters(6); CatalogService svc = GetTestCatalogService(testCatalogName); CatalogDefinition catalogDefinition = svc.FindCatalog(testCatalogName); ItemDefinition item = svc.AddItem(catalogDefinition, testItemName); catalogDefinition = svc.GetCatalog(catalogDefinition.Key); Expect.AreEqual(1, catalogDefinition.Items.Count); Expect.AreEqual(testItemName, catalogDefinition.Items[0].Name); }
public void CanAddAndGetItem() { string catalogName = $"{nameof(CanAddAndGetItem)}_TestCatalog"; string testItemName = $"{nameof(CanAddAndGetItem)}_TestItem"; CatalogService svc = GetTestCatalogService(catalogName, nameof(CanAddAndGetItem)); ItemDefinition item = svc.AddItem(svc.FindCatalog(catalogName), testItemName); ItemDefinition retrieved = svc.GetItem(item); Expect.AreEqual(retrieved, item); Expect.AreEqual(retrieved.Name, item.Name); Expect.AreEqual(testItemName, retrieved.Name); }
public void CanAddItemProperties() { string testCatalogName = nameof(CanAddItemProperties); string testItemName = "testItem_".RandomLetters(6); CatalogService svc = GetTestCatalogService(testCatalogName); CatalogDefinition catalogDefinition = svc.FindCatalog(testCatalogName); ItemDefinition item = svc.AddItem(catalogDefinition, testItemName); List <ItemProperty> properties = svc.AddItemProperties(item, new { TailCount = 5, FallopianTubes = true }).ToList(); Expect.AreEqual(2, properties.Count); Expect.AreEqual("5", properties.First(p => p.Name.Equals("TailCount")).Value); Expect.AreEqual("True", properties.First(p => p.Name.Equals("FallopianTubes")).Value); }
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 CanRemoveItemFromCatalogWithoutDeletingItem() { string testCatalogName = nameof(CanRemoveItemFromCatalogWithoutDeletingItem); string testItemName = "testItem_".RandomLetters(4); CatalogService svc = GetTestCatalogService(testCatalogName); CatalogDefinition catalogDefinition = svc.FindCatalog(testCatalogName); ItemDefinition item = svc.AddItem(catalogDefinition, testItemName); catalogDefinition = svc.GetCatalog(catalogDefinition); Expect.AreEqual(1, catalogDefinition.Items.Count); svc.RemoveItem(catalogDefinition, item); catalogDefinition = svc.GetCatalog(catalogDefinition); Expect.AreEqual(0, catalogDefinition.Items.Count); item = svc.GetItem(item); Expect.IsNotNull(item); }
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}"); }