Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/GetPropertyListValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ public override bool Execute ()
i++;
} while (i < path.Length);

if (array is not null || dict is not null) {
if (array is not null || dict is not null || value.Type is PObjectType.Data) {
Log.LogError (MSBStrings.E0157, value.Type.ToString ().ToLowerInvariant ());
return false;
}

Value = value.ToString ();
Value = value is IPValueObject pvalue ? pvalue.Value.ToString () : value.ToString ();

return !Log.HasLoggedErrors;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ test-msbuild run-tests-msbuild:
$(MAKE) test-macdev-tests test-macdev-tasks

# Example TEST_FILTER:
# TEST_FILTER="--filter FullyQualifiedName~BuildMyCocoaApp"
# TEST_FILTER="--filter:FullyQualifiedName~BuildMyCocoaApp"
# Docs: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test#filter-option-details
test-macdev-tests: export MSBUILD_EXE_PATH=
test-macdev-tests: verify-system-vsmac-xcode-match
$(Q) $(DOTNET) test $(TOP)/tests/msbuild/Xamarin.MacDev.Tests/Xamarin.MacDev.Tests.csproj $(TEST_FILTER)

# Example TEST_FILTER:
# TEST_FILTER="--filter FullyQualifiedName~BuildMyCocoaApp"
# TEST_FILTER="--filter:FullyQualifiedName~BuildMyCocoaApp"
# Docs: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test#filter-option-details
test-macdev-tasks: export MSBUILD_EXE_PATH=
test-macdev-tasks: verify-system-vsmac-xcode-match
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeyNumberInt</key>
<integer>1013</integer>
<key>KeyNumberDouble</key>
<string>10.13</string>
<key>KeyString</key>
<string>MarLoe</string>
<key>KeyBooleanTrue</key>
<true/>
<key>KeyBooleanFalse</key>
<false/>
<key>KeyDate</key>
<date>1974-11-19T10:20:30Z</date>
<key>KeyData</key>
<data>AQID</data>
<key>KeyArray</key>
<array>
<string>Array Item 0</string>
<string>Array Item 1</string>
<string>Array Item 2</string>
<array>
<string>Array Array Item 3.0</string>
<string>Array Array Item 3.1</string>
<string>Array Array Item 3.2</string>
</array>
<dict>
<key>Item0</key>
<string>Array Dictionary Item 4.0</string>
<key>Item1</key>
<string>Array Dictionary Item 4.1</string>
<key>Item2</key>
<string>Array Dictionary Item 4.2</string>
</dict>
</array>
<key>KeyDictionary</key>
<dict>
<key>Item0</key>
<string>Dictionary Item 0</string>
<key>Item1</key>
<string>Dictionary Item 1</string>
<key>Item2</key>
<string>Dictionary Item 2</string>
<key>Item3</key>
<dict>
<key>Item0</key>
<string>Dictionary Dictionary Item 3.0</string>
<key>Item1</key>
<string>Dictionary Dictionary Item 3.1</string>
<key>Item2</key>
<string>Dictionary Dictionary Item 3.2</string>
</dict>
<key>Item4</key>
<array>
<string>Dictionary Array Item 4.0</string>
<string>Dictionary Array Item 4.1</string>
<string>Dictionary Array Item 4.2</string>
</array>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
using System;
using System.IO;
using NUnit.Framework;

using Xamarin.MacDev;
using Xamarin.MacDev.Tasks;

namespace Xamarin.MacDev.Tasks {
[TestFixture]
public class GetPropertyListValueTaskTests : TestBase {

void TestExecuteTask (string property, string expected)
{
var path = Path.Combine (Path.GetDirectoryName (GetType ().Assembly.Location)!, "Resources", "PropertyList.plist");
var task = CreateTask<GetPropertyListValue> ();
task.PropertyListFile = path;
task.Property = property;

if (expected is null) {
Assert.IsFalse (task.Execute (), "Task was expected to fail.");
return;
}

Assert.IsTrue (task.Execute (), "Task was expected to execute successfully.");

Assert.AreEqual (expected, task.Value, "Task produced the incorrect plist output.");
}

[Test]
public void TestWithColonPrefix ()
{
const string property = "KeyString";
const string expected = "MarLoe";

TestExecuteTask (":" + property, expected);
}


[Test]
public void TestWithoutColonPrefix ()
{
const string property = "KeyString";
const string expected = "MarLoe";

TestExecuteTask (property, expected);
}

[Test]
public void TestReturnArrayNotSupported ()
{
const string property = "KeyArray";

TestExecuteTask (property, null);
}

[Test]
public void TestReturnDictionaryNotSupported ()
{
const string property = "KeyDictionary";

TestExecuteTask (property, null);
}

[Test]
public void TestReturnDataNotSupported ()
{
const string property = "KeyData";

TestExecuteTask (property, null);
}

[Test]
public void TestKeyNotFound ()
{
const string property = "ThisKeyDoesNotExist";

TestExecuteTask (property, null);
}

[Test]
public void TestGetStringProperty ()
{
const string property = "KeyString";
const string expected = "MarLoe";

TestExecuteTask (property, expected);
}

[Test]
public void TestGetIntegerProperty ()
{
const string property = "KeyNumberInt";
const string expected = "1013";

TestExecuteTask (property, expected);
}

[Test]
public void TestGetDoubleProperty ()
{
const string property = "KeyNumberDouble";
const string expected = "10.13";

TestExecuteTask (property, expected);
}

[Test]
public void TestGetBooleanTrueProperty ()
{
const string property = "KeyBooleanTrue";
const string expected = "True";

TestExecuteTask (property, expected);
}

[Test]
public void TestGetBooleanFalseProperty ()
{
const string property = "KeyBooleanFalse";
const string expected = "False";

TestExecuteTask (property, expected);
}

[Test]
public void TestGetDateProperty ()
{
const string property = "KeyDate";
const string expected = "11/19/1974 10:20:30 AM";

TestExecuteTask (property, expected);
}

[Test]
public void TestGetArrayIndexOutOfBounds ()
{
var property = $"KeyArray:99";

TestExecuteTask (property, null);
}

[Test]
[TestCase (0)]
[TestCase (1)]
[TestCase (2)]
public void TestGetArrayIndexProperty (int index)
{
var property = $"KeyArray:{index}";
var expected = $"Array Item {index}";

TestExecuteTask (property, expected);
}

[Test]
[TestCase (0)]
[TestCase (1)]
[TestCase (2)]
public void TestGetArrayArrayIndexProperty (int index)
{
var property = $"KeyArray:3:{index}";
var expected = $"Array Array Item 3.{index}";

TestExecuteTask (property, expected);
}

[Test]
[TestCase (0)]
[TestCase (1)]
[TestCase (2)]
public void TestGetArrayDictionaryKeyProperty (int index)
{
var property = $"KeyArray:4:Item{index}";
var expected = $"Array Dictionary Item 4.{index}";

TestExecuteTask (property, expected);
}

[Test]
public void TestGetDictionaryKeyNotFound ()
{
var property = $"KeyDictionary:ItemKeyNotFound";

TestExecuteTask (property, null);
}

[Test]
[TestCase (0)]
[TestCase (1)]
[TestCase (2)]
public void TestGetDictionaryKeyProperty (int index)
{
var property = $"KeyDictionary:Item{index}";
var expected = $"Dictionary Item {index}";

TestExecuteTask (property, expected);
}

[Test]
[TestCase (0)]
[TestCase (1)]
[TestCase (2)]
public void TestGetDictionaryDictionaryKeyProperty (int index)
{
var property = $"KeyDictionary:Item3:Item{index}";
var expected = $"Dictionary Dictionary Item 3.{index}";

TestExecuteTask (property, expected);
}

[Test]
[TestCase (0)]
[TestCase (1)]
[TestCase (2)]
public void TestGetDictionaryArrayKeyProperty (int index)
{
var property = $"KeyDictionary:Item4:{index}";
var expected = $"Dictionary Array Item 4.{index}";

TestExecuteTask (property, expected);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
</None>
</ItemGroup>
<ItemGroup>
<None Update="Resources\PropertyList.plist">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Resources\xcf-xcode12.2.plist">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Loading