コード例 #1
0
        public void Publish(string key, string id, string version)
        {
            const string defaultMessage = "An error occurred when publishing the Package";

            ValidateInputs(() => _serviceInputValidator.ValidateAllPackageKeys(key, id, version));
            Action action = () => _packagePublisher.PublishPackage(key, id, version, PackageLogAction.Update);

            ExecuteAction(action, defaultMessage);
        }
コード例 #2
0
        public void ValidateAllPackageKeysShouldValidateUserKeyPackageIdAndPackageVersion()
        {
            _userKeyValidator.Setup(ukv => ukv.IsValidUserKey(VALID_USER_KEY)).Returns(true);
            _packageIdValidator.Setup(piv => piv.IsValidPackageId(VALID_PACKAGE_ID)).Returns(true);
            _packageVersionValidator.Setup(pvv => pvv.IsValidPackageVersion(VALID_PACKAGE_VERSION)).Returns(true);

            _validator.ValidateAllPackageKeys(VALID_USER_KEY, VALID_PACKAGE_ID, VALID_PACKAGE_VERSION);

            _userKeyValidator.Verify(ukv => ukv.IsValidUserKey(VALID_USER_KEY), Times.Once());
            _packageIdValidator.Verify(piv => piv.IsValidPackageId(VALID_PACKAGE_ID), Times.Once());
            _packageVersionValidator.Verify(pvv => pvv.IsValidPackageVersion(VALID_PACKAGE_VERSION), Times.Once());
        }
コード例 #3
0
        public void Update(string key, string id, string version, Package instance)
        {
            Action validateInputsAction = () =>
            {
                _serviceInputValidator.ValidateAllPackageKeys(key, id, version);
                _serviceInputValidator.ValidateKeysMatchInstance(id, version, instance);
            };

            ValidateInputs(validateInputsAction);
            Action updateAction = () => {
                _packageAuthenticator.EnsureKeyCanAccessPackage(key, id, version);
                _packageUpdater.UpdateExistingPackage(instance);
            };

            ExecuteAction(updateAction, "The Package could not be updated");
        }
コード例 #4
0
        public Screenshot Create(string key, Screenshot instance)
        {
            ValidateInputs(() => _serviceInputValidator.ValidateAllPackageKeys(key, instance.PackageId, instance.PackageVersion));
            Func <Screenshot> actionToExecute = () =>
            {
                _packageAuthenticator.EnsureKeyCanAccessPackage(key, instance.PackageId, instance.PackageVersion);
                return(_screenshotRepository.Create(instance));
            };

            return(ExecuteAction(actionToExecute, "The Screenshot could not be created"));
        }