public void ApplyProcessors_ListOfProcessors_AppliesAllProcessorsToOperation()
        {
            var operations = new FakeImageOperationsProvider.FakeImageOperations <Rgba32>(null, false);

            operations.ApplyProcessors(this.processor);
            Assert.Contains(this.processor, operations.Applied.Select(x => x.GenericProcessor));
        }
Exemple #2
0
 public BaseImageOperationsExtensionTest()
 {
     this.options            = new GraphicsOptions(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, false);
     this.operations         = this.internalOperations;
 }
Exemple #3
0
        public void GetDefaultOptionsFromProcessingContext_AlwaysReturnsInstance()
        {
            var config  = new Configuration();
            var context = new FakeImageOperationsProvider.FakeImageOperations <Rgba32>(config, null, true);

            var ctxOptions = context.GetGraphicsOptions();

            Assert.NotNull(ctxOptions);
        }
Exemple #4
0
        public void GetDefaultOptionsFromProcessingContext_IgnoreIncorectlyTypesDictionEntry()
        {
            var config  = new Configuration();
            var context = new FakeImageOperationsProvider.FakeImageOperations <Rgba32>(config, null, true);

            context.Properties[typeof(GraphicsOptions)] = "wronge type";
            var options = context.GetGraphicsOptions();

            Assert.NotNull(options);
            Assert.IsType <GraphicsOptions>(options);
        }
Exemple #5
0
        public void GetDefaultOptionsFromProcessingContext_FallbackToConfigsInstance()
        {
            var option = new GraphicsOptions();
            var config = new Configuration();

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

            var ctxOptions = context.GetGraphicsOptions();

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

            context.SetGraphicsOptions(option);

            // sets the prop on the processing context not on the configuration
            Assert.Equal(option, context.Properties[typeof(GraphicsOptions)]);
            Assert.DoesNotContain(typeof(GraphicsOptions), config.Properties.Keys);
        }
Exemple #7
0
        public void UpdateDefaultOptionsOnProcessingContext_AlwaysNewInstance()
        {
            var option = new GraphicsOptions()
            {
                BlendPercentage = 0.9f
            };
            var config  = new Configuration();
            var context = new FakeImageOperationsProvider.FakeImageOperations <Rgba32>(config, null, true);

            context.SetGraphicsOptions(option);

            context.SetGraphicsOptions(o =>
            {
                Assert.Equal(0.9f, o.BlendPercentage); // has origional values
                o.BlendPercentage = 0.4f;
            });

            var returnedOption = context.GetGraphicsOptions();

            Assert.Equal(0.4f, returnedOption.BlendPercentage);
            Assert.Equal(0.9f, option.BlendPercentage); // hasn't been mutated
        }
Exemple #8
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);
            return(Assert.IsType <T>(operation.Processor));
        }
        public T Verify <T>(int index = 0)
        {
            Assert.InRange(index, 0, this.internalOperations.Applied.Count - 1);

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

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

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