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
44 changes: 36 additions & 8 deletions src/StoreKit/StoreProductParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

#nullable enable

using System.ComponentModel;
using System.Runtime.CompilerServices;
using CoreFoundation;

namespace StoreKit {
Expand All @@ -38,19 +40,33 @@ namespace StoreKit {
#endif
public partial class StoreProductParameters : DictionaryContainer {
#if !COREBUILD
/// <param name="iTunesItemIdentifier">To be added.</param>
/// <summary>Creates a new <see cref="StoreKit.StoreProductParameters" /> for the specified ITunes identifier.</summary>
/// <remarks>To be added.</remarks>
#if !XAMCORE_5_0
/// <summary>Creates a new <see cref="StoreKit.StoreProductParameters" /> for the specified iTunes identifier.</summary>
/// <param name="iTunesItemIdentifier">The 32-bit App Store item identifier to display.</param>
/// <remarks>Use <see cref="StoreProductParameters(long)" /> to support identifiers larger than <see cref="int.MaxValue" />.</remarks>
[OverloadResolutionPriorityAttribute (-1)]
[EditorBrowsable (EditorBrowsableState.Never)]
[Obsolete ("Use 'StoreProductParameters (long)' instead.")]
public StoreProductParameters (int iTunesItemIdentifier)
: this ((long) iTunesItemIdentifier)
{
}
#endif

/// <summary>Creates a new <see cref="StoreKit.StoreProductParameters" /> for the specified 64-bit iTunes identifier.</summary>
/// <param name="iTunesItemIdentifier">The App Store item identifier to display.</param>
public StoreProductParameters (long iTunesItemIdentifier)
: this ()
{
ITunesItemIdentifier = iTunesItemIdentifier;
ITunesItemIdentifierLong = iTunesItemIdentifier;
}

// TODO: What is real iTunes Store item identifier length
/// <summary>Gets or sets the identifier for the ITunes item being advertised.</summary>
/// <value>To be added.</value>
/// <remarks>To be added.</remarks>
#if !XAMCORE_5_0
/// <summary>Gets or sets the legacy 32-bit iTunes item identifier for the App Store product to display.</summary>
/// <value>The 32-bit App Store item identifier, or <see langword="null" /> if not set.</value>
/// <remarks>Use <see cref="ITunesItemIdentifierLong" /> for current identifiers and values larger than <see cref="int.MaxValue" />.</remarks>
[EditorBrowsable (EditorBrowsableState.Never)]
[Obsolete ("Use 'ITunesItemIdentifierLong' instead.")]
public int? ITunesItemIdentifier {
set {
SetNumberValue (SKStoreProductParameterKey.ITunesItemIdentifier, value);
Expand All @@ -59,6 +75,18 @@ public int? ITunesItemIdentifier {
return GetInt32Value (SKStoreProductParameterKey.ITunesItemIdentifier);
}
}
#endif

/// <summary>Gets or sets the 64-bit iTunes item identifier for the App Store product to display.</summary>
/// <value>The App Store item identifier, or <see langword="null" /> if not set.</value>
public long? ITunesItemIdentifierLong {
Comment thread
rolfbjarne marked this conversation as resolved.
set {
SetNumberValue (SKStoreProductParameterKey.ITunesItemIdentifier, value);
}
get {
return GetLongValue (SKStoreProductParameterKey.ITunesItemIdentifier);
}
}

/// <summary>Gets or sets a key for the affiliate token.</summary>
/// <value>To be added.</value>
Expand Down
24 changes: 24 additions & 0 deletions tests/monotouch-test/Foundation/DictionaryContainerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public void SetNumberValue_ (NSString key, nint? value)
SetNumberValue (key, value);
}

public void SetNumberValue_ (NSString key, long? value)
{
SetNumberValue (key, value);
}

public void SetNumberValue_ (NSString key, nuint? value)
{
SetNumberValue (key, value);
Expand Down Expand Up @@ -225,6 +230,25 @@ public void SetNumberValue_UInt32 ()
Assert.That ((int) dc.Dictionary.Count, Is.EqualTo (0), "0");
}

[Test]
public void SetNumberValue_Int64 ()
{
const long value = 2147483648L;
var dc = new DictionaryContainerPoker ();

Assert.Throws<ArgumentNullException> (delegate
{
dc.SetNumberValue_ (null, value);
}, "null key");

dc.SetNumberValue_ (key, value);
Assert.That ((int) dc.Dictionary.Count, Is.EqualTo (1), "1");
Assert.That (((NSNumber) dc.Dictionary [key]).Int64Value, Is.EqualTo (value), "value");

dc.SetNumberValue_ (key, (long?) null);
Assert.That ((int) dc.Dictionary.Count, Is.EqualTo (0), "0");
}

[Test]
public void SetStringValue ()
{
Expand Down
49 changes: 49 additions & 0 deletions tests/monotouch-test/StoreKit/StoreProductParametersTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#if !MONOMAC

using Foundation;
using StoreKit;

namespace MonoTouchFixtures.StoreKit {

[TestFixture]
[Preserve (AllMembers = true)]
public class StoreProductParametersTest {

[Test]
public void ITunesItemIdentifier_64BitRoundtrip ()
{
const long identifier = 2147483648L;

var withCtor = new StoreProductParameters (identifier);
var withSetter = new StoreProductParameters {
ITunesItemIdentifierLong = identifier,
};

Assert.That (withCtor.ITunesItemIdentifierLong, Is.EqualTo (identifier), "Ctor");
Assert.That (withSetter.ITunesItemIdentifierLong, Is.EqualTo (identifier), "Setter");
Assert.That (((NSNumber) withSetter.Dictionary [SKStoreProductParameterKey.ITunesItemIdentifier]).Int64Value, Is.EqualTo (identifier), "Dictionary");
}

#if !XAMCORE_5_0
#pragma warning disable 618
[Test]
public void ITunesItemIdentifier_LegacyRoundtrip ()
{
const int identifier = 123456789;

var parameters = new StoreProductParameters {
ITunesItemIdentifier = identifier,
};

Assert.That (parameters.ITunesItemIdentifier, Is.EqualTo (identifier), "Legacy");
Assert.That (parameters.ITunesItemIdentifierLong, Is.EqualTo (identifier), "Long");
}
#pragma warning restore 618
#endif
}
}

#endif
Loading