コード例 #1
0
    TestCopyTo
    (
        Boolean bCopyMetadataValues,
        Boolean bCopyTag
    )
    {
        // Set some key/value pairs and the Tag on m_oGraphVertexEdgeBase.

        const Int32 Tag = -29;

        const String Key1 = "xyz";
        const Int32 Value1 = 123456;

        const String Key2 = "xx8372";
        DateTime Value2 = DateTime.Now;

        m_oGraphVertexEdgeBase.SetValue(Key1, Value1);
        m_oGraphVertexEdgeBase.SetValue(Key2, Value2);

        m_oGraphVertexEdgeBase.Tag = Tag;

        GraphVertexEdgeBase oCopy = new MockGraphVertexEdgeBase();

        Int32 iID = oCopy.ID;

        m_oGraphVertexEdgeBase.CopyTo(oCopy, bCopyMetadataValues, bCopyTag);

        Assert.AreEqual(iID, oCopy.ID);
        Assert.IsNull(oCopy.Name);

        if (bCopyMetadataValues)
        {
            Assert.IsTrue( oCopy.ContainsKey(Key1) );
            Assert.AreEqual(Value1, oCopy.GetValue( Key1, typeof(Int32) ) );

            Assert.IsTrue( oCopy.ContainsKey(Key2) );
            Assert.AreEqual(Value2, oCopy.GetValue( Key2, typeof(DateTime) ) );
        }
        else
        {
            Assert.IsFalse( oCopy.ContainsKey(Key1) );
            Assert.IsFalse( oCopy.ContainsKey(Key2) );
        }

        if (bCopyTag)
        {
            Assert.AreEqual(Tag, oCopy.Tag);
        }
        else
        {
            Assert.IsNull(oCopy.Tag);
        }
    }
コード例 #2
0
    TestSetGetValue5()
    {
        // Add N keys for each of N GraphVertexEdgeBase objects, ask for same
        // keys in reverse order.

        // Create an array of keys.

        const Int32 Keys = 10;

        String [] asKeys = new String[Keys];

        for (Int32 i = 0; i < Keys; i++)
        {
            asKeys[i] = Guid.NewGuid().ToString();
        }

        // Create an array of GraphVertexEdgeBase objects.

        const Int32 GraphVertexEdgeBaseObjects = 10000;

        GraphVertexEdgeBase [] aoGraphVertexEdgeBase =
            new GraphVertexEdgeBase[GraphVertexEdgeBaseObjects];

        for (Int32 j = 0; j < GraphVertexEdgeBaseObjects; j++)
        {
            aoGraphVertexEdgeBase[j] = new MockGraphVertexEdgeBase();
        }

        // Add a value for each key.  The value is just the key with appended
        // indexes.

        for (Int32 j = 0; j < GraphVertexEdgeBaseObjects; j++)
        {
            GraphVertexEdgeBase oGraphVertexEdgeBase =
                aoGraphVertexEdgeBase[j];

            for (Int32 i = 0; i < Keys; i++)
            {
                String sKey = asKeys[i];

                oGraphVertexEdgeBase.SetValue(
                    sKey, sKey + i.ToString() + j.ToString() );
            }
        }

        // Retrieve the values.

        Boolean bContainsKey;

        for (Int32 j = GraphVertexEdgeBaseObjects - 1; j >= 0; j--)
        {
            GraphVertexEdgeBase oGraphVertexEdgeBase =
                aoGraphVertexEdgeBase[j];

            for (Int32 i = Keys - 1; i >= 0; i--)
            {
                String sKey = asKeys[i];

                bContainsKey = oGraphVertexEdgeBase.ContainsKey(sKey);

                Assert.IsTrue(bContainsKey);

                MetadataUtil.TestGetValue( oGraphVertexEdgeBase, sKey, 
                    sKey + i.ToString() + j.ToString() );
            }

            // Ask for a non-existent value.

            bContainsKey = oGraphVertexEdgeBase.ContainsKey("nHnHn");

            Assert.IsFalse(bContainsKey);
        }

        // Create another GraphVertexEdgeBase object and verify that it
        // contains no keys.

        GraphVertexEdgeBase oGraphVertexEdgeBaseNoKeys =
            new MockGraphVertexEdgeBase();

        for (Int32 i = 0; i < Keys; i++)
        {
            String sKey = asKeys[i];

            bContainsKey = oGraphVertexEdgeBaseNoKeys.ContainsKey(sKey);

            Assert.IsFalse(bContainsKey);
        }
    }