コード例 #1
0
		public PackageOperation AddOneFakeUninstallPackageOperation ()
		{
			var package = new FakePackage ("PackageToUninstall");
			var operation = new FakePackageOperation (package, PackageAction.Uninstall);
			FakeSolution.FakeProjectToReturnFromGetProject.FakeInstallOperations.Add (operation);
			return operation;
		}
コード例 #2
0
        public FakePackageOperation AddFakeUninstallOperation()
        {
            var package   = new FakePackage("MyPackage");
            var operation = new FakePackageOperation(package, PackageAction.Uninstall);

            FakeInstallOperations.Add(operation);
            return(operation);
        }
コード例 #3
0
        public PackageOperation AddOneFakeUninstallPackageOperation()
        {
            var package   = new FakePackage("PackageToUninstall");
            var operation = new FakePackageOperation(package, PackageAction.Uninstall);

            FakeSolution.FakeProjectToReturnFromGetProject.FakeInstallOperations.Add(operation);
            return(operation);
        }
コード例 #4
0
        public PackageOperation AddOneFakeInstallPackageOperationForViewModelPackage()
        {
            var operation = new FakePackageOperation(FakePackage, PackageAction.Install);

            FakeSolution
            .FakeProjectToReturnFromGetProject
            .FakeInstallOperations
            .Add(operation);

            return(operation);
        }
コード例 #5
0
		public PackageOperation AddOneFakeInstallPackageOperationForViewModelPackage ()
		{
			var operation = new FakePackageOperation (FakePackage, PackageAction.Install);

			FakeSolution
				.FakeProjectToReturnFromGetProject
				.FakeInstallOperations
				.Add (operation);

			return operation;
		}
コード例 #6
0
		public void Execute_PackageBeingInstalledHasPowerShellScripts_WarningAboutPowerShellScriptsIsLogged ()
		{
			CreateAction ();
			FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.0");
			expectedPackage.AddFile (@"tools\init.ps1");
			var operation = new FakePackageOperation (expectedPackage, PackageAction.Install);
			action.PackageId = expectedPackage.Id;
			action.PackageVersion = expectedPackage.Version;
			fakeProject.FakeInstallOperations.Add (operation);
			string messageLogged = null;
			packageManagementEvents.PackageOperationMessageLogged += (sender, e) => {
				if (e.Message.Level == MessageLevel.Warning) {
					messageLogged = e.Message.ToString ();
				}
			};

			action.Execute ();

			Assert.AreEqual ("Test Package contains PowerShell scripts which will not be run.", messageLogged);
		}
コード例 #7
0
		public void Execute_ProjectHasOnePackageInstallOperationThatHasALicenseToBeAcceptedAndLicensesNotAccepted_ExceptionThrown ()
		{
			CreateAction ();
			FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.0");
			expectedPackage.RequireLicenseAcceptance = true;
			var operation = new FakePackageOperation (expectedPackage, PackageAction.Install);
			action.PackageId = expectedPackage.Id;
			action.PackageVersion = expectedPackage.Version;
			fakeProject.FakeInstallOperations.Add (operation);
			packageManagementEvents.AcceptLicenses += (sender, e) => {
				e.IsAccepted = false;
			};

			Exception ex = Assert.Throws (typeof(ApplicationException), () => action.Execute ());

			Assert.AreEqual ("Licenses not accepted.", ex.Message);
		}
コード例 #8
0
		public void Execute_ProjectHasOnePackageInstallOperationThatHasALicenseToBeAcceptedButPackageInstalledAlready_NoAcceptLicensesEventIsRaised ()
		{
			CreateAction ();
			FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.0");
			expectedPackage.RequireLicenseAcceptance = true;
			var operation = new FakePackageOperation (expectedPackage, PackageAction.Install);
			action.PackageId = expectedPackage.Id;
			action.PackageVersion = expectedPackage.Version;
			fakeProject.FakeInstallOperations.Add (operation);
			fakeProject.FakePackages.Add (expectedPackage);
			bool acceptLicensesEventRaised = false;
			packageManagementEvents.AcceptLicenses += (sender, e) => {
				acceptLicensesEventRaised = true;
			};

			action.Execute ();

			Assert.IsFalse (acceptLicensesEventRaised);
		}
コード例 #9
0
		public void Execute_ProjectHasOnePackageInstallOperationThatHasALicenseToBeAccepted_AcceptLicensesEventRaised ()
		{
			CreateAction ();
			FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.0");
			expectedPackage.RequireLicenseAcceptance = true;
			var expectedPackages = new IPackage [] { expectedPackage };
			var operation = new FakePackageOperation (expectedPackage, PackageAction.Install);
			action.PackageId = expectedPackage.Id;
			action.PackageVersion = expectedPackage.Version;
			fakeProject.FakeInstallOperations.Add (operation);
			List<IPackage> actualPackages = null;
			packageManagementEvents.AcceptLicenses += (sender, e) => {
				e.IsAccepted = true;
				actualPackages = e.Packages.ToList ();
			};

			action.Execute ();

			PackageCollectionAssert.AreEqual (expectedPackages, actualPackages);
		}
コード例 #10
0
		public void HasPackageScriptsToRun_ProjectHasOnePackageOperation_PackageLocated ()
		{
			CreateAction ();
			FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.0");
			var operation = new FakePackageOperation (expectedPackage, PackageAction.Install);
			action.PackageId = expectedPackage.Id;
			action.PackageVersion = expectedPackage.Version;
			fakeProject.FakeInstallOperations.Add (operation);

			action.HasPackageScriptsToRun ();

			IPackage actualPackage = action.Package;

			Assert.AreEqual (expectedPackage, actualPackage);
		}
コード例 #11
0
		public void HasPackageScriptsToRun_ProjectHasOnePackageOperation_DoesNotThrowNullReferenceException ()
		{
			CreateAction ();
			FakePackage package = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.0");
			var operation = new FakePackageOperation (package, PackageAction.Install);
			action.PackageId = package.Id;
			action.PackageVersion = package.Version;
			fakeProject.FakeInstallOperations.Add (operation);

			Assert.DoesNotThrow (() => action.HasPackageScriptsToRun ());
		}
コード例 #12
0
		public FakePackageOperation AddFakeUninstallOperation ()
		{
			var package = new FakePackage ("MyPackage");
			var operation = new FakePackageOperation (package, PackageAction.Uninstall);
			FakeInstallOperations.Add (operation);
			return operation;
		}
コード例 #13
0
		public void Execute_PackageBeingInstalledHasPowerShellScripts_MessageAboutPowerShellScriptsIsLogged ()
		{
			CreateAction ();
			FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.0");
			expectedPackage.AddFile (@"tools\init.ps1");
			var operation = new FakePackageOperation (expectedPackage, PackageAction.Install);
			action.PackageId = expectedPackage.Id;
			action.PackageVersion = expectedPackage.Version;
			fakeProject.FakeInstallOperations.Add (operation);
			var messagesLogged = new List<string> ();
			packageManagementEvents.PackageOperationMessageLogged += (sender, e) => {
				if (e.Message.Level == MessageLevel.Info) {
					messagesLogged.Add (e.Message.ToString ());
				}
			};

			action.Execute ();

			Assert.That (messagesLogged, Contains.Item ("WARNING: Test Package contains PowerShell scripts which will not be run."));
		}