Exemplo n.º 1
0
        public void SetupTests()
        {
            license          = new ClientLicense();
            license.UniqueId = Guid.NewGuid();

            license.LicenseSets = new NotifyList <LicenseSet>();
            LicenseSet ls = new LicenseSet();

            ls.SupportedLicenseTypes = LicenseKeyTypeFlag.SingleUser;
            ls.Name      = "Standard License Set";
            ls.UniquePad = new Guid();
            license.LicenseSets.Add(ls);

            generationOptions = new LicenseGenerationOptions();

            license.Product           = new Product();
            license.Product.Name      = "My Great Uber Cool Product, with new juice!";
            license.Product.ProductId = 1;

            packingService          = new PackingService(numberDataGenerationProvider);
            clientLicenseRepository = new ClientLicenseRepository(objectSerializationProvider, symmetricEncryptionProvider);
            clientLicenseService    = new ClientLicenseService(clientLicenseRepository);

            string productHash = hashingProvider.Checksum32(license.GetLicenseProductIdentifier()).ToString("X");

            LicenseActiviationProvider licenseActiviationProvider = new LicenseActiviationProvider(asymmetricEncryptionProvider, symmetricEncryptionProvider, objectSerializationProvider);

            staticKeyGenerator      = new KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider);
            staticKeyGeneratorLarge = new Scutex.Generators.StaticKeyGeneratorLarge.KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider, hardwareFingerprintService);
            licenseKeyService       = new LicenseKeyService(staticKeyGenerator, staticKeyGeneratorLarge, packingService, clientLicenseService);
        }
            public void Before_each_test()
            {
                clientLicenseRepoistory = new ClientLicenseRepository(objectSerializationProvider, symmetricEncryptionProvider);
                clientLicenseService = new ClientLicenseService(clientLicenseRepoistory);
                serviceProductsRepository = new ServiceProductsRepository(new ScutexServiceEntities());
                symmetricEncryptionProvider = new SymmetricEncryptionProvider();
                asymmetricEncryptionProvider = new AsymmetricEncryptionProvider();
                hashingProvider = new HashingProvider();
                objectSerializationProvider = new ObjectSerializationProvider();
                numberDataGenerator = new NumberDataGenerator();
                packingService = new PackingService(numberDataGenerator);
                commonRepository = new CommonRepository(new ScutexServiceEntities());
                clientRepository = new ClientRepository(new ScutexServiceEntities());
                keyGenerator = new KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider);
                masterService = new MasterService(commonRepository);
                activationLogRepository = new ActivationLogRepoistory(new ScutexServiceEntities());

                activationLogService = new ActivationLogService(activationLogRepository, hashingProvider);
                keyService = new KeyManagementService(clientRepository, licenseKeyService, activationLogService, hashingProvider, serviceProductsRepository);
                commonService = new CommonService();

                string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
                path = path.Replace("file:\\", "");

                var mockCommonService = new Mock<ICommonService>();
                mockCommonService.Setup(common => common.GetPath()).Returns(path + "\\Data\\Client\\");

                string masterServiceDataText;

                using (TextReader reader = new StreamReader(path + "\\Data\\MasterService.dat"))
                {
                    masterServiceDataText = reader.ReadToEnd().Trim();
                }

                masterServiceData = objectSerializationProvider.Deserialize<MasterServiceData>(masterServiceDataText);

                var mockCommonRepository = new Mock<ICommonRepository>();
                mockCommonRepository.Setup(repo => repo.GetMasterServiceData()).Returns(masterServiceData);

                keyPairService = new KeyPairService(mockCommonService.Object, mockCommonRepository.Object);
                controlService = new ControlService(symmetricEncryptionProvider, keyPairService, packingService, masterService, objectSerializationProvider, asymmetricEncryptionProvider);
                servicesRepository = new ServicesRepository(new ScutexEntities());
                serviceStatusProvider = new ServiceStatusProvider(symmetricEncryptionProvider, objectSerializationProvider, asymmetricEncryptionProvider);
                licenseActiviationProvider = new LicenseActiviationProvider(asymmetricEncryptionProvider, symmetricEncryptionProvider, objectSerializationProvider);
                servicesService = new ServicesService(servicesRepository, serviceStatusProvider, packingService, licenseActiviationProvider, null, null, null, null, null);
                licenseKeyService = new LicenseKeyService(keyGenerator, packingService, clientLicenseService);
                activationService = new ActivationService(controlService, keyService, keyPairService, objectSerializationProvider, asymmetricEncryptionProvider, null, null);

                string serviceData;

                using (TextReader reader = new StreamReader(path + "\\Data\\Service.dat"))
                {
                    serviceData = reader.ReadToEnd().Trim();
                }

                service = objectSerializationProvider.Deserialize<Service>(serviceData);
            }
            public void Before_each_test()
            {
                clientLicenseRepoistory      = new ClientLicenseRepository(objectSerializationProvider, symmetricEncryptionProvider);
                clientLicenseService         = new ClientLicenseService(clientLicenseRepoistory);
                serviceProductsRepository    = new ServiceProductsRepository(new ScutexServiceEntities());
                symmetricEncryptionProvider  = new SymmetricEncryptionProvider();
                asymmetricEncryptionProvider = new AsymmetricEncryptionProvider();
                hashingProvider             = new HashingProvider();
                objectSerializationProvider = new ObjectSerializationProvider();
                numberDataGenerator         = new NumberDataGenerator();
                packingService             = new PackingService(numberDataGenerator);
                commonRepository           = new CommonRepository(new ScutexServiceEntities());
                clientRepository           = new ClientRepository(new ScutexServiceEntities());
                keyGenerator               = new KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider);
                masterService              = new MasterService(commonRepository);
                hardwareFingerprintService = new HardwareFingerprintService(new WmiDataProvider(), new HashingProvider());
                keyGeneratorLarge          = new Scutex.Generators.StaticKeyGeneratorLarge.KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider, hardwareFingerprintService);

                var mockActivationLogRepository = new Mock <IActivationLogRepoistory>();

                mockActivationLogRepository.Setup(log => log.SaveActivationLog(It.IsAny <Scutex.Model.ActivationLog>()));

                activationLogService = new ActivationLogService(mockActivationLogRepository.Object, hashingProvider);
                commonService        = new CommonService();

                string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);

                path = path.Replace("file:\\", "");

                var mockCommonService = new Mock <ICommonService>();

                mockCommonService.Setup(common => common.GetPath()).Returns(path + "\\Data\\Client\\");

                string masterServiceDataText;

                using (TextReader reader = new StreamReader(path + "\\Data\\MasterService.dat"))
                {
                    masterServiceDataText = reader.ReadToEnd().Trim();
                }

                masterServiceData = objectSerializationProvider.Deserialize <MasterServiceData>(masterServiceDataText);

                var mockCommonRepository = new Mock <ICommonRepository>();

                mockCommonRepository.Setup(repo => repo.GetMasterServiceData()).Returns(masterServiceData);

                masterService = new MasterService(mockCommonRepository.Object);

                keyPairService             = new KeyPairService(mockCommonService.Object, mockCommonRepository.Object);
                controlService             = new ControlService(symmetricEncryptionProvider, keyPairService, packingService, masterService, objectSerializationProvider, asymmetricEncryptionProvider);
                servicesRepository         = new ServicesRepository(new ScutexEntities());
                serviceStatusProvider      = new ServiceStatusProvider(symmetricEncryptionProvider, objectSerializationProvider, asymmetricEncryptionProvider);
                licenseActiviationProvider = new LicenseActiviationProvider(asymmetricEncryptionProvider, symmetricEncryptionProvider, objectSerializationProvider);
                servicesService            = new ServicesService(servicesRepository, serviceStatusProvider, packingService, licenseActiviationProvider, null, null, null, null, null);
                licenseKeyService          = new LicenseKeyService(keyGenerator, keyGeneratorLarge, packingService, clientLicenseService);
                keyService        = new KeyManagementService(clientRepository, licenseKeyService, activationLogService, hashingProvider, serviceProductsRepository);
                activationService = new ActivationService(controlService, keyService, keyPairService, objectSerializationProvider, asymmetricEncryptionProvider, activationLogService, masterService, commonService, null);

                string serviceData;

                using (TextReader reader = new StreamReader(path + "\\Data\\Service.dat"))
                {
                    serviceData = reader.ReadToEnd().Trim();
                }

                service = objectSerializationProvider.Deserialize <Service>(serviceData);
            }
