public void NewPackageVersionUpload_ThrowsExceptionWhenPackageIsTooBig() { var pub = BigPackageUploadBuilderMock(); var files = new[] { @"C:\file1.dyf", @"C:\file2.dyf" }; var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); var pkgsDir = @"C:\dynamopackages"; var handle = new PackageUploadHandle(PackageUploadBuilder.NewRequestBody(pkg)); Assert.Throws<Exception>(() => pub.NewPackageVersionUpload(pkg, pkgsDir, files, handle)); }
public void NewPackageVersionUpload_ThrowsForNullArguments() { var files = new[] { @"C:\file1.dyf", @"C:\file2.dyf" }; var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); var pkgsDir = @"C:\dynamopackages"; var handle = new PackageUploadHandle(PackageUploadBuilder.NewRequestBody(pkg)); var m = new PackageUploadBuilder(MockMaker.Empty<IPackageDirectoryBuilder>(), MockMaker.Empty<IFileCompressor>()); Assert.Throws<ArgumentNullException>(() => m.NewPackageVersionUpload(null, pkgsDir, files, handle)); Assert.Throws<ArgumentNullException>(() => m.NewPackageVersionUpload(pkg, null, files, handle)); Assert.Throws<ArgumentNullException>(() => m.NewPackageVersionUpload(pkg, pkgsDir, null, handle)); Assert.Throws<ArgumentNullException>(() => m.NewPackageVersionUpload(pkg, pkgsDir, files, null)); }
public void Publish_SetsHandleToDoneWhenNewPackageVersionPublishSucceeds() { var gc = new Mock <IGregClient>(); gc.Setup(x => x.ExecuteAndDeserialize(It.IsAny <PackageVersionUpload>())) .Returns(new ResponseBody() { success = true }); var pc = new PackageManagerClient(gc.Object, MockMaker.Empty <IPackageUploadBuilder>()); var pkg = new Package("", "Package", "0.1.0", "MIT"); var handle = new PackageUploadHandle(PackageUploadBuilder.NewRequestBody(pkg)); pc.Publish(pkg, Enumerable.Empty <string>(), false, handle); Assert.AreEqual(PackageUploadHandle.State.Uploaded, handle.UploadState); }
public void Publish_SetsErrorStatusWhenResponseIsNull() { var gc = new Mock<IGregClient>(); var rb = new ResponseBody(); rb.success = false; gc.Setup(x => x.ExecuteAndDeserialize(It.IsAny<PackageUpload>())).Returns(rb); var pc = new PackageManagerClient(gc.Object, MockMaker.Empty<IPackageUploadBuilder>(), ""); var pkg = new Package("", "Package", "0.1.0", "MIT"); var handle = new PackageUploadHandle(PackageUploadBuilder.NewRequestBody(pkg)); pc.Publish(pkg, Enumerable.Empty<string>(), true, handle); Assert.AreEqual(PackageUploadHandle.State.Error, handle.UploadState); }
public void Publish_SetsErrorStatusWhenRequestThrowsAnException() { var gc = new Mock<IGregClient>(); gc.Setup(x => x.ExecuteAndDeserialize(It.IsAny<PackageUpload>())).Throws<Exception>(); var pc = new PackageManagerClient(gc.Object, MockMaker.Empty<IPackageUploadBuilder>(), ""); var pkg = new Package("", "Package", "0.1.0", "MIT"); var handle = new PackageUploadHandle(PackageUploadBuilder.NewRequestBody(pkg)); pc.Publish(pkg, Enumerable.Empty<string>(), false, handle); Assert.AreEqual(PackageUploadHandle.State.Error, handle.UploadState); }
public void Publish_SetsHandleToDoneWhenNewPackageVersionPublishSucceeds() { var gc = new Mock<IGregClient>(); gc.Setup(x => x.ExecuteAndDeserialize(It.IsAny<PackageVersionUpload>())) .Returns(new ResponseBody() { success = true }); var pc = new PackageManagerClient(gc.Object, MockMaker.Empty<IPackageUploadBuilder>(), ""); var pkg = new Package("", "Package", "0.1.0", "MIT"); var handle = new PackageUploadHandle(PackageUploadBuilder.NewRequestBody(pkg)); pc.Publish(pkg, Enumerable.Empty<string>(), false, handle); Assert.AreEqual(PackageUploadHandle.State.Uploaded, handle.UploadState); }