コード例 #1
0
        public void EntityArgument_ParseShouldSucceed_WithSelector()
        {
            // Arrange
            EntityArgument argument = new EntityArgument();
            IStringReader  reader   = new StringReader("@a");

            // Act
            ReadResults readResults = argument.Parse(reader, out _);

            // Assert
            Assert.IsTrue(readResults.Successful);
        }
コード例 #2
0
        public void EntityArgument_ParseShouldFail_WithSelector_BecauseInvalidSelectorType()
        {
            // Arrange
            EntityArgument argument = new EntityArgument();
            IStringReader  reader   = new StringReader("@m");

            // Act
            ReadResults readResults = argument.Parse(reader, out _);

            // Assert
            Assert.IsFalse(readResults.Successful);
        }
コード例 #3
0
        public void EntityArgument_ParseShouldSucceed_WithSelfSelector_WhenLimitedToPlayers()
        {
            // Arrange
            EntityArgument argument = new EntityArgument(false, true);
            IStringReader  reader   = new StringReader("@s");

            // Act
            ReadResults readResults = argument.Parse(reader, out _);

            // Assert
            Assert.IsTrue(readResults.Successful);
        }
コード例 #4
0
        public void EntityArgument_ParseShouldSucceed_WithUuid()
        {
            // Arrange
            EntityArgument argument = new EntityArgument();
            IStringReader  reader   = new StringReader("1-2-3-4-5");

            // Act
            argument.Parse(reader, out _);

            // Assert
            Assert.IsFalse(reader.CanRead());
        }
コード例 #5
0
        public void EntityArgument_ParseShouldFail_WithAllEntitiesSelector_WhenLimitedToOneEntity()
        {
            // Arrange
            EntityArgument argument = new EntityArgument(true, false);
            IStringReader  reader   = new StringReader("@e");

            // Act
            ReadResults readResults = argument.Parse(reader, out _);

            // Assert
            Assert.IsFalse(readResults.Successful);
        }
コード例 #6
0
        public void EntityArgument_ParseShouldFail_WithUuid_WhenLimitedToPlayers()
        {
            // Arrange
            EntityArgument argument = new EntityArgument(false, true);
            IStringReader  reader   = new StringReader("1-2-3-4-5");

            // Act
            ReadResults readResults = argument.Parse(reader, out _);

            // Assert
            Assert.IsFalse(readResults.Successful);
        }
コード例 #7
0
        public void EntityArgument_ParseShouldSucceed_WithUuid_WhenLimitedToOneEntity()
        {
            // Arrange
            EntityArgument argument = new EntityArgument(true, false);
            IStringReader  reader   = new StringReader("1-2-3-4-5");

            // Act
            ReadResults readResults = argument.Parse(reader, out _);

            // Assert
            Assert.IsTrue(readResults.Successful);
        }
コード例 #8
0
        public void EntityArgument_ParseShouldSucceed_WithPlayername()
        {
            // Arrange
            EntityArgument argument = new EntityArgument();
            IStringReader  reader   = new StringReader("Steve");

            // Act
            argument.Parse(reader, out _);

            // Assert
            Assert.IsFalse(reader.CanRead());
        }
コード例 #9
0
        public void EntityArgument_ParseShouldFail_WithSelector_WithArguments_BecauseInvalidArgument()
        {
            // Arrange
            EntitySelectorOptions.Set("{\"foo\":{\"contents\":{\"type\":\"argument\",\"parser\":\"string\",\"properties\":{\"type\":\"word\"}}}, \"baz\":{\"contents\":{\"type\":\"argument\",\"parser\":\"integer\"}}}");
            EntityArgument argument = new EntityArgument();
            IStringReader  reader   = new StringReader("@a[hello=false]");

            // Act
            ReadResults readResults = argument.Parse(reader, out _);

            // Assert
            Assert.IsFalse(readResults.Successful);
        }
コード例 #10
0
        public void EntityArgument_ParseShouldSucceed_WithSelector_WithArguments()
        {
            // Arrange
            EntitySelectorOptions.Set("{\"foo\":{\"contents\":{\"type\":\"argument\",\"parser\":\"string\",\"properties\":{\"type\":\"word\"}}}, \"baz\":{\"contents\":{\"type\":\"argument\",\"parser\":\"integer\"}}}");
            EntityArgument argument = new EntityArgument();
            IStringReader  reader   = new StringReader("@a[foo=bar, baz=3]");

            // Act
            ReadResults readResults = argument.Parse(reader, out _);

            // Assert
            Assert.IsTrue(readResults.Successful);
        }
コード例 #11
0
        public void EntityArgument_ParseShouldFail_WithDuplicateArguments_IfReapplicationIsAllowedButOnlyIfInverted_AndIsNotInverted()
        {
            // Arrange
            EntitySelectorOptions.Set("{\"foo\":{\"reapplication_type\":\"only_if_inverted\",\"allow_inverse\":true,\"contents\":{\"type\":\"argument\",\"parser\":\"string\",\"properties\":{\"type\":\"word\"}}}}");
            EntityArgument argument = new EntityArgument();
            IStringReader  reader   = new StringReader("@a[foo=bar, foo=!baz]");

            // Act
            ReadResults readResults = argument.Parse(reader, out _);

            // Assert
            Assert.IsFalse(readResults.Successful);
        }
コード例 #12
0
        public void EntityArgument_ParseShouldSucceed_WithDuplicateArguments_IfReapplicationIsAllowed()
        {
            // Arrange
            EntitySelectorOptions.Set("{\"foo\":{\"reapplication_type\":\"always\",\"contents\":{\"type\":\"argument\",\"parser\":\"string\",\"properties\":{\"type\":\"word\"}}}}");
            EntityArgument argument = new EntityArgument();
            IStringReader  reader   = new StringReader("@a[foo=bar, foo=baz]");

            // Act
            ReadResults readResults = argument.Parse(reader, out _);

            // Assert
            Assert.IsTrue(readResults.Successful);
        }
コード例 #13
0
        public void EntityArgument_ParseShouldSucceed_WithAllEntitiesSelector_WithLimit_WhenLimitedToOneEntity()
        {
            // Arrange
            EntitySelectorOptions.Set("{\"limit\":{\"predicate\":\"set_limit\"}}");
            EntityArgument argument = new EntityArgument(true, false);
            IStringReader  reader   = new StringReader("@e[limit=1]");

            // Act
            ReadResults readResults = argument.Parse(reader, out _);

            // Assert
            Assert.IsTrue(readResults.Successful);
        }