using System.Collections.Generic; using Claunia.PropertyList; using Xunit; namespace plistcil.test; public class NSArrayTests { /// Tests the addition of a .NET object to the NSArray [Fact] public void AddAndContainsObjectTest() { var array = new NSArray { 1 }; Assert.True(array.Contains(1)); Assert.False(array.Contains(2)); } /// Tests the method. [Fact] public void EnumeratorTest() { var array = new NSArray { 0, 1 }; using IEnumerator enumerator = array.GetEnumerator(); Assert.Null(enumerator.Current); Assert.True(enumerator.MoveNext()); Assert.Equal(new NSNumber(0), enumerator.Current); Assert.True(enumerator.MoveNext()); Assert.Equal(new NSNumber(1), enumerator.Current); Assert.False(enumerator.MoveNext()); } /// Tests the method for .NET objects. [Fact] public void IndexOfTest() { var array = new NSArray { 1, "test" }; Assert.Equal(0, array.IndexOf(1)); Assert.Equal(1, array.IndexOf("test")); } /// Tests the method for a .NET object. [Fact] public void InsertTest() { var array = new NSArray { 0, 1, 2 }; array.Insert(1, "test"); Assert.Equal(4, array.Count); Assert.Equal("test", array[1].ToObject()); } /// Tests the method for a .NET object. [Fact] public void RemoveTest() { var array = new NSArray { 0 }; Assert.False(array.Remove((object)1)); Assert.True(array.Remove((object)0)); Assert.Empty(array); } }