Example #1
0
        public void ShouldCallUnpublish()
        {
            const string key            = "key";
            const string packageId      = "id";
            const string packageVersion = "version";

            PackagePublishingService.Unpublish(key, packageId, packageVersion);

            MockedPackageUnpublisher.Verify(pp => pp.UnpublishPackage(key, packageId, packageVersion), Times.Once(),
                                            "Package publisher's Unpublish method should have been invoked.");
        }
Example #2
0
        public void RePublishShouldPublishWithRePublishLogAction()
        {
            const string key            = "key";
            const string packageId      = "id";
            const string packageVersion = "version";

            PackagePublishingService.RePublish(key, packageId, packageVersion);

            MockedPackagePublisher.Verify(pp => pp.PublishPackage(key, packageId, packageVersion, PackageLogAction.RePublish), Times.Once(),
                                          "Package publisher should have been invoked with the correct PackageLogAction.");
        }
Example #3
0
        public void ShouldThrowWebFaultExceptionWhenUnpublishThrows()
        {
            var expectedException = new WebFaultException <string>(null, HttpStatusCode.Accepted);

            MockedPackageUnpublisher.Setup(pp => pp.UnpublishPackage(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Throws(new Exception());
            MockedWebFaultExceptionFactory.Setup(wfef => wfef.CreateWebFaultException(It.IsAny <Exception>(), It.IsAny <string>())).Returns(expectedException);

            TestDelegate methodThatShouldThrow = () => PackagePublishingService.Unpublish(null, null, null);

            ExceptionAssert.Throws(methodThatShouldThrow, expectedException, "Incorrect exception thrown.");
        }