Ejemplo n.º 1
0
            public void ReturnsFalseForNotMovedField()
            {
                var notMovedProperty = DBCInspector.GetRecordProperties(typeof(TestDBCRecordWithSingleMovedField))
                                       .First(p => p.Name == nameof(TestDBCRecordWithSingleMovedField.FieldA));

                Assert.IsFalse(DBCInspector.HasPropertyMovedInVersion(WarcraftVersion.BurningCrusade, notMovedProperty));
            }
Ejemplo n.º 2
0
            public void AssignsCorrectChainsMultiVersion()
            {
                var orderer = new FieldOrderer
                              (
                    WarcraftVersion.Wrath,
                    DBCInspector.GetVersionRelevantProperties(WarcraftVersion.Wrath, typeof(TestDBCRecordWithMultipleMovedFields))
                    .ToList()
                              );

                var propertyA = DBCInspector.GetRecordProperties(typeof(TestDBCRecordWithMultipleMovedFields))
                                .First(p => p.Name == nameof(TestDBCRecordWithMultipleMovedFields.FieldA));

                var propertyC = DBCInspector.GetRecordProperties(typeof(TestDBCRecordWithMultipleMovedFields))
                                .First(p => p.Name == nameof(TestDBCRecordWithMultipleMovedFields.FieldC));

                var propertyD = DBCInspector.GetRecordProperties(typeof(TestDBCRecordWithMultipleMovedFields))
                                .First(p => p.Name == nameof(TestDBCRecordWithMultipleMovedFields.FieldD));

                var propertyE = DBCInspector.GetRecordProperties(typeof(TestDBCRecordWithMultipleMovedFields))
                                .First(p => p.Name == nameof(TestDBCRecordWithMultipleMovedFields.FieldE));

                Assert.That(orderer.PrecedenceChains[propertyA].Select(p => p.Name), Is.EquivalentTo(MultiMoveBCDependencyChainFieldA));
                Assert.That(orderer.PrecedenceChains[propertyC].Select(p => p.Name), Is.EquivalentTo(MultiMoveBCDependencyChainFieldC));
                Assert.That(orderer.PrecedenceChains[propertyD].Select(p => p.Name), Is.EquivalentTo(MultiMoveWrathDependencyChainFieldD));
                Assert.That(orderer.PrecedenceChains[propertyE].Select(p => p.Name), Is.EquivalentTo(MultiMoveBCDependencyChainFieldE));
            }
Ejemplo n.º 3
0
            public void ReturnsFalseForMovedFieldButNotInTheSpecifiedVersion()
            {
                var movedProperty = DBCInspector.GetRecordProperties(typeof(TestDBCRecordWithSingleMovedField))
                                    .First(p => p.Name == nameof(TestDBCRecordWithSingleMovedField.FieldC));

                Assert.IsFalse(DBCInspector.HasPropertyMovedInVersion(WarcraftVersion.Classic, movedProperty));
            }
Ejemplo n.º 4
0
            public void ThrowsIfPropertyHasNotMoved()
            {
                var movedPropertyButNotInVersion = DBCInspector.GetRecordProperties(typeof(TestDBCRecordWithSingleMovedFieldMultipleVersions))
                                                   .First(p => p.Name == nameof(TestDBCRecordWithSingleMovedFieldMultipleVersions.FieldC));

                Assert.Throws <ArgumentException>(() => DBCInspector.GetMostRecentPropertyMove(WarcraftVersion.Classic, movedPropertyButNotInVersion));
            }
Ejemplo n.º 5
0
            public void IncludesArrayFields()
            {
                var recordProperties = DBCInspector.GetRecordProperties(typeof(TestDBCRecordWithArray));

                var recordPropertyNames = recordProperties.Select(p => p.Name);

                Assert.That(recordPropertyNames, Is.EquivalentTo(TestRecordWithArrayPropertyNames));
            }
Ejemplo n.º 6
0
            public void GetsAValidPropertySet()
            {
                var recordProperties = DBCInspector.GetRecordProperties(typeof(TestDBCRecord));

                var recordPropertyNames = recordProperties.Select(p => p.Name);

                Assert.That(recordPropertyNames, Is.EquivalentTo(TestRecordPropertyNames));
            }
