Пример #1
0
        public void Tuple([Values] BehaviorMode mode, [Values] ParseModesToTest parseMode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(TupleDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString($@"
                <Decs>
                    <TupleDec decName=""TestDec"">
                        <value {GenerateParseModeTag(parseMode)}>
                            <li>11</li>
                            <li>12</li>
                        </value>
                    </TupleDec>
                </Decs>");

            if (parseMode == ParseModesToTest.Default || parseMode == ParseModesToTest.Replace)
            {
                parser.Finish();
            }
            else
            {
                ExpectErrors(() => parser.Finish());
            }

            DoBehavior(mode);

            Assert.AreEqual((11, 12), Dec.Database <TupleDec> .Get("TestDec").value);
        }
Пример #2
0
        public void ObjectUnspecified([Values] BehaviorMode mode)
        {
            // so it turns out you can just be all "new object" and C# is like "okiedokie you're the boss"
            // wasn't really expecting that

            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(ObjectHolderDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <ObjectHolderDec decName=""TestDec"">
                        <child />
                    </ObjectHolderDec>
                </Decs>");
            parser.Finish();

            DoBehavior(mode);

            var result = Dec.Database <ObjectHolderDec> .Get("TestDec");

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.child);
        }
Пример #3
0
        /// <summary>
        /// Causes Grot to shoot beams of twigs and then rotate them around
        /// </summary>
        private void SpinAttack()
        {
            if (currentFrame == 1)
            {
                this.weapon = new Weapon(@"enemy\Grot", new Rectangle(this.drawPos.X + this.drawPos.Width / 2, this.drawPos.Y + this.drawPos.Height / 2, 1, 1), true, false);
            }
            double radians = 0f;

            if (currentFrame == 1)
            {
                sign = GameManager.RNG.Next(0, 2) * 2 - 1; // Generates a random direction
            }

            if (currentFrame < 90)
            {
                radians = (45) * (Math.PI / 180) * sign;
            }
            else
            {
                radians = ((currentFrame / 2) % 360) * (Math.PI / 180) * sign;
            }

            weapon.Use(Vector2.Normalize(new Vector2((float)Math.Cos(radians), (float)Math.Sin(radians))));

            if (currentFrame >= 420)
            {
                currentFrame         = 0;
                this.currentBehavior = BehaviorMode.Taunt;
                sign = 0;
            }
        }
Пример #4
0
        public void ConverterDict([ValuesExcept(BehaviorMode.Validation)] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(ConverterDictDec) }, explicitConverters = new Type[] { typeof(ConverterDictTest) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <ConverterDictDec decName=""TestDec"">
                        <payload>
                            <yabba>1</yabba>
                            <dabba>4</dabba>
                            <doo>9</doo>
                        </payload>
                    </ConverterDictDec>
                </Decs>");
            parser.Finish();

            DoBehavior(mode);

            var testDec = Dec.Database <ConverterDictDec> .Get("TestDec");

            Assert.AreEqual(1, testDec.payload.Where(kvp => kvp.Key.payload == "yabba").First().Value);
            Assert.AreEqual(4, testDec.payload.Where(kvp => kvp.Key.payload == "dabba").First().Value);
            Assert.AreEqual(9, testDec.payload.Where(kvp => kvp.Key.payload == "doo").First().Value);
        }
Пример #5
0
        public void ExplicitTypeBackwards([Values] BehaviorMode mode)
        {
            Dec.Config.UsingNamespaces = new string[] { "DecTest.Children" };
            Dec.Config.TestParameters  = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(ExplicitTypeDerivedDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <ExplicitTypeDerivedDec decName=""TestDec"">
                        <child class=""ETBase"">
                            
                        </child>
                    </ExplicitTypeDerivedDec>
                </Decs>");
            ExpectErrors(() => parser.Finish());

            DoBehavior(mode);

            var result = Dec.Database <ExplicitTypeDerivedDec> .Get("TestDec");

            Assert.IsNotNull(result);

            Assert.IsNotNull(result.child);
            Assert.AreEqual(typeof(ETDerived), result.child.GetType());
        }
Пример #6
0
        public void HierarchyDuplicateField([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(DupeChildDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <DupeChildDec decName=""TestDec"">
                        <value>12</value>
                    </DupeChildDec>
                </Decs>");
            ExpectErrors(() => parser.Finish());

            DoBehavior(mode, rewrite_expectWriteErrors: true, rewrite_expectParseErrors: true, validation_expectWriteErrors: true);

            var result = (DupeChildDec)Dec.Database <DupeParentDec> .Get("TestDec");

            Assert.IsNotNull(result);

            Assert.AreEqual(12, result.value);
            Assert.AreEqual(4, ((DupeParentDec)result).value);
        }
Пример #7
0
        public void InternalInheritance([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(InternalInheritanceDec), typeof(InternalDerived) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <InternalInheritanceDec decName=""TestDec"">
                        <value class=""InternalDerived"">
                            <baseOnly>42</baseOnly>
                            <derivedOnly>100</derivedOnly>
                        </value>
                     </InternalInheritanceDec>
                </Decs>");
            parser.Finish();

            DoBehavior(mode);

            Assert.AreEqual(typeof(InternalDerived), Dec.Database <InternalInheritanceDec> .Get("TestDec").value.GetType());

            Assert.AreEqual(42, Dec.Database <InternalInheritanceDec> .Get("TestDec").value.baseOnly);
            Assert.AreEqual(100, ((InternalDerived)Dec.Database <InternalInheritanceDec> .Get("TestDec").value).derivedOnly);
        }
Пример #8
0
        public void List([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(SimpleDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <SimpleDec decName=""Base"" abstract=""true"">
                        <list>
                          <li>2</li>
                          <li>4</li>
                        </list>
                    </SimpleDec>
  
                    <SimpleDec decName=""Thing"" parent=""Base"">
                        <list>
                          <li>50</li>
                        </list>
                    </SimpleDec>
                </Decs>");
            parser.Finish();

            DoBehavior(mode);

            var result = Dec.Database <SimpleDec> .Get("Thing");

            Assert.AreEqual(1, result.list.Count);
            Assert.AreEqual(50, result.list[0]);

            Assert.IsNull(Dec.Database <SimpleDec> .Get("Base"));
        }
Пример #9
0
        public void Duplicate([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(DictionaryStringDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <DictionaryStringDec decName=""TestDec"">
                        <data>
                            <dupe>5</dupe>
                            <dupe>10</dupe>
                        </data>
                    </DictionaryStringDec>
                </Decs>");
            ExpectErrors(() => parser.Finish());

            DoBehavior(mode);

            var result = Dec.Database <DictionaryStringDec> .Get("TestDec");

            Assert.IsNotNull(result);

            Assert.AreEqual(result.data, new Dictionary <string, string> {
                { "dupe", "10" }
            });
        }
Пример #10
0
        public void MissingBase([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(SimpleDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <SimpleDec decName=""Thing"" parent=""Base"">
                        <overridden>60</overridden>
                        <subObject>
                            <overridden>90</overridden>
                        </subObject>
                    </SimpleDec>
                </Decs>");
            ExpectErrors(() => parser.Finish());

            DoBehavior(mode);

            var result = Dec.Database <SimpleDec> .Get("Thing");

            Assert.AreEqual(60, result.overridden);
            Assert.AreEqual(90, result.subObject.overridden);
        }
Пример #11
0
        public void AbstractNonabstractClash([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(SimpleDec) }
            };

            var parser = new Dec.Parser();

            ExpectErrors(() => parser.AddString(@"
                <Decs>
                    <SimpleDec decName=""Before"" abstract=""true"">
                        <overridden>10</overridden>
                     </SimpleDec>
                    <SimpleDec decName=""Before"">
                        <overridden>20</overridden>
                     </SimpleDec>
                    <SimpleDec decName=""After"">
                        <overridden>30</overridden>
                     </SimpleDec>
                    <SimpleDec decName=""After"" abstract=""true"">
                        <overridden>40</overridden>
                     </SimpleDec>
                </Decs>"));
            parser.Finish();

            DoBehavior(mode);

            Assert.AreEqual(20, Dec.Database <SimpleDec> .Get("Before").overridden);
            Assert.AreEqual(30, Dec.Database <SimpleDec> .Get("After").overridden);
        }
Пример #12
0
        public void MissingConcrete([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(SimpleDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <SimpleDec decName=""Base"" abstract=""true"">
                        <defaulted>3</defaulted>
                        <overridden>42</overridden>
                        <subObject>
                            <defaulted>12</defaulted>
                            <overridden>80</overridden>
                        </subObject>
                    </SimpleDec>
                </Decs>");
            parser.Finish();

            DoBehavior(mode);

            Assert.AreEqual(0, Dec.Database <SimpleDec> .Count);
        }
Пример #13
0
        public StoredSettings(StoredSettings oldSettings, bool preserveSettings, bool preserveTriggers, bool preserveTargetProfile) : base()
        {
            //Stuff From Old Settings
            if (!preserveSettings)
            {
                return;
            }

            this.Mode = oldSettings.Mode;
            this.StoredCustomBooleans   = oldSettings.StoredCustomBooleans;
            this.StoredCustomCounters   = oldSettings.StoredCustomCounters;
            this.TotalDamageAccumulated = oldSettings.TotalDamageAccumulated;
            this.LastDamageTakenTime    = oldSettings.LastDamageTakenTime;

            //Triggers
            if (preserveTriggers)
            {
                this.Triggers            = oldSettings.Triggers;
                this.DamageTriggers      = oldSettings.DamageTriggers;
                this.CommandTriggers     = oldSettings.CommandTriggers;
                this.CompromisedTriggers = oldSettings.CompromisedTriggers;
            }

            //TargetProfile
            if (preserveTargetProfile)
            {
                this.CustomTargetProfile   = oldSettings.CustomTargetProfile;
                this.CurrentTargetEntityId = oldSettings.CurrentTargetEntityId;
            }

            this.SetRotation(RotationDirection);
        }
Пример #14
0
        public void ConverterEmpty([Values] BehaviorMode mode, [Values] ParseModesToTest parseMode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(ConverterDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString($@"
                <Decs>
                    <ConverterDec decName=""TestDec"">
                        <empty {GenerateParseModeTag(parseMode)}><value>60</value></empty>
                    </ConverterDec>
                </Decs>");

            if (parseMode == ParseModesToTest.Default || parseMode == ParseModesToTest.Patch)
            {
                parser.Finish();
            }
            else
            {
                ExpectErrors(() => parser.Finish());
            }

            DoBehavior(mode);

            Assert.AreEqual(60, Dec.Database <ConverterDec> .Get("TestDec").empty.value);
            Assert.AreEqual(15, Dec.Database <ConverterDec> .Get("TestDec").empty.sideValue);

            Assert.AreEqual(5, Dec.Database <ConverterDec> .Get("TestDec").filled.value);
            Assert.AreEqual(20, Dec.Database <ConverterDec> .Get("TestDec").filled.sideValue);
        }
Пример #15
0
        public void Multistring([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(RefTargetDec), typeof(RefSourceDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <RefSourceDec decName=""Source"">
                        <target>Target</target>
                    </RefSourceDec>
                </Decs>");
            parser.AddString(@"
                <Decs>
                    <RefTargetDec decName=""Target"" />
                </Decs>");
            parser.Finish();

            DoBehavior(mode);

            var target = Dec.Database <RefTargetDec> .Get("Target");

            var source = Dec.Database <RefSourceDec> .Get("Source");

            Assert.IsNotNull(target);
            Assert.IsNotNull(source);

            Assert.AreEqual(source.target, target);
        }
Пример #16
0
        public void OverrideString([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(DictionaryStringOverrideDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <DictionaryStringOverrideDec decName=""TestDec"">
                        <dataA>
                            <u>2020</u>
                            <v>2021</v>
                        </dataA>
                        <dataB />
                    </DictionaryStringOverrideDec>
                </Decs>");
            parser.Finish();

            DoBehavior(mode);

            var result = Dec.Database <DictionaryStringOverrideDec> .Get("TestDec");

            Assert.IsNotNull(result);

            Assert.AreEqual(result.dataA, new Dictionary <string, string> {
                { "u", "2020" }, { "v", "2021" }
            });
            Assert.AreEqual(result.dataB, new Dictionary <string, string> {
            });
            Assert.AreEqual(result.dataC, new Dictionary <string, string> {
                ["g"] = "7", ["h"] = "8", ["i"] = "9"
            });
        }
Пример #17
0
        public void DuplicateDec([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(IntDec) }
            };

            var parser = new Dec.Parser();

            ExpectErrors(() => parser.AddString(@"
                <Decs>
                    <IntDec decName=""TestDec"">
                        <value>10</value>
                    </IntDec>
                    <IntDec decName=""TestDec"">
                        <value>20</value>
                    </IntDec>
                </Decs>"));
            parser.Finish();

            DoBehavior(mode, errorValidator: err => err.Contains("IntDec:TestDec"));

            var result = Dec.Database <IntDec> .Get("TestDec");

            Assert.IsNotNull(result);

            Assert.AreEqual(20, result.value);
        }
Пример #18
0
        public void NullKey([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(DictionaryStringDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <DictionaryStringDec decName=""TestDec"">
                        <data>
                            <li>
                                <key null=""true"" />
                                <value>goodbye</value>
                            </li>
                        </data>
                    </DictionaryStringDec>
                </Decs>");
            ExpectErrors(() => parser.Finish());

            DoBehavior(mode);

            var result = Dec.Database <DictionaryStringDec> .Get("TestDec");

            Assert.IsNotNull(result);

            Assert.AreEqual(0, result.data.Count);
        }
Пример #19
0
        public void ForbiddenField([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(StubDec) }
            };

            var parser = new Dec.Parser();

            // This is a little silly because, as of this writing, DecName is a property and we don't even support writing to properties.
            // So we're not really testing forbidden fields here. We're really just double-checking the fact that properties can't be written to.
            // But someday I'll probably support properties, and then this had better work.
            parser.AddString(@"
                <Decs>
                    <StubDec decName=""TestDec"">
                        <DecName>NotTestDec</DecName>
                    </StubDec>
                </Decs>");

            // Just in case I rename it back to lowercase, make sure we don't just get a spelling mismatch error here.
            ExpectErrors(() => parser.Finish(), err => !err.Contains("decName"));

            DoBehavior(mode);

            Assert.AreEqual("TestDec", Dec.Database <StubDec> .Get("TestDec").DecName);
        }
Пример #20
0
        public void EnumKey([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(DictionaryEnumDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <DictionaryEnumDec decName=""TestDec"">
                        <data>
                            <Alpha>Alpha</Alpha>
                            <Beta>Bravo</Beta>
                            <Gamma>Charlie</Gamma>
                            <Delta>Delta</Delta>
                        </data>
                    </DictionaryEnumDec>
                </Decs>");
            parser.Finish();

            DoBehavior(mode);

            var result = Dec.Database <DictionaryEnumDec> .Get("TestDec");

            Assert.IsNotNull(result);

            Assert.AreEqual(result.data, new Dictionary <GenericEnum, string> {
                { GenericEnum.Alpha, "Alpha" },
                { GenericEnum.Beta, "Bravo" },
                { GenericEnum.Gamma, "Charlie" },
                { GenericEnum.Delta, "Delta" },
            });
        }
Пример #21
0
        public void InvalidDecName([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(StubDec) }
            };

            var parser = new Dec.Parser();

            ExpectErrors(() => parser.AddString(@"
                <Decs>
                    <StubDec decName=""1NumberPrefix"" />
                    <StubDec decName=""Contains Spaces"" />
                    <StubDec decName=""HasPunctuation!"" />
                    <StubDec decName=""&quot;Quotes&quot;"" />
                    <StubDec decName=""ActuallyAValidDecName"" />
                </Decs>"));
            parser.Finish();

            DoBehavior(mode);

            Assert.IsNull(Dec.Database <StubDec> .Get("1NumberPrefix"));
            Assert.IsNull(Dec.Database <StubDec> .Get("Contains Spaces"));
            Assert.IsNull(Dec.Database <StubDec> .Get("HasPunctuation!"));
            Assert.IsNull(Dec.Database <StubDec> .Get("\"Quotes\""));
            Assert.IsNotNull(Dec.Database <StubDec> .Get("ActuallyAValidDecName"));
        }
Пример #22
0
        public void Hybrid([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(DictionaryStringDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <DictionaryStringDec decName=""TestDec"">
                        <data>
                            <hello>goodbye</hello>
                            <li>
                                <key>one</key>
                                <value>two</value>
                            </li>
                        </data>
                    </DictionaryStringDec>
                </Decs>");
            parser.Finish();

            DoBehavior(mode);

            var result = Dec.Database <DictionaryStringDec> .Get("TestDec");

            Assert.IsNotNull(result);

            Assert.AreEqual(result.data, new Dictionary <string, string> {
                { "hello", "goodbye" }, { "one", "two" }
            });
        }
Пример #23
0
        public void Exception([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(ExceptionDec) }, explicitConverters = new Type[] { typeof(ExceptionConverter) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <ExceptionDec decName=""TestDecA"">
                        <before>1</before>
                        <payload />
                        <after>2</after>
                    </ExceptionDec>
                    <ExceptionDec decName=""TestDecB"">
                        <before>3</before>
                        <payload />
                        <after>4</after>
                    </ExceptionDec>
                </Decs>");
            ExpectErrors(() => parser.Finish());

            DoBehavior(mode);

            Assert.AreEqual(1, Dec.Database <ExceptionDec> .Get("TestDecA").before);
            Assert.AreEqual(2, Dec.Database <ExceptionDec> .Get("TestDecA").after);
            Assert.AreEqual(3, Dec.Database <ExceptionDec> .Get("TestDecB").before);
            Assert.AreEqual(4, Dec.Database <ExceptionDec> .Get("TestDecB").after);
        }
Пример #24
0
        public void AbstractRoot([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(ConcreteChildADec), typeof(ConcreteChildBDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <ConcreteChildADec decName=""TestDec"">
                        <absInt>20</absInt>
                        <ccaInt>30</ccaInt>
                    </ConcreteChildADec>
                    <ConcreteChildBDec decName=""TestDec"">
                        <absInt>40</absInt>
                        <ccbInt>50</ccbInt>
                    </ConcreteChildBDec>
                </Decs>");
            parser.Finish();

            DoBehavior(mode);

            Assert.AreEqual(20, Dec.Database <ConcreteChildADec> .Get("TestDec").absInt);
            Assert.AreEqual(30, Dec.Database <ConcreteChildADec> .Get("TestDec").ccaInt);
            Assert.AreEqual(40, Dec.Database <ConcreteChildBDec> .Get("TestDec").absInt);
            Assert.AreEqual(50, Dec.Database <ConcreteChildBDec> .Get("TestDec").ccbInt);
        }
Пример #25
0
        public void ExplicitTypeConflict([Values] BehaviorMode mode)
        {
            Dec.Config.UsingNamespaces = new string[] { "DecTest.Children" };
            Dec.Config.TestParameters  = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(ExplicitTypeConflictDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <ExplicitTypeConflictDec decName=""TestDec"">
                        <child class=""ETDerivedAlt"" />
                    </ExplicitTypeConflictDec>
                </Decs>");
            ExpectErrors(() => parser.Finish());

            DoBehavior(mode);

            var result = Dec.Database <ExplicitTypeConflictDec> .Get("TestDec");

            Assert.IsNotNull(result);

            Assert.IsNotNull(result.child);

            // I'm not really sure this is the right outcome - maybe it should be ETDerivedAlt - but it also kind of doesn't matter, this shouldn't happen
            Assert.AreEqual(typeof(ETDerived), result.child.GetType());
        }
Пример #26
0
        public void Circular([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(RefCircularDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <RefCircularDec decName=""Alpha"">
                        <target>Beta</target>
                    </RefCircularDec>
                    <RefCircularDec decName=""Beta"">
                        <target>Alpha</target>
                    </RefCircularDec>
                </Decs>");
            parser.Finish();

            DoBehavior(mode);

            var alpha = Dec.Database <RefCircularDec> .Get("Alpha");

            var beta = Dec.Database <RefCircularDec> .Get("Beta");

            Assert.IsNotNull(alpha);
            Assert.IsNotNull(beta);

            Assert.AreEqual(alpha.target, beta);
            Assert.AreEqual(beta.target, alpha);
        }
Пример #27
0
        public void ChildClassDefaults([Values] BehaviorMode mode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(CCDRoot) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <CCDRoot decName=""TestDec"">
                        <child>
                            <value>5</value>
                        </child>
                    </CCDRoot>
                </Decs>");
            parser.Finish();

            DoBehavior(mode);

            var result = Dec.Database <CCDRoot> .Get("TestDec");

            Assert.IsNotNull(result);

            Assert.AreEqual(5, result.child.value);
            Assert.AreEqual(8, result.child.initialized);
        }
Пример #28
0
        public void NullRef([Values] BehaviorMode mode)
        {
            // This is a little wonky; we have to test it by duplicating a tag, which is technically an error
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(RefCircularDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <RefCircularDec decName=""TestDec"">
                        <target>TestDec</target>
                        <target></target>
                    </RefCircularDec>
                </Decs>");
            ExpectErrors(() => parser.Finish());

            DoBehavior(mode);

            var result = Dec.Database <RefCircularDec> .Get("TestDec");

            Assert.IsNotNull(result);

            Assert.IsNull(result.target);
        }
Пример #29
0
 /// <summary>
 /// Creates a new Grot boss
 /// </summary>
 public Grot(EnemyType enemyType, int maxHP, bool melee, float fireRate, float attackDamage, float moveSpeed, float projectileSpeed, Rectangle drawPos, Vector2 velocity, string weaponName, int lungeTime, bool sturdy) : base(enemyType, 75, melee, fireRate, attackDamage, moveSpeed, projectileSpeed, new Rectangle(drawPos.X - FloorManager.TileWidth * 1, drawPos.Y - FloorManager.TileHeight * 3, FloorManager.TileWidth * 3, FloorManager.TileHeight * 5), velocity, "Grot", 0, true)
 {
     currentBehavior = BehaviorMode.Taunt;
     currentFrame    = 0;
     sign            = 0;
     this.hitbox     = new Rectangle(this.drawPos.X, this.drawPos.Y + FloorManager.TileHeight * 2, FloorManager.TileWidth * 3, FloorManager.TileHeight * 3);
 }
Пример #30
0
        public void ArrayEmpty([Values] BehaviorMode mode, [Values] ParseModesToTest parseMode)
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitTypes = new Type[] { typeof(ArrayDec) }
            };

            var parser = new Dec.Parser();

            parser.AddString($@"
                <Decs>
                    <ArrayDec decName=""TestDec"">
                        <empty {GenerateParseModeTag(parseMode)}>
                            <li>5</li>
                            <li>6</li>
                            <li>7</li>
                        </empty>
                    </ArrayDec>
                </Decs>");

            if (parseMode == ParseModesToTest.Default || parseMode == ParseModesToTest.Replace || parseMode == ParseModesToTest.Append)
            {
                parser.Finish();
            }
            else
            {
                ExpectErrors(() => parser.Finish());
            }

            DoBehavior(mode);

            Assert.AreEqual(new int[] { 5, 6, 7 }, Dec.Database <ArrayDec> .Get("TestDec").empty);
            Assert.AreEqual(new int[] { 1, 2, 3, 4 }, Dec.Database <ArrayDec> .Get("TestDec").filled);
        }