Пример #1
0
        /// <summary>
        /// Compares the two complete objects.
        /// </summary>
        /// <param name="expected"></param>
        /// <param name="actual"></param>
        public static void CompareComplete(CompleteWay expected, CompleteWay actual)
        {
            if (expected == null)
            { // ok, if the value is also null.
                Assert.IsNull(actual);
            }
            else
            { // check and compare the value.
                Assert.IsNotNull(actual);
                Assert.AreEqual(expected.Id, actual.Id);
                Assert.AreEqual(expected.ChangeSetId, actual.ChangeSetId);
                Assert.AreEqual(expected.TimeStamp, actual.TimeStamp);
                Assert.AreEqual(expected.User, actual.User);
                Assert.AreEqual(expected.UserId, actual.UserId);
                Assert.AreEqual(expected.Version, actual.Version);
                Assert.AreEqual(expected.Visible, actual.Visible);

                if (expected.Nodes == null)
                { // ok, if the value is also null.
                    Assert.IsNotNull(actual.Nodes);
                }
                else
                { // check and compare the nodes.
                    Assert.AreEqual(expected.Nodes.Count, actual.Nodes.Count);
                    for (int idx = 0; idx < expected.Nodes.Count; idx++)
                    {
                        ComparisonHelpers.CompareComplete(
                            expected.Nodes[idx], actual.Nodes[idx]);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Compares a found way to an expected way.
        /// </summary>
        /// <param name="expected"></param>
        /// <param name="actual"></param>
        public static void CompareSimple(Way expected, Way actual)
        {
            Assert.IsNotNull(expected);
            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.ChangeSetId, actual.ChangeSetId);
            Assert.AreEqual(expected.TimeStamp, actual.TimeStamp);
            Assert.AreEqual(expected.Type, actual.Type);
            Assert.AreEqual(expected.UserId, actual.UserId);
            Assert.AreEqual(expected.UserName, actual.UserName);
            Assert.AreEqual(expected.Version, actual.Version);
            Assert.AreEqual(expected.Visible, actual.Visible);

            if (expected.Nodes == null)
            {
                Assert.IsNull(actual.Nodes);
            }
            else
            {
                Assert.IsNotNull(actual.Nodes);
                Assert.AreEqual(expected.Nodes.Count, actual.Nodes.Count);
                for (int idx = 0; idx < expected.Nodes.Count; idx++)
                {
                    Assert.AreEqual(expected.Nodes[idx], actual.Nodes[idx]);
                }
            }

            ComparisonHelpers.CompareTags(expected.Tags, actual.Tags);
        }
Пример #3
0
        /// <summary>
        /// Compares the two complete objects.
        /// </summary>
        /// <param name="expected"></param>
        /// <param name="actual"></param>
        public static void CompareComplete(CompleteRelation expected, CompleteRelation actual)
        {
            if (expected == null)
            { // ok, if the value is also null.
                Assert.IsNull(actual);
            }
            else
            { // check and compare the value.
                Assert.IsNotNull(actual);
                Assert.AreEqual(expected.Id, actual.Id);
                Assert.AreEqual(expected.ChangeSetId, actual.ChangeSetId);
                Assert.AreEqual(expected.TimeStamp, actual.TimeStamp);
                Assert.AreEqual(expected.User, actual.User);
                Assert.AreEqual(expected.UserId, actual.UserId);
                Assert.AreEqual(expected.Version, actual.Version);
                Assert.AreEqual(expected.Visible, actual.Visible);

                if (expected.Members == null)
                { // ok, if the value is also null.
                    Assert.IsNotNull(actual.Members);
                }
                else
                { // check and compare the nodes.
                    Assert.AreEqual(expected.Members.Count, actual.Members.Count);
                    for (int idx = 0; idx < expected.Members.Count; idx++)
                    {
                        CompleteRelationMember expectedMember = expected.Members[idx];
                        CompleteRelationMember actualMember   = actual.Members[idx];

                        Assert.AreEqual(expectedMember.Role, actualMember.Role);
                        Assert.IsNotNull(expectedMember.Member);
                        Assert.IsNotNull(actualMember.Member);
                        Assert.AreEqual(expectedMember.Member.Type, actualMember.Member.Type);

                        switch (expectedMember.Member.Type)
                        {
                        case CompleteOsmType.Node:
                            ComparisonHelpers.CompareComplete(
                                expectedMember.Member as Node,
                                actualMember.Member as Node);
                            break;

                        case CompleteOsmType.Way:
                            ComparisonHelpers.CompareComplete(
                                expectedMember.Member as CompleteWay,
                                actualMember.Member as CompleteWay);
                            break;

                        case CompleteOsmType.Relation:
                            ComparisonHelpers.CompareComplete(
                                expectedMember.Member as CompleteRelation,
                                actualMember.Member as CompleteRelation);
                            break;
                        }
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Compares two lists of complete osm objects.
        /// </summary>
        /// <param name="expectedList"></param>
        /// <param name="actualList"></param>
        public static void CompareComplete(System.Collections.Generic.List <ICompleteOsmGeo> expectedList,
                                           System.Collections.Generic.List <ICompleteOsmGeo> actualList)
        {
            foreach (ICompleteOsmGeo actual in actualList)
            {
                foreach (ICompleteOsmGeo expected in
                         expectedList.Where((expected) => { return(expected.Id == actual.Id && expected.Type == actual.Type); }))
                {
                    switch (expected.Type)
                    {
                    case CompleteOsmType.Node:
                        ComparisonHelpers.CompareComplete(
                            expected as Node, actual as Node);
                        break;

                    case CompleteOsmType.Way:
                        ComparisonHelpers.CompareComplete(
                            expected as CompleteWay, actual as CompleteWay);
                        break;

                    case CompleteOsmType.Relation:
                        ComparisonHelpers.CompareComplete(
                            expected as CompleteRelation, actual as CompleteRelation);
                        break;
                    }
                }
            }
            foreach (ICompleteOsmGeo expected in expectedList)
            {
                foreach (ICompleteOsmGeo actual in
                         actualList.Where((actual) => { return(expected.Id == actual.Id && expected.Type == actual.Type); }))
                {
                    switch (expected.Type)
                    {
                    case CompleteOsmType.Node:
                        ComparisonHelpers.CompareComplete(
                            expected as Node, actual as Node);
                        break;

                    case CompleteOsmType.Way:
                        ComparisonHelpers.CompareComplete(
                            expected as CompleteWay, actual as CompleteWay);
                        break;

                    case CompleteOsmType.Relation:
                        ComparisonHelpers.CompareComplete(
                            expected as CompleteRelation, actual as CompleteRelation);
                        break;
                    }
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Compares a found node to an expected node.
        /// </summary>
        /// <param name="expected"></param>
        /// <param name="actual"></param>
        public static void CompareSimple(Node expected, Node actual)
        {
            Assert.IsNotNull(expected);
            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.ChangeSetId, actual.ChangeSetId);
            Assert.AreEqual((float)expected.Latitude, (float)actual.Latitude);
            Assert.AreEqual((float)expected.Longitude, (float)actual.Longitude);
            Assert.AreEqual(expected.TimeStamp, actual.TimeStamp);
            Assert.AreEqual(expected.Type, actual.Type);
            Assert.AreEqual(expected.UserId, actual.UserId);
            Assert.AreEqual(expected.UserName, actual.UserName);
            Assert.AreEqual(expected.Version, actual.Version);
            Assert.AreEqual(expected.Visible, actual.Visible);

            ComparisonHelpers.CompareTags(expected.Tags, actual.Tags);
        }
Пример #6
0
        /// <summary>
        /// Compares a found relation to an expected relation.
        /// </summary>
        /// <param name="expected"></param>
        /// <param name="actual"></param>
        public static void CompareSimple(Relation expected, Relation actual)
        {
            Assert.IsNotNull(expected);
            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.ChangeSetId, actual.ChangeSetId);
            Assert.AreEqual(expected.TimeStamp, actual.TimeStamp);
            Assert.AreEqual(expected.Type, actual.Type);
            Assert.AreEqual(expected.UserId, actual.UserId);
            Assert.AreEqual(expected.UserName, actual.UserName);
            Assert.AreEqual(expected.Version, actual.Version);
            Assert.AreEqual(expected.Visible, actual.Visible);

            if (expected.Members == null)
            {
                Assert.IsNull(actual.Members);
            }
            else
            {
                Assert.IsNotNull(actual.Members);
                Assert.AreEqual(expected.Members.Count, actual.Members.Count);
                for (int idx = 0; idx < expected.Members.Count; idx++)
                {
                    Assert.AreEqual(expected.Members[idx].MemberId, actual.Members[idx].MemberId);
                    // the oracle database converts empty strings to null and does not follow standards.
                    // this is why there is this ugly code here matching empty strings to null.
                    if (expected.Members[idx].MemberRole == string.Empty &&
                        actual.Members[idx].MemberRole == null)
                    { // only for oracle!
                        Assert.AreEqual(null, actual.Members[idx].MemberRole);
                    }
                    else
                    {
                        Assert.AreEqual(expected.Members[idx].MemberRole, actual.Members[idx].MemberRole);
                    }
                    Assert.AreEqual(expected.Members[idx].MemberType, actual.Members[idx].MemberType);
                }
            }

            ComparisonHelpers.CompareTags(expected.Tags, actual.Tags);
        }