public void Remove_ProperlyLocksRegions( ISimpleGameObject simpleGameObject, [Frozen] IRegionLocator regionLocator, IRegion region0, IRegion region1, IRegion region2, [Frozen] ITileLocator tileLocator, RegionManager regionManager) { simpleGameObject.InWorld.Returns(true); regionLocator.GetRegionIndex(0, 0).ReturnsForAnyArgs <ushort>(2); regionLocator.GetRegionIndex(1, 1).Returns <ushort>(0); regionLocator.GetRegionIndex(1, 2).Returns <ushort>(0); regionLocator.GetRegionIndex(2, 1).Returns <ushort>(1); tileLocator.ForeachMultitile(0, 0, 0).ReturnsForAnyArgs(new[] { new Position(1, 1), new Position(2, 1), }); regionManager.AddRegion(region0); regionManager.AddRegion(region1); regionManager.AddRegion(region2); regionManager.Remove(simpleGameObject); region0.Received(1).EnterWriteLock(); region1.Received(1).EnterWriteLock(); region0.Received(1).ExitWriteLock(); region1.Received(1).ExitWriteLock(); region2.DidNotReceive().EnterWriteLock(); }
public void Add_ShouldAddObjectToAllTiles( ISimpleGameObject simpleGameObject, [Frozen] IRegionLocator regionLocator, IRegion region0, IRegion region1, IRegion region2, [Frozen] ITileLocator tileLocator, RegionManager regionManager) { simpleGameObject.PrimaryPosition.Returns(new Position(1, 2)); regionLocator.GetRegionIndex(0, 0).ReturnsForAnyArgs <ushort>(2); regionLocator.GetRegionIndex(1, 1).Returns <ushort>(0); regionLocator.GetRegionIndex(1, 2).Returns <ushort>(0); regionLocator.GetRegionIndex(2, 1).Returns <ushort>(1); tileLocator.ForeachMultitile(simpleGameObject).Returns(new[] { new Position(1, 1), new Position(1, 2), new Position(2, 1), }); regionManager.AddRegion(region0); regionManager.AddRegion(region1); regionManager.AddRegion(region2); regionManager.Add(simpleGameObject); region0.Received(1).AddObjectToTile(simpleGameObject, 1, 1); region0.Received(1).AddObjectToTile(simpleGameObject, 1, 2); region1.Received(1).AddObjectToTile(simpleGameObject, 2, 1); region2.DidNotReceive().AddObjectToTile(Arg.Any <ISimpleGameObject>(), Arg.Any <uint>(), Arg.Any <uint>()); }
public void Add_ShouldAddObjectToPrimaryRegion( ISimpleGameObject simpleGameObject, [Frozen] IRegionLocator regionLocator, IRegion region0, IRegion region1, RegionManager regionManager) { simpleGameObject.PrimaryPosition.Returns(new Position(1, 2)); regionLocator.GetRegionIndex(simpleGameObject.PrimaryPosition.X, simpleGameObject.PrimaryPosition.Y).Returns <ushort>(1); regionManager.AddRegion(region0); regionManager.AddRegion(region1); regionManager.Add(simpleGameObject); region0.DidNotReceive().Add(simpleGameObject); region1.Received(1).Add(simpleGameObject); }
public void Remove_RemovesObjectFromAllTiles( ISimpleGameObject simpleGameObject, [Frozen] IRegionLocator regionLocator, IRegion region0, IRegion region1, IRegion region2, [Frozen] ITileLocator tileLocator, RegionManager regionManager) { simpleGameObject.InWorld.Returns(true); simpleGameObject.PrimaryPosition.Returns(new Position(1, 2)); simpleGameObject.Size.Returns <byte>(10); regionLocator.GetRegionIndex(0, 0).ReturnsForAnyArgs <ushort>(2); regionLocator.GetRegionIndex(1, 1).Returns <ushort>(0); regionLocator.GetRegionIndex(1, 2).Returns <ushort>(0); regionLocator.GetRegionIndex(2, 1).Returns <ushort>(1); tileLocator.ForeachMultitile(1, 2, 10).Returns(new[] { new Position(1, 1), new Position(1, 2), new Position(2, 1), }); regionManager.AddRegion(region0); regionManager.AddRegion(region1); regionManager.AddRegion(region2); regionManager.Remove(simpleGameObject); region0.Received(1).Remove(simpleGameObject, 1, 2); region0.Received(1).RemoveObjectFromTile(simpleGameObject, 1, 1); region0.Received(1).RemoveObjectFromTile(simpleGameObject, 1, 2); region1.Received(1).RemoveObjectFromTile(simpleGameObject, 2, 1); region2.DidNotReceive().RemoveObjectFromTile(Arg.Any <ISimpleGameObject>(), Arg.Any <uint>(), Arg.Any <uint>()); }