2018-07-09 19:57:08 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Claunia.PropertyList;
|
2017-03-16 23:37:42 +01:00
|
|
|
|
using Xunit;
|
2016-05-22 16:05:33 +02:00
|
|
|
|
|
|
|
|
|
|
namespace plistcil.test
|
|
|
|
|
|
{
|
|
|
|
|
|
public class NSArrayTests
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2018-07-09 19:57:08 +01:00
|
|
|
|
/// Tests the addition of a .NET object to the NSArray
|
2016-05-22 16:05:33 +02:00
|
|
|
|
/// </summary>
|
2017-03-16 23:37:42 +01:00
|
|
|
|
[Fact]
|
2016-05-22 16:05:33 +02:00
|
|
|
|
public void AddAndContainsObjectTest()
|
|
|
|
|
|
{
|
|
|
|
|
|
NSArray array = new NSArray();
|
|
|
|
|
|
array.Add(1);
|
|
|
|
|
|
|
2017-03-16 23:37:42 +01:00
|
|
|
|
Assert.True(array.Contains(1));
|
|
|
|
|
|
Assert.False(array.Contains(2));
|
2016-05-22 16:05:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-07-09 19:57:08 +01:00
|
|
|
|
/// Tests the <see cref="NSArray.GetEnumerator" /> method.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void EnumeratorTest()
|
|
|
|
|
|
{
|
|
|
|
|
|
NSArray array = new NSArray();
|
|
|
|
|
|
array.Add(0);
|
|
|
|
|
|
array.Add(1);
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerator<NSObject> 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());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Tests the <see cref="NSArray.IndexOf(object)" /> method for .NET objects.
|
2016-05-22 16:05:33 +02:00
|
|
|
|
/// </summary>
|
2017-03-16 23:37:42 +01:00
|
|
|
|
[Fact]
|
2016-05-22 16:05:33 +02:00
|
|
|
|
public void IndexOfTest()
|
|
|
|
|
|
{
|
|
|
|
|
|
NSArray array = new NSArray();
|
|
|
|
|
|
array.Add(1);
|
|
|
|
|
|
array.Add("test");
|
|
|
|
|
|
|
2017-03-16 23:37:42 +01:00
|
|
|
|
Assert.Equal(0, array.IndexOf(1));
|
|
|
|
|
|
Assert.Equal(1, array.IndexOf("test"));
|
2016-05-22 16:05:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-07-09 19:57:08 +01:00
|
|
|
|
/// Tests the <see cref="NSArray.Insert(int, object)" /> method for a
|
|
|
|
|
|
/// .NET object.
|
2016-05-22 16:05:33 +02:00
|
|
|
|
/// </summary>
|
2017-03-16 23:37:42 +01:00
|
|
|
|
[Fact]
|
2016-05-22 16:05:33 +02:00
|
|
|
|
public void InsertTest()
|
|
|
|
|
|
{
|
|
|
|
|
|
NSArray array = new NSArray();
|
|
|
|
|
|
array.Add(0);
|
|
|
|
|
|
array.Add(1);
|
|
|
|
|
|
array.Add(2);
|
|
|
|
|
|
|
|
|
|
|
|
array.Insert(1, "test");
|
|
|
|
|
|
|
2018-07-09 19:57:08 +01:00
|
|
|
|
Assert.Equal(4, array.Count);
|
2018-05-22 22:02:06 +02:00
|
|
|
|
Assert.Equal("test", array[1].ToObject());
|
2016-05-22 16:05:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-07-09 19:57:08 +01:00
|
|
|
|
/// Tests the <see cref="NSArray.Remove(object)" /> method for a .NET object.
|
2016-05-22 16:05:33 +02:00
|
|
|
|
/// </summary>
|
2017-03-16 23:37:42 +01:00
|
|
|
|
[Fact]
|
2016-05-22 16:05:33 +02:00
|
|
|
|
public void RemoveTest()
|
|
|
|
|
|
{
|
|
|
|
|
|
NSArray array = new NSArray();
|
|
|
|
|
|
array.Add(0);
|
2017-03-16 23:37:42 +01:00
|
|
|
|
Assert.False(array.Remove((object)1));
|
|
|
|
|
|
Assert.True(array.Remove((object)0));
|
2016-05-22 16:05:33 +02:00
|
|
|
|
|
2018-05-22 22:02:06 +02:00
|
|
|
|
Assert.Empty(array);
|
2016-05-22 16:05:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-09 19:57:08 +01:00
|
|
|
|
}
|