Пример #1
0
        public void ApplyProcessors_ListOfProcessors_AppliesAllProcessorsToOperation()
        {
            var operations = new FakeImageOperationsProvider.FakeImageOperations <Rgba32>(Configuration.Default, null, false);

            operations.ApplyProcessors(this.processorDefinition);
            Assert.Contains(this.processorDefinition, operations.Applied.Select(x => x.NonGenericProcessor));
        }
 public BaseImageOperationsExtensionTest()
 {
     this.options = new GraphicsOptions
     {
         AntialiasSubpixelDepth = 99,
         Antialias            = false,
         BlendPercentage      = 0.9f,
         AlphaCompositionMode = PixelAlphaCompositionMode.DestOut,
         ColorBlendingMode    = PixelColorBlendingMode.Multiply
     };
     this.textOptions = new TextOptions
     {
         TabWidth = 99
     };
     this.shapeOptions = new ShapeOptions {
         IntersectionRule = IntersectionRule.Nonzero
     };
     this.source             = new Image <Rgba32>(91 + 324, 123 + 56);
     this.rect               = new Rectangle(91, 123, 324, 56); // make this random?
     this.internalOperations = new FakeImageOperationsProvider.FakeImageOperations <Rgba32>(this.source.GetConfiguration(), this.source, false);
     this.internalOperations.SetShapeOptions(this.shapeOptions);
     this.internalOperations.SetTextOptions(this.textOptions);
     this.internalOperations.SetGraphicsOptions(this.options);
     this.operations = this.internalOperations;
 }
        public void GetDefaultOptionsFromProcessingContext_AlwaysReturnsInstance()
        {
            var config  = new Configuration();
            var context = new FakeImageOperationsProvider.FakeImageOperations <Rgba32>(config, null, true);

            ShapeOptions ctxOptions = context.GetShapeOptions();

            Assert.NotNull(ctxOptions);
        }
Пример #4
0
 public BaseImageOperationsExtensionTest()
 {
     this.options = new GraphicsOptions {
         Antialias = false
     };
     this.source             = new Image <Rgba32>(91 + 324, 123 + 56);
     this.rect               = new Rectangle(91, 123, 324, 56); // make this random?
     this.internalOperations = new FakeImageOperationsProvider.FakeImageOperations <Rgba32>(this.source.GetConfiguration(), this.source, false);
     this.operations         = this.internalOperations;
 }
        public void GetDefaultOptionsFromProcessingContext_IgnoreIncorectlyTypesDictionEntry()
        {
            var config  = new Configuration();
            var context = new FakeImageOperationsProvider.FakeImageOperations <Rgba32>(config, null, true);

            context.Properties[typeof(ShapeOptions)] = "wronge type";
            ShapeOptions options = context.GetShapeOptions();

            Assert.NotNull(options);
            Assert.IsType <ShapeOptions>(options);
        }
        public void GetDefaultOptionsFromProcessingContext_FallbackToConfigsInstance()
        {
            var option = new ShapeOptions();
            var config = new Configuration();

            config.SetShapeOptions(option);
            var context = new FakeImageOperationsProvider.FakeImageOperations <Rgba32>(config, null, true);

            ShapeOptions ctxOptions = context.GetShapeOptions();

            Assert.Equal(option, ctxOptions);
        }
        public void SetDefaultOptionsOnProcessingContext()
        {
            var option  = new ShapeOptions();
            var config  = new Configuration();
            var context = new FakeImageOperationsProvider.FakeImageOperations <Rgba32>(config, null, true);

            context.SetShapeOptions(option);

            // sets the prop on the processing context not on the configuration
            Assert.Equal(option, context.Properties[typeof(ShapeOptions)]);
            Assert.DoesNotContain(typeof(ShapeOptions), config.Properties.Keys);
        }
Пример #8
0
 public BaseImageOperationsExtensionTest()
 {
     this.options = new GraphicsOptions {
         Antialias = false
     };
     this.textOptions = new TextOptions
     {
         TabWidth = 99
     };
     this.shapeOptions = new ShapeOptions {
         IntersectionRule = IntersectionRule.Nonzero
     };
     this.source             = new Image <Rgba32>(91 + 324, 123 + 56);
     this.rect               = new Rectangle(91, 123, 324, 56); // make this random?
     this.internalOperations = new FakeImageOperationsProvider.FakeImageOperations <Rgba32>(this.source.GetConfiguration(), this.source, false);
     this.internalOperations.SetShapeOptions(this.shapeOptions);
     this.internalOperations.SetTextOptions(this.textOptions);
     this.internalOperations.SetGraphicsOptions(this.options);
     this.operations = this.internalOperations;
 }
        public void UpdateDefaultOptionsOnProcessingContext_AlwaysNewInstance()
        {
            var option = new ShapeOptions()
            {
                IntersectionRule = IntersectionRule.Nonzero
            };
            var config  = new Configuration();
            var context = new FakeImageOperationsProvider.FakeImageOperations <Rgba32>(config, null, true);

            context.SetShapeOptions(option);

            context.SetShapeOptions(o =>
            {
                Assert.Equal(IntersectionRule.Nonzero, o.IntersectionRule); // has origional values
                o.IntersectionRule = IntersectionRule.OddEven;
            });

            ShapeOptions returnedOption = context.GetShapeOptions();

            Assert.Equal(IntersectionRule.OddEven, returnedOption.IntersectionRule);
            Assert.Equal(IntersectionRule.Nonzero, option.IntersectionRule); // hasn't been mutated
        }
Пример #10
0
        public T Verify <T>(Rectangle rect, int index = 0)
        {
            Assert.InRange(index, 0, this.internalOperations.Applied.Count - 1);

            FakeImageOperationsProvider.FakeImageOperations <Rgba32> .AppliedOperation operation = this.internalOperations.Applied[index];

            Assert.Equal(rect, operation.Rectangle);

            if (operation.NonGenericProcessor != null)
            {
                return(Assert.IsType <T>(operation.NonGenericProcessor));
            }

            return(Assert.IsType <T>(operation.GenericProcessor));
        }