public void AddObjectsTest() { var v1 = (NSString)"1"; var v2 = (NSString)"2"; using (var st = new NSMutableSet <NSString> ()) { Assert.Throws <ArgumentNullException> (() => st.AddObjects((NSString)null), "AddObjects ANE 1"); Assert.Throws <ArgumentNullException> (() => st.AddObjects((NSString[])null), "AddObjects ANE 2"); st.AddObjects(v1); Assert.AreEqual((nuint)1, st.Count, "AddObjects 1 Count"); Assert.IsTrue(st.Contains(v1), "AddObjects 1 Contains"); st.RemoveAll(); st.AddObjects(v1, v1); Assert.AreEqual((nuint)1, st.Count, "AddObjects 2 Count"); Assert.IsTrue(st.Contains(v1), "AddObjects 2 Contains"); st.RemoveAll(); st.AddObjects(v2, v1); Assert.AreEqual((nuint)2, st.Count, "AddObjects 3 Count"); Assert.IsTrue(st.Contains(v1), "AddObjects 3 Contains a"); Assert.IsTrue(st.Contains(v2), "AddObjects 3 Contains b"); } }
public void WeakRequiredBillingContactFields() { TestRuntime.AssertXcodeVersion(9, 0); using (var pr = new PKPaymentRequest()) { Assert.That(pr.WeakRequiredBillingContactFields.Count, Is.EqualTo(0), "Count"); using (var set = new NSMutableSet()) { pr.WeakRequiredBillingContactFields = set; Assert.That(pr.WeakRequiredBillingContactFields.Count, Is.EqualTo(0), "Count-0"); set.Add(PKContactFields.PostalAddress.GetConstant()); Assert.That(pr.WeakRequiredBillingContactFields.Count, Is.EqualTo(1), "Count-1"); set.Add(PKContactFields.EmailAddress.GetConstant()); Assert.That(pr.WeakRequiredBillingContactFields.Count, Is.EqualTo(2), "Count-2"); set.Add(PKContactFields.PhoneNumber.GetConstant()); Assert.That(pr.WeakRequiredBillingContactFields.Count, Is.EqualTo(3), "Count-3"); set.Add(PKContactFields.Name.GetConstant()); Assert.That(pr.WeakRequiredBillingContactFields.Count, Is.EqualTo(4), "Count-5"); set.Add(PKContactFields.PhoneticName.GetConstant()); Assert.That(pr.WeakRequiredBillingContactFields.Count, Is.EqualTo(5), "Count-5"); set.Add(PKContactFields.PhoneticName.GetConstant()); Assert.That(pr.WeakRequiredBillingContactFields.Count, Is.EqualTo(5), "Count-5b"); set.Remove(PKContactFields.PhoneticName.GetConstant()); Assert.That(pr.WeakRequiredBillingContactFields.Count, Is.EqualTo(4), "Count-4b"); set.RemoveAll(); Assert.That(pr.WeakRequiredBillingContactFields.Count, Is.EqualTo(0), "Count-0b"); } } }