/// <summary>
        /// Compares a found way to an expected way.
        /// </summary>
        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);
        }
        /// <summary>
        /// Compares the two complete objects.
        /// </summary>
        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]);
                    }
                }
            }
        }
        /// <summary>
        /// Tests read/write and actual data file.
        /// </summary>
        protected void TestReadWriteData()
        {
            this.NotifyEmptyExpected(); // empty test database.

            // create the target and pull the data from the test-file into the sqlite database.
            OsmStreamTarget    target = this.CreateDataStreamTarget();
            PBFOsmStreamSource source = new PBFOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Data.Test.Unittests.Data.Osm.test.osm.pbf"));

            target.RegisterSource(source);
            target.Pull();

            IDataSourceReadOnly dataSource   = this.CreateDataSource();
            MemoryDataSource    memorySource = MemoryDataSource.CreateFrom(source);

            foreach (Node node in memorySource.GetNodes())
            {
                Node dbNode = dataSource.GetNode(node.Id.Value);
                ComparisonHelpers.CompareSimple(node, dbNode);
            }
            foreach (Way way in memorySource.GetWays())
            {
                Way dbWay = dataSource.GetWay(way.Id.Value);
                ComparisonHelpers.CompareSimple(way, dbWay);
            }
            foreach (Relation relation in memorySource.GetRelations())
            {
                Relation dbRelation = dataSource.GetRelation(relation.Id.Value);
                ComparisonHelpers.CompareSimple(relation, dbRelation);
            }
        }
        /// <summary>
        /// Compares the two complete objects.
        /// </summary>
        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;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Compares two lists of complete osm objects.
        /// </summary>
        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;
                    }
                }
            }
        }
        /// <summary>
        /// Compares a found node to an expected node.
        /// </summary>
        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);
        }
        /// <summary>
        /// Compares a found relation to an expected relation.
        /// </summary>
        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);
        }
        /// <summary>
        /// Compares the two collection to check if they contain the same objects.
        /// </summary>
        /// <param name="expected"></param>
        /// <param name="found"></param>
        private void CompareResults(IList <OsmGeo> expected, IList <OsmGeo> found)
        {
            //Assert.AreEqual(expected.Count, found.Count);
            Dictionary <string, OsmGeo> referenceBoxDataIndex = new Dictionary <string, OsmGeo>();

            foreach (OsmGeo osmGeo in expected)
            {
                referenceBoxDataIndex.Add(string.Format("{0}:{1}", osmGeo.Type.ToString(), osmGeo.Id.Value), osmGeo);
            }

            foreach (OsmGeo osmGeo in found)
            {
                string refString = string.Format("{0}:{1}", osmGeo.Type.ToString(), osmGeo.Id.Value);
                OsmGeo refOsmGeo;
                if (referenceBoxDataIndex.TryGetValue(refString, out refOsmGeo))
                {
                    Assert.IsNotNull(refOsmGeo);
                    switch (osmGeo.Type)
                    {
                    case OsmGeoType.Node:
                        ComparisonHelpers.CompareSimple(refOsmGeo as Node, osmGeo as Node);
                        break;

                    case OsmGeoType.Way:
                        ComparisonHelpers.CompareSimple(refOsmGeo as Way, osmGeo as Way);
                        break;

                    case OsmGeoType.Relation:
                        ComparisonHelpers.CompareSimple(refOsmGeo as Relation, osmGeo as Relation);
                        break;
                    }
                }
                else
                {
                    Assert.Fail("Reference data not found!");
                }
            }
        }
        /// <summary>
        /// Tests read/writing a node.
        /// </summary>
        protected void TestNodeReadWrite()
        {
            this.NotifyEmptyExpected(); // empty test database.

            // create a test-node.
            Node node = new Node();

            node.Id        = 1;
            node.Latitude  = 51.0;
            node.Longitude = 4.0;

            // create a target, add the node, create a source and verify node in db.
            var target = this.CreateDataStreamTarget();

            target.Initialize();
            target.AddNode(node);
            target.Flush();
            target.Close();
            var  dataSource = this.CreateDataSource();
            Node foundNode  = dataSource.GetNode(1);

            ComparisonHelpers.CompareSimple(node, foundNode);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-node.
            node           = new Node();
            node.Id        = 1;
            node.Latitude  = 51.0;
            node.Longitude = 4.0;
            node.UserName  = "******";

            // create a target, add the node, create a source and verify node in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddNode(node);
            target.Flush();
            target.Close();
            dataSource = this.CreateDataSource();
            foundNode  = dataSource.GetNode(1);
            ComparisonHelpers.CompareSimple(node, foundNode);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-node.
            node           = new Node();
            node.Id        = 1;
            node.Latitude  = 51.0;
            node.Longitude = 4.0;
            node.UserName  = "******";
            node.UserId    = 10;

            // create a target, add the node, create a source and verify node in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddNode(node);
            target.Flush();
            target.Close();
            dataSource = this.CreateDataSource();
            foundNode  = dataSource.GetNode(1);
            ComparisonHelpers.CompareSimple(node, foundNode);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-node.
            node           = new Node();
            node.Id        = 1;
            node.Latitude  = 51.0;
            node.Longitude = 4.0;
            node.UserName  = "******";
            node.UserId    = 10;
            node.Version   = 1;

            // create a target, add the node, create a source and verify node in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddNode(node);
            target.Flush();
            target.Close();
            dataSource = this.CreateDataSource();
            foundNode  = dataSource.GetNode(1);
            ComparisonHelpers.CompareSimple(node, foundNode);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-node.
            node           = new Node();
            node.Id        = 1;
            node.Latitude  = 51.0;
            node.Longitude = 4.0;
            node.UserName  = "******";
            node.UserId    = 10;
            node.Version   = 1;
            node.Visible   = true;

            // create a target, add the node, create a source and verify node in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddNode(node);
            target.Flush();
            target.Close();
            dataSource = this.CreateDataSource();
            foundNode  = dataSource.GetNode(1);
            ComparisonHelpers.CompareSimple(node, foundNode);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-node.
            node           = new Node();
            node.Id        = 1;
            node.Latitude  = 51.0;
            node.Longitude = 4.0;
            node.UserName  = "******";
            node.UserId    = 10;
            node.Version   = 1;
            node.Visible   = true;
            node.TimeStamp = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                                          DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);

            // create a target, add the node, create a source and verify node in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddNode(node);
            target.Flush();
            target.Close();
            dataSource = this.CreateDataSource();
            foundNode  = dataSource.GetNode(1);
            ComparisonHelpers.CompareSimple(node, foundNode);


            this.NotifyEmptyExpected(); // empty test database.

            // create a test-node.
            node           = new Node();
            node.Id        = 1;
            node.Latitude  = 51.0;
            node.Longitude = 4.0;
            node.UserName  = "******";
            node.UserId    = 10;
            node.Version   = 1;
            node.Visible   = true;
            node.TimeStamp = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                                          DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            node.Tags = new TagsCollection();
            node.Tags.Add("tag", "value");

            // create a target, add the node, create a source and verify node in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddNode(node);
            target.Flush();
            target.Close();
            dataSource = this.CreateDataSource();
            foundNode  = dataSource.GetNode(1);
            ComparisonHelpers.CompareSimple(node, foundNode);
        }
        /// <summary>
        /// Tests read/writing a relation.
        /// </summary>
        protected void TestRelationReadWrite()
        {
            this.NotifyEmptyExpected(); // empty test database.

            // create a test-relation.
            Relation relation = new Relation();

            relation.Id = 1;

            // create a target, add the relation, create a source and verify relation in db.
            var target = this.CreateDataStreamTarget();

            target.Initialize();
            target.AddRelation(relation);
            target.Flush();
            target.Close();
            var      dataSource    = this.CreateDataSource();
            Relation foundRelation = dataSource.GetRelation(1);

            ComparisonHelpers.CompareSimple(relation, foundRelation);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-relation.
            relation          = new Relation();
            relation.Id       = 1;
            relation.UserName = "******";

            // create a target, add the relation, create a source and verify relation in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddRelation(relation);
            target.Flush();
            target.Close();
            dataSource    = this.CreateDataSource();
            foundRelation = dataSource.GetRelation(1);
            ComparisonHelpers.CompareSimple(relation, foundRelation);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-relation.
            relation          = new Relation();
            relation.Id       = 1;
            relation.UserName = "******";
            relation.UserId   = 10;

            // create a target, add the relation, create a source and verify relation in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddRelation(relation);
            target.Flush();
            target.Close();
            dataSource    = this.CreateDataSource();
            foundRelation = dataSource.GetRelation(1);
            ComparisonHelpers.CompareSimple(relation, foundRelation);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-relation.
            relation          = new Relation();
            relation.Id       = 1;
            relation.UserName = "******";
            relation.UserId   = 10;
            relation.Version  = 1;

            // create a target, add the relation, create a source and verify relation in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddRelation(relation);
            target.Flush();
            target.Close();
            dataSource    = this.CreateDataSource();
            foundRelation = dataSource.GetRelation(1);
            ComparisonHelpers.CompareSimple(relation, foundRelation);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-relation.
            relation          = new Relation();
            relation.Id       = 1;
            relation.UserName = "******";
            relation.UserId   = 10;
            relation.Version  = 1;
            relation.Visible  = true;

            // create a target, add the relation, create a source and verify relation in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddRelation(relation);
            target.Flush();
            target.Close();
            dataSource    = this.CreateDataSource();
            foundRelation = dataSource.GetRelation(1);
            ComparisonHelpers.CompareSimple(relation, foundRelation);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-relation.
            relation           = new Relation();
            relation.Id        = 1;
            relation.UserName  = "******";
            relation.UserId    = 10;
            relation.Version   = 1;
            relation.Visible   = true;
            relation.TimeStamp = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                                              DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);

            // create a target, add the relation, create a source and verify relation in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddRelation(relation);
            target.Flush();
            target.Close();
            dataSource    = this.CreateDataSource();
            foundRelation = dataSource.GetRelation(1);
            ComparisonHelpers.CompareSimple(relation, foundRelation);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-relation.
            relation           = new Relation();
            relation.Id        = 1;
            relation.UserName  = "******";
            relation.UserId    = 10;
            relation.Version   = 1;
            relation.Visible   = true;
            relation.TimeStamp = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                                              DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            relation.Tags = new TagsCollection();
            relation.Tags.Add("tag", "value");

            // create a target, add the relation, create a source and verify relation in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddRelation(relation);
            target.Flush();
            target.Close();
            dataSource    = this.CreateDataSource();
            foundRelation = dataSource.GetRelation(1);
            ComparisonHelpers.CompareSimple(relation, foundRelation);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-relation.
            relation           = new Relation();
            relation.Id        = 1;
            relation.UserName  = "******";
            relation.UserId    = 10;
            relation.Version   = 1;
            relation.Visible   = true;
            relation.TimeStamp = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                                              DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            relation.Members = new List <RelationMember>();
            relation.Members.Add(new RelationMember()
            {
                MemberId = 1, MemberRole = "node1", MemberType = OsmGeoType.Node
            });
            relation.Members.Add(new RelationMember()
            {
                MemberId = 2, MemberRole = "node2", MemberType = OsmGeoType.Node
            });
            relation.Members.Add(new RelationMember()
            {
                MemberId = 1, MemberRole = "node1", MemberType = OsmGeoType.Node
            });
            relation.Members.Add(new RelationMember()
            {
                MemberId = 1, MemberRole = "way", MemberType = OsmGeoType.Way
            });

            // create a target, add the relation, create a source and verify relation in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddRelation(relation);
            target.Flush();
            target.Close();
            dataSource    = this.CreateDataSource();
            foundRelation = dataSource.GetRelation(1);
            ComparisonHelpers.CompareSimple(relation, foundRelation);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-relation.
            relation           = new Relation();
            relation.Id        = 1;
            relation.UserName  = "******";
            relation.UserId    = 10;
            relation.Version   = 1;
            relation.Visible   = true;
            relation.TimeStamp = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                                              DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            relation.Members = new List <RelationMember>();
            relation.Members.Add(new RelationMember()
            {
                MemberId = 1, MemberRole = string.Empty, MemberType = OsmGeoType.Node
            });

            // create a target, add the relation, create a source and verify relation in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddRelation(relation);
            target.Flush();
            target.Close();
            dataSource    = this.CreateDataSource();
            foundRelation = dataSource.GetRelation(1);
            ComparisonHelpers.CompareSimple(relation, foundRelation);
        }
        /// <summary>
        /// Tests read/writing a way.
        /// </summary>
        protected void TestWayReadWrite()
        {
            this.NotifyEmptyExpected(); // empty test database.

            // create a test-way.
            Way way = new Way();

            way.Id = 1;

            // create a target, add the way, create a source and verify way in db.
            var target = this.CreateDataStreamTarget();

            target.Initialize();
            target.AddWay(way);
            target.Flush();
            target.Close();
            var dataSource = this.CreateDataSource();
            Way foundWay   = dataSource.GetWay(1);

            ComparisonHelpers.CompareSimple(way, foundWay);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-way.
            way          = new Way();
            way.Id       = 1;
            way.UserName = "******";

            // create a target, add the way, create a source and verify way in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddWay(way);
            target.Flush();
            target.Close();
            dataSource = this.CreateDataSource();
            foundWay   = dataSource.GetWay(1);
            ComparisonHelpers.CompareSimple(way, foundWay);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-way.
            way          = new Way();
            way.Id       = 1;
            way.UserName = "******";
            way.UserId   = 10;

            // create a target, add the way, create a source and verify way in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddWay(way);
            target.Flush();
            target.Close();
            dataSource = this.CreateDataSource();
            foundWay   = dataSource.GetWay(1);
            ComparisonHelpers.CompareSimple(way, foundWay);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-way.
            way          = new Way();
            way.Id       = 1;
            way.UserName = "******";
            way.UserId   = 10;
            way.Version  = 1;

            // create a target, add the way, create a source and verify way in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddWay(way);
            target.Flush();
            target.Close();
            dataSource = this.CreateDataSource();
            foundWay   = dataSource.GetWay(1);
            ComparisonHelpers.CompareSimple(way, foundWay);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-way.
            way          = new Way();
            way.Id       = 1;
            way.UserName = "******";
            way.UserId   = 10;
            way.Version  = 1;
            way.Visible  = true;

            // create a target, add the way, create a source and verify way in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddWay(way);
            target.Flush();
            target.Close();
            dataSource = this.CreateDataSource();
            foundWay   = dataSource.GetWay(1);
            ComparisonHelpers.CompareSimple(way, foundWay);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-way.
            way           = new Way();
            way.Id        = 1;
            way.UserName  = "******";
            way.UserId    = 10;
            way.Version   = 1;
            way.Visible   = true;
            way.TimeStamp = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                                         DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);

            // create a target, add the way, create a source and verify way in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddWay(way);
            target.Flush();
            target.Close();
            dataSource = this.CreateDataSource();
            foundWay   = dataSource.GetWay(1);
            ComparisonHelpers.CompareSimple(way, foundWay);


            this.NotifyEmptyExpected(); // empty test database.

            // create a test-way.
            way           = new Way();
            way.Id        = 1;
            way.UserName  = "******";
            way.UserId    = 10;
            way.Version   = 1;
            way.Visible   = true;
            way.TimeStamp = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                                         DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            way.Tags = new TagsCollection();
            way.Tags.Add("tag", "value");

            // create a target, add the way, create a source and verify way in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddWay(way);
            target.Flush();
            target.Close();
            dataSource = this.CreateDataSource();
            foundWay   = dataSource.GetWay(1);
            ComparisonHelpers.CompareSimple(way, foundWay);

            this.NotifyEmptyExpected(); // empty test database.

            // create a test-way.
            way           = new Way();
            way.Id        = 1;
            way.UserName  = "******";
            way.UserId    = 10;
            way.Version   = 1;
            way.Visible   = true;
            way.TimeStamp = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                                         DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            way.Nodes = new List <long>();
            way.Nodes.Add(1);
            way.Nodes.Add(2);
            way.Nodes.Add(3);
            way.Nodes.Add(1);

            // create a target, add the way, create a source and verify way in db.
            target = this.CreateDataStreamTarget();
            target.Initialize();
            target.AddWay(way);
            target.Flush();
            target.Close();
            dataSource = this.CreateDataSource();
            foundWay   = dataSource.GetWay(1);
            ComparisonHelpers.CompareSimple(way, foundWay);
        }