public void Check_Inventory() { InventoryService target = new InventoryService(mock.Object); bool result1 = target.CheckInventory(1, 5); bool result2 = target.CheckInventory(2, 30); Assert.IsTrue(result1); Assert.IsFalse(result2); }
public bool CheckInventory(Shop.ProfileTheme theme) { return(InventoryService.CheckInventory(theme, this)); }
public void LoadAppearanceFromNotecard(Notecard nc) { AppearanceInfo appearance = AppearanceInfo.FromNotecard(nc); InventoryService.CheckInventory(ID); InventoryService.Folder.Purge(InventoryService.Folder[ID, AssetType.CurrentOutfitFolder].ID); UUID bodypartsFolder = InventoryService.Folder[ID, AssetType.Bodypart].ID; UUID clothingFolder = InventoryService.Folder[ID, AssetType.Clothing].ID; UUID objectFolder = InventoryService.Folder[ID, AssetType.Object].ID; UUID currentOutfitFolder = InventoryService.Folder[ID, AssetType.CurrentOutfitFolder].ID; var attachmentsToRez = new List <InventoryItem>(); /* generate inventory entries for wearables */ foreach (KeyValuePair <WearableType, List <AgentWearables.WearableInfo> > kvp in appearance.Wearables.All) { UUID targetFolder = clothingFolder; var assetType = AssetType.Clothing; switch (kvp.Key) { case WearableType.Shape: case WearableType.Skin: case WearableType.Hair: case WearableType.Eyes: case WearableType.Physics: targetFolder = bodypartsFolder; assetType = AssetType.Bodypart; break; } int layer = 0; foreach (AgentWearables.WearableInfo wInfo in kvp.Value) { var item = new InventoryItem(wInfo.ItemID) { AssetID = wInfo.AssetID, LastOwner = Owner, Owner = Owner, Creator = UGUI.Unknown, InventoryType = InventoryType.Wearable, AssetType = assetType, Flags = (InventoryFlags)(uint)kvp.Key, Name = wInfo.ItemID.ToString(), ParentFolderID = targetFolder }; item.Permissions.Base = InventoryPermissionsMask.None; item.Permissions.Current = InventoryPermissionsMask.None; item.Permissions.EveryOne = InventoryPermissionsMask.None; item.Permissions.Group = InventoryPermissionsMask.None; item.Permissions.NextOwner = InventoryPermissionsMask.None; try { InventoryService.Item.Add(item); } catch { InventoryService.Item.Update(item); } item = new InventoryItem { LastOwner = Owner, Owner = Owner, Creator = Owner, InventoryType = InventoryType.Wearable, AssetType = AssetType.Link, AssetID = wInfo.ItemID, ParentFolderID = currentOutfitFolder, Name = wInfo.AssetID.ToString(), Description = "@" + layer.ToString() }; item.Permissions.Base = InventoryPermissionsMask.All; item.Permissions.Current = InventoryPermissionsMask.All; item.Permissions.EveryOne = InventoryPermissionsMask.None; item.Permissions.Group = InventoryPermissionsMask.None; item.Permissions.NextOwner = InventoryPermissionsMask.None; InventoryService.Item.Add(item); ++layer; } } /* generate inventory entries for attachments */ foreach (KeyValuePair <AttachmentPoint, RwLockedDictionary <UUID, UUID> > kvp in appearance.Attachments) { foreach (KeyValuePair <UUID, UUID> kvpInner in kvp.Value) { var item = new InventoryItem(kvpInner.Key) { AssetID = kvpInner.Value, LastOwner = Owner, Owner = Owner, Creator = UGUI.Unknown, ParentFolderID = objectFolder, InventoryType = InventoryType.Object, AssetType = AssetType.Object, Flags = (InventoryFlags)(uint)kvp.Key, Name = kvpInner.Key.ToString() }; item.Permissions.Base = InventoryPermissionsMask.None; item.Permissions.Current = InventoryPermissionsMask.None; item.Permissions.EveryOne = InventoryPermissionsMask.None; item.Permissions.Group = InventoryPermissionsMask.None; item.Permissions.NextOwner = InventoryPermissionsMask.None; try { InventoryService.Item.Add(item); } catch { InventoryService.Item.Update(item); } attachmentsToRez.Add(item); } } DetachAllAttachments(); foreach (InventoryItem item in attachmentsToRez) { AssetData data; try { data = AssetService[item.AssetID]; } catch (Exception e) { m_Log.WarnFormat("Fetch error for object asset {0} for NPC {1} {2} ({3}): {4}: {5}", item.AssetID, NamedOwner.FirstName, NamedOwner.LastName, NamedOwner.ID, e.GetType().FullName, e.ToString()); break; } if (data.Type != AssetType.Object) { m_Log.WarnFormat("Wrong asset for object asset {0} for NPC {1} {2} ({3})", item.AssetID, NamedOwner.FirstName, NamedOwner.LastName, NamedOwner.ID); break; } AttachFromInventory(data, item.ID); } try { RebakeAppearance(); } catch { m_Log.WarnFormat("Failed to rebake NPC {0} {1} ({2})", NamedOwner.FirstName, NamedOwner.LastName, NamedOwner.ID); } }