Exemplo n.º 1
0
        public void CopyFrom_NullRegion_ThrowsArgumentNullException()
        {
            var extent = Mock.Of <Extent>();

            // ReSharper disable once AssignNullToNotNullAttribute
            Assert.That(() => Clipboard.CopyFrom(extent, null), Throws.ArgumentNullException);
        }
Exemplo n.º 2
0
        public void CopyFrom()
        {
            var tileEntity = Mock.Of <ITileEntity>(e => e.Position == Vector.One);

            Mock.Get(tileEntity)
            .Setup(e => e.WithPosition(Vector.Zero))
            .Returns((Vector v) => Mock.Of <ITileEntity>(e => e.Position == v));
            var tile = new Tile {
                WallId = 1
            };
            var extent = Mock.Of <Extent>(e => e.Dimensions == new Vector(5, 5) &&
                                          e.GetTileEntities() == new[] { tileEntity } &&
                                          e.GetTile(It.IsAny <Vector>()) == tile);
            var region = Mock.Of <Region>(r => r.LowerBound == Vector.One && r.UpperBound == new Vector(5, 5));

            Mock.Get(region).Setup(r => r.Contains(It.IsAny <Vector>())).Returns((Vector v) => true);
            Mock.Get(region)
            .As <IEnumerable <Vector> >()
            .Setup(r => r.GetEnumerator())
            .Returns(() => region.GetEnumerator());

            var clipboard = Clipboard.CopyFrom(extent, region);

            for (var x = 0; x < 4; ++x)
            {
                for (var y = 0; y < 4; ++y)
                {
                    Assert.That(clipboard.GetTile(new Vector(x, y)), Is.EqualTo(tile));
                }
            }
            var tileEntities = clipboard.GetTileEntities().ToList();

            Assert.That(tileEntities, Has.Count.EqualTo(1));
            Assert.That(tileEntities[0].Position, Is.EqualTo(Vector.Zero));
        }
Exemplo n.º 3
0
        public void CopyFrom_NullExtent_ThrowsArgumentNullException()
        {
            var region = Mock.Of <Region>();

            // ReSharper disable once AssignNullToNotNullAttribute
            Assert.That(() => Clipboard.CopyFrom(null, region), Throws.ArgumentNullException);
        }
Exemplo n.º 4
0
 private async void Copy(CommandArgs args)
 {
     var player  = args.Player;
     var session = Plugin.GetOrCreateSession(player);
     var region  = session.Selection;
     await Task.Run(() => session.Submit(() =>
     {
         session.Clipboard = Clipboard.CopyFrom(session.World, region);
         player.SendSuccessMessage("Copied clipboard from selection.");
     })).SendExceptions(player);
 }