Esempio n. 1
0
 public async Task InvalidPackageVersion()
 {
     var scriptExecutor = new Mock <IScriptExecutor>();
     var executor       = new VsGlobalPackagesInitScriptExecutor(scriptExecutor.Object);
     await Assert.ThrowsAsync <ArgumentException>(async()
                                                  => await executor.ExecuteInitScriptAsync("A", "1.abc.0"));
 }
Esempio n. 2
0
 public async Task EmptyPackageVersion()
 {
     var scriptExecutor = new Mock <IScriptExecutor>();
     var executor       = new VsGlobalPackagesInitScriptExecutor(scriptExecutor.Object);
     await Assert.ThrowsAsync <ArgumentException>(async()
                                                  => await executor.ExecuteInitScriptAsync("A", packageVersion: string.Empty));
 }
Esempio n. 3
0
 public async Task NullPackageId()
 {
     var scriptExecutor = new Mock <IScriptExecutor>();
     var executor       = new VsGlobalPackagesInitScriptExecutor(scriptExecutor.Object);
     await Assert.ThrowsAsync <ArgumentException>(async()
                                                  => await executor.ExecuteInitScriptAsync(packageId:  null, packageVersion: "1.0.0"));
 }
 public async Task EmptyPackageId()
 {
     var scriptExecutor = new Mock <IScriptExecutor>();
     var executor       = new VsGlobalPackagesInitScriptExecutor(scriptExecutor.Object, _telemetryProvider.Object);
     await Assert.ThrowsAsync <ArgumentException>(async()
                                                  => await executor.ExecuteInitScriptAsync(packageId: string.Empty, packageVersion: "1.0.0"));
 }
 public async Task NullPackageVersion()
 {
     var scriptExecutor = new Mock <IScriptExecutor>();
     var executor       = new VsGlobalPackagesInitScriptExecutor(scriptExecutor.Object, _telemetryProvider.Object);
     await Assert.ThrowsAsync <ArgumentException>(async()
                                                  => await executor.ExecuteInitScriptAsync("A", packageVersion: null));
 }
        public async Task ExecuteInitScriptAsync_ImplementationBug_PostsFault()
        {
            // Arrange
            var scriptExecutor = new Mock <IScriptExecutor>();
            // Pretend that there's an implementation bug that throws a ArgumentException. This specific exception type
            // is interesting, because it should not be recorded as a fault for API customer inputs, only for internal
            // implementation bugs.
            var expectedException = new ArgumentException("internal bug");

            scriptExecutor.Setup(se => se.ExecuteInitScriptAsync(It.IsAny <PackageIdentity>()))
            .Throws(expectedException);
            var telemetry = new Mock <INuGetTelemetryProvider>();

            // Act
            var target          = new VsGlobalPackagesInitScriptExecutor(scriptExecutor.Object, telemetry.Object);
            var actualException = await Assert.ThrowsAsync <ArgumentException>(() => target.ExecuteInitScriptAsync("A", "1.2.3"));

            // Assert
            telemetry.Verify(t => t.PostFaultAsync(expectedException, typeof(VsGlobalPackagesInitScriptExecutor).FullName, nameof(VsGlobalPackagesInitScriptExecutor.ExecuteInitScriptAsync), It.IsAny <IDictionary <string, object> >()));
            Assert.Equal(expectedException, actualException);
        }