Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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}");
        }
Esempio n. 8
0
        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}");
        }