Esempio n. 1
0
        public bool TestService(Service service)
        {
            string clientToken = _packingService.PackToken(service.GetClientToken());
            string mgmtToken = _packingService.PackToken(service.GetManagementToken());

            LicenseActivationPayload payload = new LicenseActivationPayload();
            payload.ServiceLicense = new ServiceLicense(CreateTestClientLicense(service));

            LicenseGenerationOptions options = new LicenseGenerationOptions();
            options.LicenseKeyType = LicenseKeyTypes.MultiUser;

            payload.LicenseKey = _licenseKeyService.GenerateLicenseKey(null, payload.ServiceLicense, options);

            SetupTestProductResult result = _serviceStatusProvider.SetupTestProduct(service.ManagementUrl, mgmtToken, payload.LicenseKey, GetManagementStandardEncryptionInfo(service));

            if (result.WasRequestValid == false)
                return false;

            if (result.WasOperationSuccessful == false)
                return false;

            ActivationResult activationResult1 = _licenseActiviationProvider.ActivateLicense(service.ClientUrl, clientToken, GetClientStandardEncryptionInfo(service),
                payload, CreateTestClientLicense(service));

            ActivationResult activationResult2 = _licenseActiviationProvider.ActivateLicense(service.ClientUrl, clientToken, GetClientStandardEncryptionInfo(service),
                payload, CreateTestClientLicense(service));

            ActivationResult activationResult3 = _licenseActiviationProvider.ActivateLicense(service.ClientUrl, clientToken, GetClientStandardEncryptionInfo(service),
                payload, CreateTestClientLicense(service));

            if (activationResult1.WasRequestValid == false || activationResult1.ActivationSuccessful == false)
                return false;

            if (activationResult2.WasRequestValid == false || activationResult2.ActivationSuccessful == false)
                return false;

            if (activationResult3.WasRequestValid == false || activationResult3.ActivationSuccessful == true)
                return false;

            SetupTestProductResult cleanUpResult = _serviceStatusProvider.CleanUpTestProductData(service.ManagementUrl, mgmtToken,
                                                                                                                                                                                     GetManagementStandardEncryptionInfo
                                                                                                                                                                                        (service));

            if (cleanUpResult.WasOperationSuccessful == false)
                return false;

            return true;
        }