Пример #1
0
        public void TestCommandQueueKeyNoId()
        {
            var cmd = new TallyChannelConfigCommand()
            {
                InputCount = 0,
            };

            var key = new CommandQueueKey(cmd);

            Assert.Equal(0, key.Id);
        }
Пример #2
0
        public void TestCommandQueueKeyWithMask()
        {
            var cmd = new ColorGeneratorSetCommand()
            {
                Mask  = ColorGeneratorSetCommand.MaskFlags.Hue,
                Index = ColorGeneratorId.Two,
                Hue   = 5,
            };

            var key = new CommandQueueKey(cmd);

            Assert.NotEqual(0, key.Mask);
        }
Пример #3
0
        public void TestCommandQueueKeyId()
        {
            var cmd = new ColorGeneratorGetCommand()
            {
                Index = ColorGeneratorId.Two,
                Hue   = 5,
            };

            var key = new CommandQueueKey(cmd);

            Assert.NotEqual(0, key.Id);
            Assert.Equal(0, key.Mask);
        }
Пример #4
0
        public static Func <Lazy <ImmutableList <ICommand> >, ICommand, IEnumerable <ICommand> > CreateAutoCommandHandler <TSet, TGet>(string[] names, bool disableMask = false) where TGet : ICommand where TSet : ICommand
        {
            object expectedMask = null;

            if (!disableMask)
            {
                // Calculate what the mask should ssbe
                PropertyInfo maskProp = typeof(TSet).GetProperty("Mask");
                Assert.NotNull(maskProp);
                expectedMask = Enum.Parse(maskProp.PropertyType, string.Join(",", names));
                Assert.NotEqual(0, (int)expectedMask);
            }

            return((previousCommands, cmd) =>
            {
                if (cmd is TSet setCmd)
                {
                    // Ensure the mask is correct
                    dynamic dynCmd = setCmd;
                    if (!disableMask)
                    {
                        Assert.Equal(expectedMask, dynCmd.Mask);
                    }

                    // Find the command to base the result on
                    CommandQueueKey targetCommandKey = CommandQueueKey.ForGetter <TGet>(setCmd);
                    TGet previousCmd = previousCommands.Value.OfType <TGet>().LastOrDefault(c => targetCommandKey.Equals(new CommandQueueKey(c)));
                    Assert.NotNull(previousCmd);

                    // Now copy the value across
                    foreach (string name in names)
                    {
                        PropertyInfo previousProp = typeof(TGet).GetProperty(name);
                        Assert.NotNull(previousProp);
                        PropertyInfo setProp = typeof(TSet).GetProperty(name);
                        Assert.NotNull(setProp);
                        previousProp.SetValue(previousCmd, setProp.GetValue(setCmd));
                    }

                    return new ICommand[] { previousCmd };
                }

                return new ICommand[0];
            });
        }
Пример #5
0
        private static IEnumerable <ICommand> SampledColorHandler(Lazy <ImmutableList <ICommand> > previousCommands, ICommand cmd)
        {
            if (cmd is MixEffectKeyAdvancedChromaSampleSetCommand sampleCmd)
            {
                var expectedMask = MixEffectKeyAdvancedChromaSampleSetCommand.MaskFlags.SampledY |
                                   MixEffectKeyAdvancedChromaSampleSetCommand.MaskFlags.SampledCb |
                                   MixEffectKeyAdvancedChromaSampleSetCommand.MaskFlags.SampledCr;
                Assert.Equal(expectedMask, sampleCmd.Mask);

                var setKey      = CommandQueueKey.ForGetter <MixEffectKeyAdvancedChromaSampleGetCommand>(sampleCmd);
                var previousCmd = previousCommands.Value.OfType <MixEffectKeyAdvancedChromaSampleGetCommand>()
                                  .Last(c => setKey.Equals(new CommandQueueKey(c)));
                Assert.NotNull(previousCmd);

                previousCmd.SampledY  = sampleCmd.SampledY;
                previousCmd.SampledCb = sampleCmd.SampledCb;
                previousCmd.SampledCr = sampleCmd.SampledCr;
                yield return(previousCmd);
            }
        }