Exemple #1
0
 def test_as_function(self):
     propset = wfc.PropertySet()
     propset.Insert("strmap", wfc.StringMap())
     self.assertTrue(propset.HasKey("strmap"))
     o = propset.Lookup("strmap")
     strmap = wfc.StringMap._from(o)
     self.assertEqual(type(strmap), wfc.StringMap)
Exemple #2
0
    def test_stringmap(self):
        m = wfc.StringMap()
        m.Insert("hello", "world")

        self.assertTrue(m.HasKey("hello"))
        self.assertFalse(m.HasKey("world"))
        self.assertEqual(m.Size, 1)
        self.assertEqual(m.Lookup("hello"), "world")
Exemple #3
0
        async def async_test():
            future = loop.create_future()

            def onMapChanged(sender, args): 
                self.assertEqual(args.CollectionChange, wfc.CollectionChange.ItemInserted)
                self.assertEqual(args.Key, "dr")

                self.assertEqual(sender.Size, 2)
                self.assertTrue(sender.HasKey("dr"))
                self.assertTrue(sender.HasKey("hello"))
                
                loop.call_soon_threadsafe(asyncio.Future.set_result, future, True)

            m = wfc.StringMap()
            m.Insert("hello", "world")
            token = m.add_MapChanged(onMapChanged)
            m.Insert("dr", "who")
            m.remove_MapChanged(token)

            called = await future
            self.assertTrue(called)