Ejemplo n.º 7
0
            public void ReturnsCorrectAttributeForSingleVersionMove()
            {
                var movedProperty = DBCInspector.GetRecordProperties(typeof(TestDBCRecordWithSingleMovedField))
                                    .First(p => p.Name == nameof(TestDBCRecordWithSingleMovedField.FieldC));

                var attribute = DBCInspector.GetMostRecentPropertyMove(WarcraftVersion.BurningCrusade, movedProperty);

                Assert.AreEqual(WarcraftVersion.BurningCrusade, attribute.MovedIn);
                Assert.AreEqual(nameof(DBCRecord.ID), attribute.ComesAfter);
            }
Ejemplo n.º 8
0
            public void ReturnsCorrectPropertiesForSingleField()
            {
                var recordProperties = DBCInspector.GetRecordProperties(typeof(TestDBCRecordWithSingleMovedField)).ToList();

                var movedPropertiesClassic = DBCInspector.GetMovedProperties(WarcraftVersion.Classic, recordProperties).Select(p => p.Key.Name);
                var movedPropertiesBC      = DBCInspector.GetMovedProperties(WarcraftVersion.BurningCrusade, recordProperties).Select(p => p.Key.Name);

                Assert.That(movedPropertiesClassic, Is.Empty);
                Assert.That(movedPropertiesBC, Is.EquivalentTo(SingleMovedFieldRecordNamesMovingFields));
            }
Ejemplo n.º 9
0
            public void ReturnsFalseForNonMoved()
            {
                var orderer = new FieldOrderer
                              (
                    WarcraftVersion.BurningCrusade,
                    DBCInspector.GetVersionRelevantProperties(WarcraftVersion.BurningCrusade, typeof(TestDBCRecordWithInvalidReentrantMovedFields))
                    .ToList()
                              );

                var propertyB = DBCInspector.GetRecordProperties(typeof(TestDBCRecordWithInvalidReentrantMovedFields))
                                .First(p => p.Name == nameof(TestDBCRecordWithInvalidReentrantMovedFields.FieldB));

                Assert.IsFalse(orderer.HasCyclicMoveDependency(propertyB));
            }
Ejemplo n.º 10
0
            public void GetsCorrectChainForMultiVersionMove()
            {
                var orderer = new FieldOrderer
                              (
                    WarcraftVersion.Wrath,
                    DBCInspector.GetVersionRelevantProperties(WarcraftVersion.Wrath, typeof(TestDBCRecordWithMultipleMovedFields))
                    .ToList()
                              );

                var movedProperty = DBCInspector.GetRecordProperties(typeof(TestDBCRecordWithMultipleMovedFields))
                                    .First(p => p.Name == nameof(TestDBCRecordWithMultipleMovedFields.FieldD));

                var moveAttribute = DBCInspector.GetMostRecentPropertyMove(WarcraftVersion.Wrath, movedProperty);

                var chain = orderer.GetPrecendenceChain(moveAttribute, new List <PropertyInfo>()).Select(p => p.Name);

                Assert.That(MultiVersionDependencyChainFieldE, Is.EquivalentTo(chain));
            }
Ejemplo n.º 11
0
            public void GetsCorrectChainForSimpleMove()
            {
                var orderer = new FieldOrderer
                              (
                    WarcraftVersion.BurningCrusade,
                    DBCInspector.GetVersionRelevantProperties(WarcraftVersion.BurningCrusade, typeof(TestDBCRecordWithSingleMovedField))
                    .ToList()
                              );

                var movedProperty = DBCInspector.GetRecordProperties(typeof(TestDBCRecordWithSingleMovedField))
                                    .First(p => p.Name == nameof(TestDBCRecordWithSingleMovedField.FieldC));

                var moveAttribute = DBCInspector.GetMostRecentPropertyMove(WarcraftVersion.BurningCrusade, movedProperty);

                var chain = orderer.GetPrecendenceChain(moveAttribute, new List <PropertyInfo>()).Select(p => p.Name);

                Assert.That(SimpleMoveDependencyChainFieldC, Is.EquivalentTo(chain));
            }
Ejemplo n.º 12
0
 public void ThrowsIfAnIncompatiblePropertyIsDecoratedWithRecordFieldArray()
 {
     Assert.Throws <IncompatibleRecordArrayTypeException>(() => DBCInspector.GetRecordProperties(typeof(TestDBCRecordWithInvalidArray)));
 }