Exemplo n.º 4
0
        public void SetupTests()
        {
            license = new ClientLicense();
            license.UniqueId = Guid.NewGuid();

            license.LicenseSets = new NotifyList<LicenseSet>();
            LicenseSet ls = new LicenseSet();
            ls.SupportedLicenseTypes = LicenseKeyTypeFlag.SingleUser;
            ls.Name = "Standard License Set";
            ls.UniquePad = new Guid();
            license.LicenseSets.Add(ls);

            generationOptions = new LicenseGenerationOptions();

            license.Product = new Product();
            license.Product.Name = "My Great Uber Cool Product, with new juice!";
            license.Product.ProductId = 1;

            packingService = new PackingService(numberDataGenerationProvider);
            clientLicenseRepository = new ClientLicenseRepository(objectSerializationProvider, symmetricEncryptionProvider);
            clientLicenseService = new ClientLicenseService(clientLicenseRepository);

            string productHash = hashingProvider.Checksum32(license.GetLicenseProductIdentifier()).ToString("X");

            LicenseActiviationProvider licenseActiviationProvider = new LicenseActiviationProvider(asymmetricEncryptionProvider, symmetricEncryptionProvider, objectSerializationProvider);

            staticKeyGenerator = new KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider);
            licenseKeyService = new LicenseKeyService(staticKeyGenerator, packingService, clientLicenseService);
        }
Exemplo n.º 5
0
		public ClientLicenseService(IClientLicenseRepository clientLicenseRepository)
		{
			_clientLicenseRepository = clientLicenseRepository;
		}
Exemplo n.º 6
0
 public ClientLicenseService(IClientLicenseRepository clientLicenseRepository)
 {
     _clientLicenseRepository = clientLicenseRepository;
 }