public void Constructor_Cache_Null() { var distributedCache = DistributedCacheFactory.Create(); IAddressRegistry addressRegistry = new AddressRegistryMock(new AddressRegistrySettings(), distributedCache); new CollaborationProtocolRegistry(new CollaborationProtocolRegistrySettings(), null, addressRegistry); }
public void Setup() { _loggerFactory = new LoggerFactory(); _loggerFactory.AddDebug(); _logger = _loggerFactory.CreateLogger <AddressRegistryTests>(); _registry = GetDefaultAddressRegistryMock(); }
public void Constructor_Cache_Null() { var memoryCache = new MemoryCache(new MemoryCacheOptions()); var distributedCache = new MemoryDistributedCache(memoryCache); IAddressRegistry addressRegistry = new AddressRegistryMock(new AddressRegistrySettings(), distributedCache); new CollaborationProtocolRegistry(new CollaborationProtocolRegistrySettings(), null, addressRegistry); }
public void Setup() { var serviceCollection = new ServiceCollection(); serviceCollection.AddLogging(loggingBuilder => loggingBuilder.AddDebug()); var provider = serviceCollection.BuildServiceProvider(); _loggerFactory = provider.GetRequiredService <ILoggerFactory>(); _logger = _loggerFactory.CreateLogger <AddressRegistryTests>(); _registry = GetDefaultAddressRegistryMock(); }
internal static AddressRegistryMock GetDefaultAddressRegistryMock() { var settings = new AddressRegistrySettings() { UserName = "******", Password = "******", EndpointName = "BasicHttpBinding_ICommunicationPartyService", WcfConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None), CachingInterval = TimeSpan.FromSeconds(5) }; var memoryCache = new MemoryCache(new MemoryCacheOptions()); var distributedCache = new MemoryDistributedCache(memoryCache); var registry = new AddressRegistryMock(settings, distributedCache); registry.SetupFindCommunicationPartyDetails(i => { if (i < 0) { throw new FaultException(new FaultReason("Her-ID expected to an integer of positive value.")); } var file = Path.Combine("Files", $"CommunicationDetails_{i}.xml"); return(File.Exists(file) == false ? null : XElement.Load(file)); }); registry.SetupGetCertificateDetailsForEncryption(i => { if (i < 0) { throw new FaultException(new FaultReason("Her-ID expected to an integer of positive value.")); } var file = Path.Combine("Files", $"GetCertificateDetailsForEncryption_{i}.xml"); return(File.Exists(file) == false ? null : XElement.Load(file)); }); registry.SetupGetCertificateDetailsForValidatingSignature(i => { if (i < 0) { throw new FaultException(new FaultReason("Her-ID expected to an integer of positive value.")); } var file = Path.Combine("Files", $"GetCertificateDetailsForValidatingSignature_{i}.xml"); return(File.Exists(file) == false ? null : XElement.Load(file)); }); return(registry); }
internal void SetupInternal(int otherHerId) { var addressRegistrySettings = new AddressRegistrySettings() { UserName = "******", Password = "******", EndpointName = "SomeEndpointName", WcfConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None), CachingInterval = TimeSpan.FromSeconds(5) }; var collaborationRegistrySettings = new CollaborationProtocolRegistrySettings() { UserName = "******", Password = "******", EndpointName = "SomeEndpointName", WcfConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None), CachingInterval = TimeSpan.FromSeconds(5) }; LoggerFactory = new LoggerFactory(); MockLoggerProvider = new MockLoggerProvider(null); LoggerFactory.AddProvider(MockLoggerProvider); //LoggerFactory.AddDebug(); //Logger = new LoggerMock(LoggerFactory.CreateLogger<BaseTest>()); Logger = LoggerFactory.CreateLogger <BaseTest>(); var memoryCache = new MemoryCache(new MemoryCacheOptions()); var distributedCache = new MemoryDistributedCache(memoryCache); AddressRegistry = new AddressRegistryMock(addressRegistrySettings, distributedCache); AddressRegistry.SetupFindCommunicationPartyDetails(i => { var file = Path.Combine("Files", $"CommunicationDetails_{i}.xml"); return(File.Exists(file) == false ? null : XElement.Load(file)); }); AddressRegistry.SetupGetCertificateDetailsForEncryption(i => { var path = Path.Combine("Files", $"GetCertificateDetailsForEncryption_{i}.xml"); return(File.Exists(path) == false ? null : XElement.Load(path)); }); AddressRegistry.SetupGetCertificateDetailsForValidatingSignature(i => { var path = Path.Combine("Files", $"GetCertificateDetailsForValidatingSignature_{i}.xml"); return(File.Exists(path) == false ? null : XElement.Load(path)); }); CollaborationRegistry = new CollaborationProtocolRegistryMock(collaborationRegistrySettings, distributedCache, AddressRegistry); CollaborationRegistry.SetupFindProtocolForCounterparty(i => { var file = Path.Combine("Files", $"CPP_{i}.xml"); return(File.Exists(file) == false ? null : File.ReadAllText(file)); }); CollaborationRegistry.SetupFindAgreementForCounterparty(i => { var file = Path.Combine("Files", $"CPA_{i}.xml"); return(File.Exists(file) == false ? null : File.ReadAllText(file)); }); CollaborationRegistry.SetupFindAgreementById(i => { var file = Path.Combine("Files", $"CPA_{i:D}.xml"); return(File.Exists(file) == false ? null : File.ReadAllText(file)); }); Settings = new MessagingSettings() { MyHerId = MockFactory.HelsenorgeHerId, SigningCertificate = new CertificateSettings() { Certificate = TestCertificates.HelsenorgePrivateSigntature }, DecryptionCertificate = new CertificateSettings() { Certificate = TestCertificates.HelsenorgePrivateEncryption } }; Settings.ServiceBus.ConnectionString = "connection string"; Settings.ServiceBus.Synchronous.ReplyQueueMapping.Add(Environment.MachineName.ToLower(), "RepliesGoHere"); // make things easier by only having one processing task per queue Settings.ServiceBus.Asynchronous.ProcessingTasks = 1; Settings.ServiceBus.Synchronous.ProcessingTasks = 1; Settings.ServiceBus.Error.ProcessingTasks = 1; MockFactory = new MockFactory(otherHerId); CertificateValidator = new MockCertificateValidator(); Client = new MessagingClient(Settings, CollaborationRegistry, AddressRegistry) { DefaultMessageProtection = new NoMessageProtection(), // disable protection for most tests DefaultCertificateValidator = CertificateValidator }; Client.ServiceBus.RegisterAlternateMessagingFactory(MockFactory); Server = new MessagingServer(Settings, Logger, LoggerFactory, CollaborationRegistry, AddressRegistry) { DefaultMessageProtection = new NoMessageProtection(), // disable protection for most tests DefaultCertificateValidator = CertificateValidator }; Server.ServiceBus.RegisterAlternateMessagingFactory(MockFactory); }