chore: import upstream snapshot with attribution
Spell checking / Check Spelling (push) Has been cancelled
Spell checking / Update PR (push) Has been cancelled
Publish Dev Docs Website / build (push) Failing after 1s
Publish Dev Docs Website / deploy (push) Has been skipped
Spell checking / Report (Push) (push) Has been cancelled
Spell checking / Report (PR) (push) Has been cancelled
Spell checking / Check Spelling (push) Has been cancelled
Spell checking / Update PR (push) Has been cancelled
Publish Dev Docs Website / build (push) Failing after 1s
Publish Dev Docs Website / deploy (push) Has been skipped
Spell checking / Report (Push) (push) Has been cancelled
Spell checking / Report (PR) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Castle.Core.Internal;
|
||||
using Microsoft.Plugin.Program.Programs;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
{
|
||||
[TestClass]
|
||||
public class UWPTests
|
||||
{
|
||||
private static readonly PackageWrapper DevelopmentModeApp = new PackageWrapper(
|
||||
"DevelopmentApp",
|
||||
"DevelopmentApp",
|
||||
"DevelopmentApp",
|
||||
false,
|
||||
true,
|
||||
"AppxManifests/DevelopmentApp");
|
||||
|
||||
private static readonly PackageWrapper FrameworkApp = new PackageWrapper(
|
||||
"FrameworkApp",
|
||||
"FrameworkApp",
|
||||
"FrameworkApp",
|
||||
true,
|
||||
false,
|
||||
"AppxManifests/FrameworkApp");
|
||||
|
||||
private static readonly PackageWrapper PackagedApp = new PackageWrapper(
|
||||
"PackagedApp",
|
||||
"PackagedApp",
|
||||
"PackagedApp",
|
||||
false,
|
||||
false,
|
||||
"AppxManifests/PackagedApp");
|
||||
|
||||
[TestMethod]
|
||||
public void AllShouldReturnPackagesWithDevelopmentModeWhenCalled()
|
||||
{
|
||||
// Arrange
|
||||
Main.Settings = new ProgramPluginSettings();
|
||||
List<IPackage> packages = new List<IPackage>() { DevelopmentModeApp, PackagedApp };
|
||||
var mock = new Mock<IPackageManager>();
|
||||
mock.Setup(x => x.FindPackagesForCurrentUser()).Returns(packages);
|
||||
UWP.PackageManagerWrapper = mock.Object;
|
||||
|
||||
// Act
|
||||
var applications = UWP.All();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(2, applications.Length);
|
||||
Assert.IsTrue(Array.FindAll(applications, x => x.Name == "DevelopmentApp").Length > 0);
|
||||
Assert.IsTrue(Array.FindAll(applications, x => x.Name == "PackagedApp").Length > 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AllShouldNotReturnPackageFrameworksWhenCalled()
|
||||
{
|
||||
// Arrange
|
||||
Main.Settings = new ProgramPluginSettings();
|
||||
List<IPackage> packages = new List<IPackage>() { FrameworkApp, PackagedApp };
|
||||
var mock = new Mock<IPackageManager>();
|
||||
mock.Setup(x => x.FindPackagesForCurrentUser()).Returns(packages);
|
||||
UWP.PackageManagerWrapper = mock.Object;
|
||||
|
||||
// Act
|
||||
var applications = UWP.All();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, applications.Length);
|
||||
Assert.IsTrue(Array.FindAll(applications, x => x.Name == "PackagedApp").Length > 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void PowerToysRunShouldNotAddInvalidAppWhenIndexingUWPApplications()
|
||||
{
|
||||
// Arrange
|
||||
PackageWrapper invalidPackagedApp = new PackageWrapper();
|
||||
Main.Settings = new ProgramPluginSettings();
|
||||
List<IPackage> packages = new List<IPackage>() { invalidPackagedApp };
|
||||
var mock = new Mock<IPackageManager>();
|
||||
mock.Setup(x => x.FindPackagesForCurrentUser()).Returns(packages);
|
||||
UWP.PackageManagerWrapper = mock.Object;
|
||||
|
||||
// Act
|
||||
var applications = UWP.All();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(0, applications.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user