private void InitializeConfiguration() { var certificateStore = new CertificateStore(ModuleLogger(nameof(CertificateStore))); var compressor = new GZipCompressor(ModuleLogger(nameof(GZipCompressor))); var passwordEncryption = new PasswordEncryption(ModuleLogger(nameof(PasswordEncryption))); var publicKeyEncryption = new PublicKeyEncryption(certificateStore, ModuleLogger(nameof(PublicKeyEncryption))); var symmetricEncryption = new PublicKeySymmetricEncryption(certificateStore, ModuleLogger(nameof(PublicKeySymmetricEncryption)), passwordEncryption); var repositoryLogger = ModuleLogger(nameof(ConfigurationRepository)); var xmlParser = new XmlParser(compressor, ModuleLogger(nameof(XmlParser))); var xmlSerializer = new XmlSerializer(ModuleLogger(nameof(XmlSerializer))); configuration = new ConfigurationRepository(certificateStore, new HashAlgorithm(), repositoryLogger); appConfig = configuration.InitializeAppConfig(); configuration.Register(new BinaryParser( compressor, new HashAlgorithm(), ModuleLogger(nameof(BinaryParser)), passwordEncryption, publicKeyEncryption, symmetricEncryption, xmlParser)); configuration.Register(new BinarySerializer( compressor, ModuleLogger(nameof(BinarySerializer)), passwordEncryption, publicKeyEncryption, symmetricEncryption, xmlSerializer)); configuration.Register(new XmlParser(compressor, ModuleLogger(nameof(XmlParser)))); configuration.Register(new XmlSerializer(ModuleLogger(nameof(XmlSerializer)))); configuration.Register(new FileResourceLoader(ModuleLogger(nameof(FileResourceLoader)))); configuration.Register(new FileResourceSaver(ModuleLogger(nameof(FileResourceSaver)))); configuration.Register(new NetworkResourceLoader(appConfig, new ModuleLogger(logger, nameof(NetworkResourceLoader)))); }
public void Initialize() { logger = new Mock <ILogger>(); passwordEncryption = new PasswordEncryption(logger.Object); store = new Mock <ICertificateStore>(); LoadCertificate(); store.Setup(s => s.TryGetCertificateWith(It.IsAny <byte[]>(), out certificate)).Returns(true); sut = new PublicKeySymmetricEncryption(store.Object, logger.Object, passwordEncryption); }
private void InitializeConfiguration() { var executable = Assembly.GetExecutingAssembly(); var programBuild = FileVersionInfo.GetVersionInfo(executable.Location).FileVersion; var programCopyright = executable.GetCustomAttribute <AssemblyCopyrightAttribute>().Copyright; var programTitle = executable.GetCustomAttribute <AssemblyTitleAttribute>().Title; var programVersion = executable.GetCustomAttribute <AssemblyInformationalVersionAttribute>().InformationalVersion; var certificateStore = new CertificateStore(ModuleLogger(nameof(CertificateStore))); var compressor = new GZipCompressor(ModuleLogger(nameof(GZipCompressor))); var passwordEncryption = new PasswordEncryption(ModuleLogger(nameof(PasswordEncryption))); var publicKeyEncryption = new PublicKeyEncryption(certificateStore, ModuleLogger(nameof(PublicKeyEncryption))); var symmetricEncryption = new PublicKeySymmetricEncryption(certificateStore, ModuleLogger(nameof(PublicKeySymmetricEncryption)), passwordEncryption); var repositoryLogger = ModuleLogger(nameof(ConfigurationRepository)); var xmlParser = new XmlParser(ModuleLogger(nameof(XmlParser))); var xmlSerializer = new XmlSerializer(ModuleLogger(nameof(XmlSerializer))); configuration = new ConfigurationRepository( certificateStore, new HashAlgorithm(), repositoryLogger, executable.Location, programBuild, programCopyright, programTitle, programVersion); appConfig = configuration.InitializeAppConfig(); configuration.Register(new BinaryParser( compressor, new HashAlgorithm(), ModuleLogger(nameof(BinaryParser)), passwordEncryption, publicKeyEncryption, symmetricEncryption, xmlParser)); configuration.Register(new BinarySerializer( compressor, ModuleLogger(nameof(BinarySerializer)), passwordEncryption, publicKeyEncryption, symmetricEncryption, xmlSerializer)); configuration.Register(new XmlParser(ModuleLogger(nameof(XmlParser)))); configuration.Register(new XmlSerializer(ModuleLogger(nameof(XmlSerializer)))); configuration.Register(new FileResourceLoader(ModuleLogger(nameof(FileResourceLoader)))); configuration.Register(new FileResourceSaver(ModuleLogger(nameof(FileResourceSaver)))); configuration.Register(new NetworkResourceLoader(appConfig, new ModuleLogger(logger, nameof(NetworkResourceLoader)))); }