Example #1
0
        public void OnCondition(GatewayElement config, GatewayCapabilities capability, Action action)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            var capabilityExcluded = config.Exclusions.HasFlag(capability);

            try {
                action();

                Assert.IsFalse(capabilityExcluded, $"Unexpected capability {capability}".ToString(CultureInfo.CurrentCulture));
            } catch (NotSupportedException) when(capabilityExcluded)
            {
                // Ignore NotSupportedException
            } catch (AggregateException ex) when(capabilityExcluded && ex.InnerExceptions.Count == 1 && ex.InnerException is NotSupportedException)
            {
                // Ignore AggregateException containing a single NotSupportedException
            }
        }
Example #2
0
        protected override void SetElement(VisualElement element)
        {
            GatewayElement gateway = element as GatewayElement;

            _gatewayElement = gateway;
            base.SetElement(element);
        }
Example #3
0
        public RootName GetRootName(GatewayElement config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            return(new RootName(config.Schema, config.UserName, config.Mount));
        }
Example #4
0
        protected override IBaseElement CreateElement(object xpdlItem)
        {
            Route          route   = GetXpdlType <Route>(xpdlItem);
            GatewayElement element = new GatewayElement();

            if (route.GatewayType == RouteGatewayType.XOR)
            {
                element.Type = GatewayType.Xor;
            }
            else if (route.GatewayType == RouteGatewayType.OR)
            {
                element.Type = GatewayType.Or;
            }
            else if (route.ExclusiveType == RouteExclusiveType.Event)
            {
                element.Type = GatewayType.EventBased;
            }
            return(element);
        }
Example #5
0
        public override void ProcessActivity(Activity activity, IBaseElement baseElement)
        {
            GatewayElement element = GetType <GatewayElement>(baseElement);
            Route          route   = new Route();

            switch (element.Type)
            {
            case GatewayType.Xor:
                route.GatewayType = RouteGatewayType.XOR;
                break;

            case GatewayType.Or:
                route.GatewayType = RouteGatewayType.OR;
                break;

            case GatewayType.EventBased:
                route.ExclusiveType = RouteExclusiveType.Event;
                break;
            }
            activity.Item = route;
        }
Example #6
0
        public IDictionary <string, string> GetParameters(GatewayElement config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            var parameters = config.Parameters;

            if (string.IsNullOrEmpty(parameters))
            {
                return(null);
            }

            var result = new Dictionary <string, string>();

            foreach (var parameter in parameters.Split('|'))
            {
                var components = parameter.Split(new[] { '=' }, 2);
                result.Add(components[0], components.Length == 2 ? components[1] : null);
            }

            return(result);
        }
 internal static TestDirectoryFixture CreateTestDirectory(ICloudGateway gateway, GatewayElement config, GatewayTestsFixture fixture)
 {
     return(new TestDirectoryFixture(gateway, fixture.GetRootName(config), config.ApiKey, fixture.GetParameters(config), config.TestDirectory));
 }
Example #8
0
 protected override VisualElement CreateElement()
 {
     _gatewayElement = new GatewayElement();
     return(_gatewayElement);
 }
Example #9
0
 public ICloudGateway GetGateway(GatewayElement config)
 {
     return(Gateways.Single(g => g.Metadata.CloudService == config.Schema).CreateExport().Value);
 }
Example #10
0
        private void CallTimedTestOnConfig <TGateway>(Action <TGateway, RootName, GatewayElement> test, GatewayElement config, Func <GatewayElement, TGateway> getGateway, IDictionary <string, Exception> failures)
        {
            try {
                var startedAt = DateTime.Now;
                var gateway   = getGateway(config);
                var rootName  = GetRootName(config);
                test(gateway, rootName, config);
                var completedAt = DateTime.Now;
                Log($"Test for schema '{config.Schema}' completed in {completedAt - startedAt}".ToString(CultureInfo.CurrentCulture));
            } catch (Exception ex) {
                var aggregateException = ex as AggregateException;
                var message            = aggregateException != null?string.Join(", ", aggregateException.InnerExceptions.Select(e => e.Message)) : ex.Message;

                Log($"Test for schema '{config.Schema}' failed:\n\t {message}".ToString(CultureInfo.CurrentCulture));
                failures.Add(config.Schema, ex);
            }
        }