Пример #1
0
        public void Copy()
        {
            using (var k = new NSString("key"))
                using (var v = new NSString("value"))
                    using (var d = new NSDictionary <NSString, NSString> (k, v)) {
                        // NSObject.Copy works because NSDictionary conforms to NSCopying
                        // note: we do not Dispose the "copies" because it's the same instance being returned
                        var copy1 = (NSDictionary)d.Copy();
                        Assert.AreSame(d, copy1, "1");
                        Assert.That(copy1, Is.Not.TypeOf <NSMutableDictionary> (), "NSDictionary-1");
                        Assert.That(copy1.Count, Is.EqualTo((nuint)1), "Count-1");

                        var copy2 = (NSDictionary)d.Copy(null);
                        Assert.AreSame(d, copy2, "2");
                        Assert.That(copy2, Is.Not.TypeOf <NSMutableDictionary> (), "NSDictionary-2");
                        Assert.That(copy2.Count, Is.EqualTo((nuint)1), "Count-2");

                        var copy3 = (NSDictionary)d.Copy(NSZone.Default);
                        Assert.AreSame(d, copy3, "3");
                        Assert.That(copy3, Is.Not.TypeOf <NSMutableDictionary> (), "NSDictionary-3");
                        Assert.That(copy3.Count, Is.EqualTo((nuint)1), "Count-3");
                    }
        }