Skip to content

Commit 9951fd7

Browse files
committed
Update Unit Test
1 parent 83185aa commit 9951fd7

File tree

1 file changed

+6
-1
lines changed
  • src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests

1 file changed

+6
-1
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ public void BuildInDesignTimeMode ([Values(false, true)] bool useManagedParser)
778778
}
779779

780780
[Test]
781-
public void IfAndroidJarDoesNotExistThrowXA5207 ()
781+
public void IfAndroidJarDoesNotExistThrowXA5207 ([Values(true, false)] bool buildingInsideVisualStudio)
782782
{
783783
var path = Path.Combine ("temp", TestName);
784784
var AndroidSdkDirectory = CreateFauxAndroidSdkDirectory (Path.Combine (path, "android-sdk"), "24.0.1", new ApiInfo [] { new ApiInfo { Id = "30" } });
@@ -788,6 +788,7 @@ public void IfAndroidJarDoesNotExistThrowXA5207 ()
788788

789789
using (var builder = CreateApkBuilder (Path.Combine (path, proj.ProjectName), false, false)) {
790790
builder.ThrowOnBuildFailure = false;
791+
builder.BuildingInsideVisualStudio = buildingInsideVisualStudio;
791792
Assert.IsTrue (builder.DesignTimeBuild (proj), "DesignTime build should succeed.");
792793
Assert.IsFalse (builder.LastBuildOutput.ContainsText ("error XA5207:"), "XA5207 should not have been raised.");
793794
builder.Target = "AndroidPrepareForBuild";
@@ -797,6 +798,10 @@ public void IfAndroidJarDoesNotExistThrowXA5207 ()
797798
}), "Build should have failed");
798799
Assert.IsTrue (builder.LastBuildOutput.ContainsText ("error XA5207:"), "XA5207 should have been raised.");
799800
Assert.IsTrue (builder.LastBuildOutput.ContainsText ($"Could not find android.jar for API level {proj.TargetSdkVersion}"), "XA5207 should have had a good error message.");
801+
if (buildingInsideVisualStudio)
802+
Assert.IsTrue (builder.LastBuildOutput.ContainsText ($"Either install it in the Android SDK Manager"), "XA5207 should have an error message for Visual Studio.");
803+
else
804+
Assert.IsTrue (builder.LastBuildOutput.ContainsText ($"You can install the missing API level by running"), "XA5207 should have an error message for the command line.");
800805
}
801806
Directory.Delete (AndroidSdkDirectory, recursive: true);
802807
}

0 commit comments

Comments
 (0)