Files
libremetaverse/LibreMetaverse.RLV.Tests/Commands/DetachMeCommandTests.cs
nooperation 44103df8c1 Combined 'TryGetSharedFolderAsync' and 'TryGetCurrentOutfitAsync' and the creation of an inventory map into 'TryGetInventoryMapAsync'
Easier to differentiate between items in the shared #RLV folder and attached items that are not in the shared folder
Minor internal refactoring
Updated tests
2025-08-21 04:58:45 -04:00

140 lines
4.9 KiB
C#

using Moq;
namespace LibreMetaverse.RLV.Tests.Commands
{
public class DetachMeCommandTests : RestrictionsBase
{
#region @detachme=force
[Fact]
public async Task DetachMeForce()
{
// #RLV
// |
// |- .private
// |
// |- Clothing
// | |= Business Pants
// | |= Happy Shirt (attached spine)
// | |= Retro Pants (attached pelvis) <-- Expected detach
// | \- Hats
// | |
// | |- Sub Hats
// | | \ (Empty)
// | |
// | |= Fancy Hat
// | \= Party Hat
// \-Accessories
// |= Watch
// \= Glasses
var sampleTree = SampleInventoryTree.BuildInventoryTree();
var sharedFolder = sampleTree.Root;
sampleTree.Root_Clothing_RetroPants.AttachedTo = RlvAttachmentPoint.Pelvis;
sampleTree.Root_Clothing_RetroPants.AttachedPrimId = new Guid("11111111-0002-4aaa-8aaa-ffffffffffff");
sampleTree.Root_Clothing_HappyShirt.AttachedTo = RlvAttachmentPoint.Spine;
sampleTree.Root_Clothing_HappyShirt.AttachedPrimId = new Guid("11111111-0003-4aaa-8aaa-ffffffffffff");
var inventoryMap = new InventoryMap(sharedFolder, []);
_queryCallbacks.Setup(e =>
e.TryGetInventoryMapAsync(default)
).ReturnsAsync((true, inventoryMap));
_actionCallbacks.Setup(e =>
e.DetachAsync(It.IsAny<IReadOnlyList<Guid>>(), It.IsAny<CancellationToken>())
).Returns(Task.CompletedTask);
var expected = new HashSet<Guid>()
{
sampleTree.Root_Clothing_RetroPants.Id,
};
// Act
await _rlv.ProcessMessage("@detachme=force", sampleTree.Root_Clothing_RetroPants.AttachedPrimId!.Value, sampleTree.Root_Clothing_RetroPants.Name);
// Assert
_actionCallbacks.Verify(e =>
e.DetachAsync(
It.Is<IReadOnlyList<Guid>>(ids =>
ids != null &&
ids.Count == expected.Count &&
expected.SetEquals(ids)
),
It.IsAny<CancellationToken>()
),
Times.Once
);
_actionCallbacks.VerifyNoOtherCalls();
}
[Fact]
public async Task DetachMeForce_IgnoreNoStrip()
{
// #RLV
// |
// |- .private
// |
// |- Clothing
// | |= Business Pants
// | |= Happy Shirt (attached spine)
// | |= nostrip Retro Pants (attached pelvis) <-- Expected detach
// | \- Hats
// | |
// | |- Sub Hats
// | | \ (Empty)
// | |
// | |= Fancy Hat
// | \= Party Hat
// \-Accessories
// |= Watch
// \= Glasses
var sampleTree = SampleInventoryTree.BuildInventoryTree();
var sharedFolder = sampleTree.Root;
sampleTree.Root_Clothing_RetroPants.Name = "nostrip Retro Pants";
sampleTree.Root_Clothing_RetroPants.AttachedTo = RlvAttachmentPoint.Pelvis;
sampleTree.Root_Clothing_RetroPants.AttachedPrimId = new Guid("11111111-0002-4aaa-8aaa-ffffffffffff");
sampleTree.Root_Clothing_HappyShirt.AttachedTo = RlvAttachmentPoint.Spine;
sampleTree.Root_Clothing_HappyShirt.AttachedPrimId = new Guid("11111111-0003-4aaa-8aaa-ffffffffffff");
var inventoryMap = new InventoryMap(sharedFolder, []);
_queryCallbacks.Setup(e =>
e.TryGetInventoryMapAsync(default)
).ReturnsAsync((true, inventoryMap));
_actionCallbacks.Setup(e =>
e.DetachAsync(It.IsAny<IReadOnlyList<Guid>>(), It.IsAny<CancellationToken>())
).Returns(Task.CompletedTask);
var expected = new HashSet<Guid>()
{
sampleTree.Root_Clothing_RetroPants.Id,
};
// Act
await _rlv.ProcessMessage("@detachme=force", sampleTree.Root_Clothing_RetroPants.AttachedPrimId!.Value, sampleTree.Root_Clothing_RetroPants.Name);
// Assert
_actionCallbacks.Verify(e =>
e.DetachAsync(
It.Is<IReadOnlyList<Guid>>(ids =>
ids != null &&
ids.Count == expected.Count &&
expected.SetEquals(ids)
),
It.IsAny<CancellationToken>()
),
Times.Once
);
_actionCallbacks.VerifyNoOtherCalls();
}
#endregion
}
}