Ejemplo n.º 1
0
        public void CanGetXIRImageFromFile(string imageName, ImageFormat expectedFormat, int width, int height)
        {
            var sdBitmap    = new Bitmap(ResourcesRootPath.Combine(imageName));
            var repProvider = new ReflectionRepresentationProvider();

            var reps = repProvider.ProvideRepresentations(sdBitmap);

            reps.Count().ShouldEqual(1);

            var firstRep = reps.First();

            var xirImage = firstRep.ShouldBeType <Representations.Image> ();

            xirImage.Format.ShouldEqual(expectedFormat);
            xirImage.Width.ShouldEqual(width);
            xirImage.Height.ShouldEqual(height);
        }
Ejemplo n.º 2
0
        public void CanGetXIRImageFromStream(string imageName, ImageFormat expectedFormat, int width, int height)
        {
            var image       = TestHelpers.GetResource <ReflectionRepresentationProviderTests> (prefix + imageName);
            var sdBitmap    = new Bitmap(image);
            var repProvider = new ReflectionRepresentationProvider();

            var reps = repProvider.ProvideRepresentations(sdBitmap);

            reps.Count().ShouldEqual(1);

            var firstRep = reps.First();

            var xirImage = firstRep.ShouldBeType <Representations.Image> ();

            xirImage.Format.ShouldEqual(expectedFormat);
            xirImage.Width.ShouldEqual(width);
            xirImage.Height.ShouldEqual(height);
        }
Ejemplo n.º 3
0
        public IAgentIntegration CheckLoadedAssemblyForAgentIntegration(Assembly assembly)
        {
            if (assembly?.GetReferencedAssemblies().Any(r => r.Name == "Xamarin.Interactive") == false)
            {
                return(null);
            }

            var integrationType = assembly
                                  .GetCustomAttribute <AgentIntegrationAttribute> ()
                                  ?.AgentIntegrationType;

            if (integrationType == null)
            {
                return(null);
            }

            if (!typeof(IAgentIntegration).IsAssignableFrom(integrationType))
            {
                throw new InvalidOperationException(
                          $"encountered [assembly:{typeof (AgentIntegrationAttribute).FullName}" +
                          $"({integrationType.FullName})] on assembly '{assembly.FullName}', " +
                          $"but type specified does not implement " +
                          $"{typeof (IAgentIntegration).FullName}");
            }

            var integration = (IAgentIntegration)Activator.CreateInstance(integrationType);

            integration.IntegrateWith(agent);

            if (integration is IEvaluationContextIntegration evalContextIntegration)
            {
                evalContextIntegration.IntegrateWith(this);
            }

            ReflectionRepresentationProvider.AgentHasIntegratedWith(integration);

            return(integration);
        }