public void Constructor_Cache_Null()
        {
            var distributedCache             = DistributedCacheFactory.Create();
            IAddressRegistry addressRegistry = new AddressRegistryMock(new AddressRegistrySettings(), distributedCache);

            new CollaborationProtocolRegistry(new CollaborationProtocolRegistrySettings(), null, addressRegistry);
        }
Ejemplo n.º 2
0
        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 = DistributedCacheFactory.Create();

            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);
        }
Ejemplo n.º 3
0
        public void Setup()
        {
            var settings = new CollaborationProtocolRegistrySettings()
            {
                UserName         = "******",
                Password         = "******",
                EndpointName     = "BasicHttpBinding_ICommunicationPartyService",
                WcfConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None),
                CachingInterval  = TimeSpan.FromSeconds(5),
                MyHerId          = 93238 // matches a value in a CPA test file
            };

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging(loggingBuilder => loggingBuilder.AddDebug());
            var provider = serviceCollection.BuildServiceProvider();

            _loggerFactory = provider.GetRequiredService <ILoggerFactory>();
            _logger        = _loggerFactory.CreateLogger <CollaborationRegistryTests>();

            var distributedCache = DistributedCacheFactory.Create();

            IAddressRegistry addressRegistry = AddressRegistryTests.GetDefaultAddressRegistryMock();

            _registry = new CollaborationProtocolRegistryMock(settings, distributedCache, addressRegistry);
            _registry.SetupFindAgreementById(i =>
            {
                var file = Path.Combine("Files", $"CPA_{i:D}.xml");
                return(File.Exists(file) == false ? null : File.ReadAllText(file));
            });
            _registry.SetupFindAgreementForCounterparty(i =>
            {
                var file = Path.Combine("Files", $"CPA_{i}.xml");
                return(File.Exists(file) == false ? null : File.ReadAllText(file));
            });
            _registry.SetupFindProtocolForCounterparty(i =>
            {
                if (i < 0)
                {
                    throw new FaultException(new FaultReason("Dummy fault from mock"));
                }
                var file = Path.Combine("Files", $"CPP_{i}.xml");
                return(File.Exists(file) == false ? null : File.ReadAllText(file));
            });
        }
        public void Constructor_AddressRegistry_Null()
        {
            var distributedCache = DistributedCacheFactory.Create();

            new CollaborationProtocolRegistry(new CollaborationProtocolRegistrySettings(), distributedCache, null);
        }
Ejemplo n.º 5
0
        public void Constructor_Settings_Null()
        {
            var distributedCache = DistributedCacheFactory.Create();

            new AddressRegistry(null, distributedCache);
        }