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
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ static void AssertAttributeCreation<T> (Func<PlatformName, int, int, string?, T>
{
var typeName = typeof (T).Name;
var attr = callback (platform, major, minor, message) as T;
Assert.IsNotNull (attr, $"{typeName} attribute type");
Assert.AreEqual (platform, attr.Platform, $"{typeName} Platform");
Assert.AreEqual (major, attr.Version!.Major, $"{typeName} Major");
Assert.AreEqual (minor, attr.Version!.Minor, $"{typeName} Minor");
Assert.AreEqual (message, attr.Message);
Assert.That (attr, Is.Not.Null, $"{typeName} attribute type");
Assert.That (attr.Platform, Is.EqualTo (platform), $"{typeName} Platform");
Assert.That (attr.Version!.Major, Is.EqualTo (major), $"{typeName} Major");
Assert.That (attr.Version!.Minor, Is.EqualTo (minor), $"{typeName} Minor");
Assert.That (attr.Message, Is.EqualTo (message));
}

static void AssertAttributeCreationNotVersion<T> (Func<PlatformName, string?, T> callback, PlatformName platform,
string? message = null) where T : AvailabilityBaseAttribute
{
var typeName = typeof (T).Name;
var attr = callback (platform, message) as T;
Assert.IsNotNull (attr, $"{typeName} attribute type");
Assert.AreEqual (platform, attr.Platform, $"{typeName} Platform");
Assert.AreEqual (message, attr.Message);
Assert.That (attr, Is.Not.Null, $"{typeName} attribute type");
Assert.That (attr.Platform, Is.EqualTo (platform), $"{typeName} Platform");
Assert.That (attr.Message, Is.EqualTo (message));
}


Expand Down Expand Up @@ -58,14 +58,14 @@ public void CreateAttributeNoVersionTest (PlatformName platform, string? message
[TestCase (PlatformName.MacOSX)]
[TestCase (PlatformName.TvOS)]
public void CreateNoVersionSupportedAttributeTest (PlatformName platform)
=> Assert.AreEqual (platform, AttributeFactory.CreateNoVersionSupportedAttribute (platform).Platform);
=> Assert.That (AttributeFactory.CreateNoVersionSupportedAttribute (platform).Platform, Is.EqualTo (platform));

[TestCase (PlatformName.iOS)]
[TestCase (PlatformName.MacCatalyst)]
[TestCase (PlatformName.MacOSX)]
[TestCase (PlatformName.TvOS)]
public void CreateUnsupportedAttributeTest (PlatformName platform)
=> Assert.AreEqual (platform, AttributeFactory.CreateUnsupportedAttribute (platform).Platform);
=> Assert.That (AttributeFactory.CreateUnsupportedAttribute (platform).Platform, Is.EqualTo (platform));

class CloneCasesNoVersionClass : IEnumerable {
public IEnumerator GetEnumerator ()
Expand All @@ -90,9 +90,9 @@ public IEnumerator GetEnumerator ()
public void CloneNoVersionTest (AvailabilityBaseAttribute attributeToClone, PlatformName targetPlatform)
{
var clone = AttributeFactory.CloneFromOtherPlatform (attributeToClone, targetPlatform);
Assert.AreEqual (targetPlatform, clone.Platform, "platform");
Assert.AreEqual (attributeToClone.Message, clone.Message, "message");
Assert.AreEqual (attributeToClone.GetType (), clone.GetType (), "type");
Assert.That (clone.Platform, Is.EqualTo (targetPlatform), "platform");
Assert.That (clone.Message, Is.EqualTo (attributeToClone.Message), "message");
Assert.That (clone.GetType (), Is.EqualTo (attributeToClone.GetType ()), "type");
}

class CloneCasesMinVersionClass : IEnumerable {
Expand All @@ -113,13 +113,13 @@ public IEnumerator GetEnumerator ()
public void CloneMinVersion (AvailabilityBaseAttribute attributeToClone, PlatformName targetPlatform)
{
var clone = AttributeFactory.CloneFromOtherPlatform (attributeToClone, targetPlatform);
Assert.AreEqual (targetPlatform, clone.Platform, "platform");
Assert.AreEqual (attributeToClone.Message, clone.Message, "message");
Assert.AreEqual (attributeToClone.GetType (), clone.GetType (), "type");
Assert.That (clone.Platform, Is.EqualTo (targetPlatform), "platform");
Assert.That (clone.Message, Is.EqualTo (attributeToClone.Message), "message");
Assert.That (clone.GetType (), Is.EqualTo (attributeToClone.GetType ()), "type");
if (clone.AvailabilityKind == AvailabilityKind.Introduced) {
Assert.Null (clone.Version, "Version");
Assert.That (clone.Version, Is.Null, "Version");
} else {
Assert.AreEqual (Xamarin.SdkVersions.GetMinVersion (targetPlatform.AsApplePlatform ()), clone.Version, "Version");
Assert.That (clone.Version, Is.EqualTo (Xamarin.SdkVersions.GetMinVersion (targetPlatform.AsApplePlatform ())), "Version");
}
}

Expand All @@ -145,10 +145,10 @@ public IEnumerator GetEnumerator ()
public void CloneBuildVersion (AvailabilityBaseAttribute attributeToClone, PlatformName targetPlatform)
{
var clone = AttributeFactory.CloneFromOtherPlatform (attributeToClone, targetPlatform);
Assert.AreEqual (targetPlatform, clone.Platform, "platform");
Assert.AreEqual (attributeToClone.Message, clone.Message, "message");
Assert.AreEqual (attributeToClone.GetType (), clone.GetType (), "type");
Assert.AreEqual (attributeToClone.Version, clone.Version);
Assert.That (clone.Platform, Is.EqualTo (targetPlatform), "platform");
Assert.That (clone.Message, Is.EqualTo (attributeToClone.Message), "message");
Assert.That (clone.GetType (), Is.EqualTo (attributeToClone.GetType ()), "type");
Assert.That (clone.Version, Is.EqualTo (attributeToClone.Version));
}

}
Expand Down
2 changes: 1 addition & 1 deletion tests/generator/BGenBase.cs → tests/bgen/BGenBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal BGenTool BuildFile (Profile profile, bool nowarnings, Action<BGenTool>
TestContext.Out.WriteLine (TestContext.CurrentContext.Test.FullName);
foreach (var filename in filenames)
TestContext.Out.WriteLine ($"\t{filename}");
bgen.CreateTemporaryBinding (filenames.Select ((filename) => File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", filename))).ToArray ());
bgen.CreateTemporaryBinding (filenames.Select ((filename) => File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", filename))).ToArray ());
bgen.AssertExecute ("build");
if (nowarnings)
bgen.AssertNoWarnings ();
Expand Down
Loading
Loading