示例#1
0
        public void TestRunToKeyFrame()
        {
            bool tested         = false;
            var  expectedCmd    = new MixEffectKeyFlyRunSetCommand();
            bool ignoreInfinite = false;
            Func <Lazy <ImmutableList <ICommand> >, ICommand, IEnumerable <ICommand> > handler = (previousCommands, cmd) =>
            {
                string[] ignoreProps = ignoreInfinite ? new[] { "RunToInfinite" } : new string[] { };
                if (CommandGenerator.ValidateCommandMatches(cmd, expectedCmd, false, ignoreProps))
                {
                    // Accept it
                    return(new ICommand[] { null });
                }

                return(new ICommand[0]);
            };

            AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper =>
            {
                SelectionOfKeyers <IBMDSwitcherKeyFlyParameters>(helper, (stateBefore, keyerBefore, sdkKeyer, meId, keyId, i) =>
                {
                    tested = true;

                    expectedCmd.MixEffectIndex = meId;
                    expectedCmd.KeyerIndex     = keyId;

                    for (int o = 0; o < 5; o++)
                    {
                        var targetFrame = Randomiser.RangeInt(2) > 0
                            ? FlyKeyKeyFrameType.RunToInfinite
                            : Randomiser.EnumValue <FlyKeyKeyFrameType>(FlyKeyKeyFrameType.None);
                        var targetInfinite = Randomiser.EnumValue <FlyKeyLocation>();

                        ignoreInfinite = targetFrame != FlyKeyKeyFrameType.RunToInfinite;

                        expectedCmd.KeyFrame      = targetFrame;
                        expectedCmd.RunToInfinite = targetInfinite;

                        /*expectedCmd.Mask = targetFrame == FlyKeyKeyFrameType.RunToInfinite
                         *  ? MixEffectKeyFlyRunSetCommand.MaskFlags.RunToInfinite |
                         *    MixEffectKeyFlyRunSetCommand.MaskFlags.KeyFrame
                         *  : MixEffectKeyFlyRunSetCommand.MaskFlags.KeyFrame;*/

                        helper.SendAndWaitForChange(stateBefore, () =>
                        {
                            _BMDSwitcherFlyKeyFrame destination;
                            switch (targetFrame)
                            {
                            case FlyKeyKeyFrameType.None:
                            case FlyKeyKeyFrameType.A:
                                destination = _BMDSwitcherFlyKeyFrame.bmdSwitcherFlyKeyFrameA;
                                break;

                            case FlyKeyKeyFrameType.B:
                                destination = _BMDSwitcherFlyKeyFrame.bmdSwitcherFlyKeyFrameB;
                                break;

                            case FlyKeyKeyFrameType.Full:
                                destination = _BMDSwitcherFlyKeyFrame.bmdSwitcherFlyKeyFrameFull;
                                break;

                            case FlyKeyKeyFrameType.RunToInfinite:
                                switch (targetInfinite)
                                {
                                case FlyKeyLocation.CentreOfKey:
                                    destination = _BMDSwitcherFlyKeyFrame
                                                  .bmdSwitcherFlyKeyFrameInfinityCentreOfKey;
                                    break;

                                case FlyKeyLocation.TopLeft:
                                    destination = _BMDSwitcherFlyKeyFrame.bmdSwitcherFlyKeyFrameInfinityTopLeft;
                                    break;

                                case FlyKeyLocation.TopCentre:
                                    destination = _BMDSwitcherFlyKeyFrame.bmdSwitcherFlyKeyFrameInfinityTop;
                                    break;

                                case FlyKeyLocation.TopRight:
                                    destination = _BMDSwitcherFlyKeyFrame
                                                  .bmdSwitcherFlyKeyFrameInfinityTopRight;
                                    break;

                                case FlyKeyLocation.MiddleLeft:
                                    destination = _BMDSwitcherFlyKeyFrame.bmdSwitcherFlyKeyFrameInfinityLeft;
                                    break;

                                case FlyKeyLocation.MiddleCentre:
                                    destination = _BMDSwitcherFlyKeyFrame.bmdSwitcherFlyKeyFrameInfinityCentre;
                                    break;

                                case FlyKeyLocation.MiddleRight:
                                    destination = _BMDSwitcherFlyKeyFrame.bmdSwitcherFlyKeyFrameInfinityRight;
                                    break;

                                case FlyKeyLocation.BottomLeft:
                                    destination = _BMDSwitcherFlyKeyFrame
                                                  .bmdSwitcherFlyKeyFrameInfinityBottomLeft;
                                    break;

                                case FlyKeyLocation.BottomCentre:
                                    destination = _BMDSwitcherFlyKeyFrame.bmdSwitcherFlyKeyFrameInfinityBottom;
                                    break;

                                case FlyKeyLocation.BottomRight:
                                    destination = _BMDSwitcherFlyKeyFrame
                                                  .bmdSwitcherFlyKeyFrameInfinityBottomRight;
                                    break;

                                default:
                                    throw new ArgumentOutOfRangeException();
                                }

                                break;

                            default:
                                throw new ArgumentOutOfRangeException();
                            }

                            sdkKeyer.RunToKeyFrame(destination);
                        });
                    }
                });
            });
            Assert.True(tested);
        }