Skip to content

Commit

Permalink
test: updated unit tests to match changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pictos committed Mar 15, 2023
1 parent 2765bff commit 9c9ae6f
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 4 deletions.
42 changes: 38 additions & 4 deletions src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,45 @@ public void ManifestTakesPriority()
Assert.Equal(expectedDoc.ToString(), outputDoc.ToString());
}

[Theory]
[InlineData("typical", "typical")]
[InlineData("empty", "typical")]
public void CorrectGeneration(string input, string expected)
[Fact]
public void CorrectGenerationWhenUserSpecifyBackgroundColor()
{
var input = "empty";
var expected = "typicalWithNoBackground";
var appIcon = new TaskItem("images/appicon.svg");
appIcon.SetMetadata("ForegroundFile", "images/appiconfg.svg");
appIcon.SetMetadata("IsAppIcon", "true");

var splashScreen = new TaskItem("images/dotnet_bot.svg");
splashScreen.SetMetadata("Color", "#FFFFFF");

var inputFilename = $"testdata/appxmanifest/{input}.appxmanifest";
var task = GetNewTask(inputFilename,
guid: "f9e4fa3e-3505-4742-9b2b-d1acdaff4ec8",
displayVersion: "1.0.0",
version: "1",
displayName: "Sample App",
appIcon: appIcon,
splashScreen: splashScreen);

var success = task.Execute();
Assert.True(success, $"{task.GetType()}.Execute() failed: " + LogErrorEvents.FirstOrDefault()?.Message);

var outputFilename = Path.Combine(DestinationDirectory, "Package.appxmanifest");
var expectedFilename = $"testdata/appxmanifest/{expected}.appxmanifest";

var outputDoc = XDocument.Load(outputFilename);
var expectedDoc = XDocument.Load(expectedFilename);

if (!XNode.DeepEquals(outputDoc, expectedDoc))
Assert.Equal(expectedDoc.ToString(), outputDoc.ToString());
}

[Fact]
public void CorrectGenerationWhitOutBackgroundColor()
{
var input = "typical";
var expected = "typical";
var appIcon = new TaskItem("images/appicon.svg");
appIcon.SetMetadata("ForegroundFile", "images/appiconfg.svg");
appIcon.SetMetadata("IsAppIcon", "true");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">
<Identity Publisher="CN=.NET Foundation" Name="f9e4fa3e-3505-4742-9b2b-d1acdaff4ec8" Version="1.0.0.1" />
<Properties>
<PublisherDisplayName>.NET Foundation</PublisherDisplayName>
<DisplayName>Sample App</DisplayName>
<Logo>Images/appiconStoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
<uap:VisualElements DisplayName="Sample App" Description="Sample App" BackgroundColor="#ffffff" Square150x150Logo="Images/appiconMediumTile.png" Square44x44Logo="Images/appiconLogo.png">
<uap:DefaultTile Wide310x150Logo="Images/appiconWideTile.png" Square71x71Logo="Images/appiconSmallTile.png" Square310x310Logo="Images/appiconLargeTile.png" ShortName="Sample App">
<uap:ShowNameOnTiles>
<uap:ShowOn Tile="square150x150Logo" />
<uap:ShowOn Tile="wide310x150Logo" />
</uap:ShowNameOnTiles>
</uap:DefaultTile>
<uap:SplashScreen Image="dotnet_botSplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
<DeviceCapability Name="location" />
</Capabilities>
</Package>

0 comments on commit 9c9ae6f

Please sign in to comment.