public void TestMode()
        {
            var handler = CommandGenerator.CreateAutoCommandHandler <MixMinusOutputSetCommand, MixMinusOutputGetCommand>("Mode");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.MixMinusOutputs, helper =>
            {
                bool tested = false;

                List <IBMDSwitcherMixMinusOutput> outputs = GetMixMinusOutputs(helper);
                for (int id = 0; id < outputs.Count; id++)
                {
                    IBMDSwitcherMixMinusOutput mixMinus = outputs[id];
                    tested = true;

                    AtemState stateBefore = helper.Helper.BuildLibState();
                    SettingsState.MixMinusOutputState mixMinusState = stateBefore.Settings.MixMinusOutputs[id];

                    for (int i = 0; i < 5; i++)
                    {
                        MixMinusMode newValue = Randomiser.EnumValue <MixMinusMode>();
                        mixMinusState.Mode    = newValue;

                        helper.SendAndWaitForChange(stateBefore,
                                                    () => { mixMinus.SetAudioMode(AtemEnumMaps.MixMinusModeMap[newValue]); });
                    }
                }
                Assert.True(tested);
            });
        }
        public void TestNextStyle()
        {
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <TransitionPropertiesSetCommand, TransitionPropertiesGetCommand>("NextStyle");

            AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper =>
            {
                EachMixEffect <IBMDSwitcherTransitionParameters>(helper, (stateBefore, meBefore, sdk, meId, i) =>
                {
                    tested = true;

                    var omitStyles = new List <TransitionStyle>();
                    if (stateBefore.Info.DVE == null)
                    {
                        omitStyles.Add(TransitionStyle.DVE);
                    }
                    if (stateBefore.MediaPool.Clips.Count == 0)
                    {
                        omitStyles.Add(TransitionStyle.Stinger);
                    }

                    TransitionStyle target = Randomiser.EnumValue(omitStyles.ToArray());
                    _BMDSwitcherTransitionStyle target2      = AtemEnumMaps.TransitionStyleMap[target];
                    meBefore.Transition.Properties.NextStyle = target;
                    helper.SendAndWaitForChange(stateBefore, () => { sdk.SetNextTransitionStyle(target2); });
                });
            });
            Assert.True(tested);
        }
        public void TestTally()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.FairlightMain, helper =>
            {
                IBMDSwitcherFairlightAudioMixer mixer = GetFairlightMixer(helper);
                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    var cmd = new FairlightMixerTallyCommand
                    {
                        Tally = new Dictionary <Tuple <AudioSource, long>, bool>()
                    };

                    Assert.NotEmpty(stateBefore.Fairlight.Tally);

                    // the sdk is a bit picky about ids, so best to go with what it expects
                    foreach (KeyValuePair <Tuple <AudioSource, long>, bool> k in stateBefore.Fairlight.Tally)
                    {
                        bool isMixedIn   = Randomiser.Range(0, 1) > 0.7;
                        cmd.Tally[k.Key] = isMixedIn;
                    }

                    stateBefore.Fairlight.Tally = cmd.Tally;
                    helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(cmd); });
                }
            });
        }
Ejemplo n.º 4
0
        public void TestClipSetValid()
        {
            AtemMockServerWrapper.Each(_output, _pool, SetValidCommandHandler, DeviceTestCases.MediaPlayerClips, helper =>
            {
                for (int i = 0; i < 3; i++)
                {
                    AtemState stateBefore = helper.Helper.BuildLibState();
                    uint index            = Randomiser.RangeInt((uint)stateBefore.MediaPool.Clips.Count);
                    IBMDSwitcherClip clip = GetClip(helper, index);

                    string name     = Guid.NewGuid().ToString();
                    uint frameCount = Randomiser.RangeInt(5) + 3;

                    var cb = new LockCallback();
                    helper.SendAndWaitForChange(stateBefore, () => { clip.Lock(cb); });
                    Assert.True(cb.Wait.WaitOne(2000));

                    var clipState        = stateBefore.MediaPool.Clips[(int)index];
                    clipState.IsUsed     = true;
                    clipState.Name       = name;
                    clipState.FrameCount = frameCount;

                    helper.SendAndWaitForChange(stateBefore, () =>
                    {
                        clip.SetValid(name, frameCount);
                    });

                    helper.SendAndWaitForChange(stateBefore, () =>
                    {
                        clip.Unlock(cb);
                    });
                }
            });
        }
Ejemplo n.º 5
0
        public void TestPreviewInput()
        {
            var ignorePortTypes = new HashSet <InternalPortType>
            {
                InternalPortType.Mask, InternalPortType.Auxiliary, InternalPortType.MEOutput
            };
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <PreviewInputSetCommand, PreviewInputGetCommand>("Source", true);

            AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper =>
            {
                // TODO - this could be better and use the availabilitymask
                List <VideoSource> validSources = helper.Helper.BuildLibState().Settings.Inputs
                                                  .Where(s => !ignorePortTypes.Contains(s.Value.Properties.InternalPortType)).Select(s => s.Key)
                                                  .ToList();
                VideoSource[] sampleSources = Randomiser.SelectionOfGroup(validSources).ToArray();

                EachMixEffect <IBMDSwitcherMixEffectBlock>(helper, (stateBefore, meBefore, sdk, meId, i) =>
                {
                    tested = true;

                    VideoSource target       = sampleSources[i];
                    meBefore.Sources.Preview = target;
                    helper.SendAndWaitForChange(stateBefore, () => { sdk.SetPreviewInput((long)target); });
                }, sampleSources.Length);
            });
            Assert.True(tested);
        }
        public void TestArtKeyInput()
        {
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <SuperSourcePropertiesSetV8Command, SuperSourcePropertiesGetV8Command>("ArtCutSource");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.SuperSource, helper =>
            {
                VideoSource[] validSources = helper.Helper.BuildLibState().Settings.Inputs.Where(
                    i => i.Value.Properties.SourceAvailability.HasFlag(SourceAvailability.SuperSourceArt)
                    ).Select(i => i.Key).ToArray();
                var sampleSources = VideoSourceUtil.TakeSelection(validSources);

                EachSuperSource(helper, (stateBefore, ssrcBefore, sdk, ssrcId, i) =>
                {
                    tested = true;

                    // TODO GetCutInputAvailabilityMask

                    VideoSource target = sampleSources[i];
                    ssrcBefore.Properties.ArtCutSource = target;
                    helper.SendAndWaitForChange(stateBefore, () => { sdk.SetInputCut((long)target); });
                }, sampleSources.Length);
            });
            Assert.True(tested);
        }
Ejemplo n.º 7
0
        public void TestLockAndUnlock()
        {
            AtemMockServerWrapper.Each(_output, _pool, UploadJobWorker.LockCommandHandler, DeviceTestCases.MediaPlayerClips, helper =>
            {
                helper.DisposeSdkClient = true;

                int clipCount = helper.Helper.BuildLibState().MediaPool.Clips.Count;
                for (int index = 0; index < clipCount; index++)
                {
                    IBMDSwitcherClip clip = GetClip(helper, (uint)index);

                    AtemState stateBefore = helper.Helper.BuildLibState();

                    var cb = new LockCallback();
                    helper.SendAndWaitForChange(stateBefore, () => { clip.Lock(cb); });
                    Assert.True(cb.Wait.WaitOne(2000));

                    helper.Helper.CheckStateChanges(stateBefore);

                    uint timeBefore = helper.Server.CurrentTime;

                    helper.SendAndWaitForChange(stateBefore, () => { clip.Unlock(cb); });

                    // It should have sent a response, but we dont expect any comparable data
                    Assert.NotEqual(timeBefore, helper.Server.CurrentTime);

                    helper.Helper.CheckStateChanges(stateBefore);
                }
            });
        }
        public void TestDiskRemoval()
        {
            var handler = CommandGenerator.CreateAutoCommandHandler <RecordingStatusSetCommand, RecordingStatusGetCommand>("IsRecording", true);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.Streaming, helper =>
            {
                var switcher = helper.SdkClient.SdkSwitcher as IBMDSwitcherStreamRTMP;
                Assert.NotNull(switcher);

                AtemState stateBefore = helper.Helper.BuildLibState();

                // Init a disk that will persit
                InitDisk(helper, stateBefore, 99);

                for (int i = 0; i < 10; i++)
                {
                    var id  = Randomiser.RangeInt(20);
                    var cmd = InitDisk(helper, stateBefore, id);

                    // Simulate removal
                    cmd.IsDelete = true;
                    stateBefore.Recording.Disks.Remove(id);
                    helper.SendFromServerAndWaitForChange(stateBefore, cmd);
                }
            });
        }
        public void TestStyle()
        {
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <TransitionDVESetCommand, TransitionDVEGetCommand>("Style");

            AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper =>
            {
                EachMixEffect <IBMDSwitcherTransitionDVEParameters>(helper, (stateBefore, meBefore, sdk, meId, i) =>
                {
                    if (stateBefore.Info.DVE != null && stateBefore.Info.DVE.SupportedTransitions.Count > 0)
                    {
                        var selection = Randomiser
                                        .SelectionOfGroup(stateBefore.Info.DVE.SupportedTransitions.ToList(), 3).ToList();

                        tested = true;
                        Assert.NotNull(meBefore.Transition.DVE);

                        foreach (DVEEffect style in selection)
                        {
                            meBefore.Transition.DVE.Style = style;
                            helper.SendAndWaitForChange(stateBefore,
                                                        () => { sdk.SetStyle(AtemEnumMaps.DVEStyleMap[style]); });
                        }
                    }
                });
            });
            Assert.True(tested);
        }
        public void TestRecordingState()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.Recording, helper =>
            {
                var switcher = helper.SdkClient.SdkSwitcher as IBMDSwitcherRecordAV;
                Assert.NotNull(switcher);

                AtemState stateBefore = helper.Helper.BuildLibState();

                InitDisk(helper, stateBefore);
                InitRecording(helper, stateBefore);

                stateBefore.Recording.Status.TotalRecordingTimeAvailable = 0;

                for (int i = 0; i < 10; i++)
                {
                    stateBefore.Recording.Status.State = Randomiser.EnumValue <RecordingStatus>();
                    stateBefore.Recording.Status.Error = Randomiser.EnumValue <RecordingError>();
                    var cmd = new RecordingStatusGetCommand()
                    {
                        Status = stateBefore.Recording.Status.State,
                        Error  = stateBefore.Recording.Status.Error,
                    };
                    helper.SendFromServerAndWaitForChange(stateBefore, cmd);
                }
            });
        }
        public void TestSwitchDisk()
        {
            var handler = CommandGenerator.MatchCommand(new RecordingSwitchDiskCommand());

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.Streaming, helper =>
            {
                var switcher = helper.SdkClient.SdkSwitcher as IBMDSwitcherRecordAV;
                Assert.NotNull(switcher);

                var stateBefore = helper.Helper.BuildLibState();
                InitDisk(helper, stateBefore, 0);
                InitDisk(helper, stateBefore, 1);

                InitRecording(helper, stateBefore, 0, 1);

                for (int i = 0; i < 5; i++)
                {
                    uint timeBefore = helper.Server.CurrentTime;

                    helper.SendAndWaitForChange(null, () => { switcher.SwitchDisk(); });

                    // It should have sent a response, but we dont expect any comparable data
                    Assert.NotEqual(timeBefore, helper.Server.CurrentTime);
                }
            });
        }
        protected static void EachSuperSourceBox(AtemMockServerWrapper helper, Action <AtemState, SuperSourceState.BoxState, IBMDSwitcherSuperSourceBox, SuperSourceId, SuperSourceBoxId, int> fcn, int iterations = 5)
        {
            var allBoxes = new List <Tuple <SuperSourceId, SuperSourceBoxId, IBMDSwitcherSuperSourceBox> >();

            foreach (KeyValuePair <VideoSource, IBMDSwitcherInputSuperSource> ssrc in helper.GetSdkInputsOfType <IBMDSwitcherInputSuperSource>())
            {
                SuperSourceId id       = (SuperSourceId)(ssrc.Key - VideoSource.SuperSource);
                var           iterator = AtemSDKConverter.CastSdk <IBMDSwitcherSuperSourceBoxIterator>(ssrc.Value.CreateIterator);
                AtemSDKConverter.Iterate <IBMDSwitcherSuperSourceBox>(iterator.Next, (box, i) =>
                {
                    allBoxes.Add(Tuple.Create(id, (SuperSourceBoxId)i, box));
                });
            }

            var boxes = Randomiser.SelectionOfGroup(allBoxes);

            foreach (Tuple <SuperSourceId, SuperSourceBoxId, IBMDSwitcherSuperSourceBox> box in boxes)
            {
                AtemState stateBefore = helper.Helper.BuildLibState();

                SuperSourceState.BoxState boxBefore = stateBefore.SuperSources[(int)box.Item1].Boxes[(int)box.Item2];
                Assert.NotNull(boxBefore);

                for (int i = 0; i < iterations; i++)
                {
                    fcn(stateBefore, boxBefore, box.Item3, box.Item1, box.Item2, i);
                }
            }
        }
 protected static void EachSuperSourceBorder(AtemMockServerWrapper helper, Action <AtemState, SuperSourceState.BorderState, IBMDSwitcherSuperSourceBorder, SuperSourceId, int> fcn, int iterations = 5)
 {
     EachSuperSource(helper, (stateBefore, ssrcState, sdk, ssrcId, i) =>
     {
         fcn(stateBefore, ssrcState.Border, (IBMDSwitcherSuperSourceBorder)sdk, ssrcId, i);
     }, iterations);
 }
        public void TestAudioInputId()
        {
            var handler = CommandGenerator.CreateAutoCommandHandler <MixMinusOutputSetCommand, MixMinusOutputGetCommand>("Mode");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.MixMinusOutputs, helper =>
            {
                var previousCommands = helper.Server.GetParsedDataDump().OfType <MixMinusOutputGetCommand>().ToList();

                for (int i = 0; i < 10; i++)
                {
                    AtemState stateBefore = helper.Helper.BuildLibState();
                    uint id = Randomiser.RangeInt((uint)stateBefore.Settings.MixMinusOutputs.Count - 1);
                    SettingsState.MixMinusOutputState mixMinusState = stateBefore.Settings.MixMinusOutputs[(int)id];

                    MixMinusOutputGetCommand cmd = previousCommands.Single(c => c.Id == id);
                    uint newValue       = Randomiser.RangeInt(9) + 1;
                    cmd.HasAudioInputId = i % 2 == 0;
                    cmd.AudioInputId    = cmd.HasAudioInputId ? (AudioSource)newValue : 0;

                    mixMinusState.HasAudioInputId = cmd.HasAudioInputId;
                    mixMinusState.AudioInputId    = cmd.AudioInputId;

                    helper.SendFromServerAndWaitForChange(stateBefore, cmd);
                }
            });
        }
Ejemplo n.º 15
0
 protected static VideoSource[] GetTransitionSourcesSelection(AtemMockServerWrapper helper)
 {
     VideoSource[] validSources = helper.Helper.BuildLibState().Settings.Inputs.Where(
         i => i.Value.Properties.SourceAvailability.HasFlag(SourceAvailability.KeySource)
         ).Select(i => i.Key).ToArray();
     return(VideoSourceUtil.TakeSelection(validSources));
 }
        public void TestFillSource()
        {
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <TransitionDVESetCommand, TransitionDVEGetCommand>("FillSource");

            AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper =>
            {
                VideoSource[] validSources = helper.Helper.BuildLibState().Settings.Inputs.Where(
                    i => i.Value.Properties.SourceAvailability.HasFlag(SourceAvailability.KeySource)
                    ).Select(i => i.Key).ToArray();
                var sampleSources = VideoSourceUtil.TakeSelection(validSources);

                EachMixEffect <IBMDSwitcherTransitionDVEParameters>(helper, (stateBefore, meBefore, sdk, meId, i) =>
                {
                    tested = true;
                    Assert.NotNull(meBefore.Transition.DVE);

                    // sdk.GetFillInputAvailabilityMask(out _BMDSwitcherInputAvailability mask);
                    // Assert.Equal((long)SourceAvailability., (long)mask);

                    VideoSource target = sampleSources[i];
                    meBefore.Transition.DVE.FillSource = target;
                    helper.SendAndWaitForChange(stateBefore, () => { sdk.SetInputFill((long)target); });
                }, sampleSources.Length);
            });
            Assert.True(tested);
        }
        public void TestReset()
        {
            var target = new FairlightMixerSourceDynamicsResetCommand()
            {
                Expander = true
            };
            var handler = CommandGenerator.MatchCommand(target);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.FairlightMain, helper =>
            {
                TestFairlightInputSource.EachRandomSource(helper, (stateBefore, srcState, inputId, src, i) =>
                {
                    IBMDSwitcherFairlightAudioExpander expander = GetExpander(src);

                    target.Index    = (AudioSource)inputId;
                    target.SourceId = srcState.SourceId;

                    uint timeBefore = helper.Server.CurrentTime;

                    helper.SendAndWaitForChange(null, () => { expander.Reset(); });

                    // It should have sent a response, but we dont expect any comparable data
                    Assert.NotEqual(timeBefore, helper.Server.CurrentTime);
                }, 1);
            });
        }
Ejemplo n.º 18
0
        public void TestHasUnsupportedOps()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.MacroTransfer, helper =>
            {
                var pool = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroPool;
                Assert.NotNull(pool);

                ImmutableList <ICommand> previousCommands = helper.Server.GetParsedDataDump();

                for (int i = 0; i < 10; i++)
                {
                    AtemState stateBefore = helper.Helper.BuildLibState();

                    uint index = Randomiser.RangeInt((uint)stateBefore.Macros.Pool.Count);
                    MacroPropertiesGetCommand cmd = previousCommands.OfType <MacroPropertiesGetCommand>().Single(c => c.Index == index);
                    cmd.HasUnsupportedOps         = i % 2 == 0;

                    stateBefore.Macros.Pool[(int)index].HasUnsupportedOps = cmd.HasUnsupportedOps;

                    helper.SendAndWaitForChange(stateBefore, () =>
                    {
                        helper.Server.SendCommands(cmd);
                    });
                }
            });
        }
Ejemplo n.º 19
0
        public void TestIsUsed()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.MediaPlayerClips, helper =>
            {
                ImmutableList <ICommand> previousCommands = helper.Server.GetParsedDataDump();

                int clipCount = helper.Helper.BuildLibState().MediaPool.Clips.Count;
                for (int index = 0; index < clipCount; index++)
                {
                    AtemState stateBefore = helper.Helper.BuildLibState();

                    for (int i = 0; i < 5; i++)
                    {
                        MediaPoolClipDescriptionCommand cmd = previousCommands.OfType <MediaPoolClipDescriptionCommand>().Single(c => c.Index == index);
                        cmd.IsUsed = i % 2 == 0;
                        cmd.Name   = cmd.IsUsed ? "abc" : "";

                        stateBefore.MediaPool.Clips[index].IsUsed = cmd.IsUsed;
                        stateBefore.MediaPool.Clips[index].Name   = cmd.Name;

                        helper.SendFromServerAndWaitForChange(stateBefore, cmd);
                    }
                }
            });
        }
        public void TestRecordPause()
        {
            var expectedCommand = new MacroAddTimedPauseCommand();
            var handler         = CommandGenerator.MatchCommand(expectedCommand);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.All, helper =>
            {
                var control = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroControl;
                Assert.NotNull(control);

                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    uint frames = Randomiser.RangeInt(2500);

                    expectedCommand.Frames = frames;

                    uint timeBefore = helper.Server.CurrentTime;

                    helper.SendAndWaitForChange(stateBefore, () => { control.RecordPause(frames); });

                    // It should have sent a response, but we dont expect any comparable data
                    Assert.NotEqual(timeBefore, helper.Server.CurrentTime);
                }
            });
        }
Ejemplo n.º 21
0
        public void TestSetAudioInvalid()
        {
            AtemMockServerWrapper.Each(_output, _pool, ClearAudioCommandHandler, DeviceTestCases.MediaPlayerClips, helper =>
            {
                ImmutableList <ICommand> previousCommands = helper.Server.GetParsedDataDump();

                int clipCount = helper.Helper.BuildLibState().MediaPool.Clips.Count;
                for (int index = 0; index < clipCount; index++)
                {
                    AtemState stateBefore = helper.Helper.BuildLibState();

                    IBMDSwitcherClip clip = GetClip(helper, (uint)index);

                    for (int i = 0; i < 5; i++)
                    {
                        MediaPoolAudioDescriptionCommand cmd = previousCommands
                                                               .OfType <MediaPoolAudioDescriptionCommand>().Single(c => c.Index == index + 1);
                        cmd.IsUsed = true;

                        // Set it to true first
                        stateBefore.MediaPool.Clips[index].Audio.IsUsed = true;
                        helper.SendFromServerAndWaitForChange(stateBefore, cmd);

                        // Now set invalid
                        stateBefore.MediaPool.Clips[index].Audio.IsUsed = false;
                        helper.SendAndWaitForChange(stateBefore, () => { clip.SetAudioInvalid(); });
                    }
                }
            });
        }
        public void TestRun()
        {
            var expectedCommand = RunThroughSerialize(new MacroActionCommand
            {
                Action = MacroActionCommand.MacroAction.Run
            });
            var handler = CommandGenerator.MatchCommand(expectedCommand);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.All, helper =>
            {
                var control = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroControl;
                Assert.NotNull(control);

                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    uint index            = Randomiser.RangeInt((uint)stateBefore.Macros.Pool.Count);
                    expectedCommand.Index = index;

                    uint timeBefore = helper.Server.CurrentTime;

                    helper.SendAndWaitForChange(stateBefore, () =>
                    {
                        control.Run(index);
                    });

                    // It should have sent a response, but we dont expect any comparable data
                    Assert.NotEqual(timeBefore, helper.Server.CurrentTime);
                }
            });
        }
Ejemplo n.º 23
0
        public void TestTransitionFramesRemaining()
        {
            bool tested = false;

            AtemMockServerWrapper.Each(Output, Pool, null, DeviceTestCases.All, helper =>
            {
                EachMixEffect <IBMDSwitcherMixEffectBlock>(helper, (stateBefore, meBefore, sdk, meId, i) =>
                {
                    tested = true;

                    uint target = Randomiser.RangeInt(250);
                    meBefore.Transition.Position.RemainingFrames = target;
                    helper.SendAndWaitForChange(stateBefore, () => {
                        helper.Server.SendCommands(new TransitionPositionGetCommand
                        {
                            Index           = meId,
                            RemainingFrames = target,
                            InTransition    = meBefore.Transition.Position.InTransition,
                            HandlePosition  = meBefore.Transition.Position.HandlePosition
                        });
                    });
                });
            });
            Assert.True(tested);
        }
        public void TestRunStatus()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.All, helper =>
            {
                var control = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroControl;
                Assert.NotNull(control);

                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    uint index = Randomiser.RangeInt((uint)stateBefore.Macros.Pool.Count);
                    var status = Randomiser.EnumValue <MacroState.MacroRunStatus>();

                    stateBefore.Macros.RunStatus.RunIndex  = index;
                    stateBefore.Macros.RunStatus.RunStatus = status;

                    helper.SendAndWaitForChange(stateBefore, () =>
                    {
                        helper.Server.SendCommands(new MacroRunStatusGetCommand
                        {
                            Index     = index,
                            IsWaiting = status == MacroState.MacroRunStatus.UserWait,
                            IsRunning = status == MacroState.MacroRunStatus.Running,
                            Loop      = stateBefore.Macros.RunStatus.Loop,
                        });
                    });
                }
            });
        }
        public void TestGetSelection()
        {
            bool tested = false;

            AtemMockServerWrapper.Each(Output, Pool, null, DeviceTestCases.All, helper =>
            {
                EachMixEffect <IBMDSwitcherTransitionParameters>(helper, (stateBefore, meBefore, sdk, meId, i) =>
                {
                    tested = true;

                    uint maxSelectionValue = (uint)1 << meBefore.Keyers.Count;
                    uint maxSelection      = (maxSelectionValue << 1) - 1;
                    uint target            = 1 + Randomiser.RangeInt(maxSelection - 1);
                    meBefore.Transition.Properties.Selection = (TransitionLayer)target;
                    helper.SendAndWaitForChange(stateBefore, () => {
                        helper.Server.SendCommands(new TransitionPropertiesGetCommand
                        {
                            Index         = meId,
                            NextStyle     = meBefore.Transition.Properties.NextStyle,
                            Style         = meBefore.Transition.Properties.Style,
                            NextSelection = meBefore.Transition.Properties.NextSelection,
                            Selection     = (TransitionLayer)target,
                        });
                    });
                });
            });
            Assert.True(tested);
        }
        public void TestRecordStatus()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.All, helper =>
            {
                var control = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroControl;
                Assert.NotNull(control);

                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    uint index     = Randomiser.RangeInt((uint)stateBefore.Macros.Pool.Count);
                    bool recording = Randomiser.RangeInt(1) == 1;

                    stateBefore.Macros.RecordStatus.RecordIndex = index;
                    stateBefore.Macros.RecordStatus.IsRecording = recording;

                    helper.SendAndWaitForChange(stateBefore, () =>
                    {
                        helper.Server.SendCommands(new MacroRecordingStatusGetCommand()
                        {
                            Index       = index,
                            IsRecording = recording,
                        });
                    });
                }
            });
        }
        public void TestGetStyle()
        {
            bool tested = false;

            AtemMockServerWrapper.Each(Output, Pool, null, DeviceTestCases.All, helper =>
            {
                EachMixEffect <IBMDSwitcherTransitionParameters>(helper, (stateBefore, meBefore, sdk, meId, i) =>
                {
                    tested = true;

                    TransitionStyle target = Randomiser.EnumValue <TransitionStyle>();
                    meBefore.Transition.Properties.Style = target;
                    helper.SendAndWaitForChange(stateBefore, () => {
                        helper.Server.SendCommands(new TransitionPropertiesGetCommand
                        {
                            Index         = meId,
                            NextStyle     = meBefore.Transition.Properties.NextStyle,
                            Style         = target,
                            NextSelection = meBefore.Transition.Properties.NextSelection,
                            Selection     = meBefore.Transition.Properties.Selection,
                        });
                    });
                });
            });
            Assert.True(tested);
        }
        public void TestStop()
        {
            var expectedCommand = RunThroughSerialize(new MacroActionCommand
            {
                Action = MacroActionCommand.MacroAction.Stop
            });
            var handler = CommandGenerator.MatchCommand(expectedCommand);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.All, helper =>
            {
                var control = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroControl;
                Assert.NotNull(control);

                uint timeBefore = helper.Server.CurrentTime;

                AtemState stateBefore = helper.Helper.BuildLibState();
                helper.SendAndWaitForChange(stateBefore, () =>
                {
                    control.StopRunning();
                });

                // It should have sent a response, but we dont expect any comparable data
                Assert.NotEqual(timeBefore, helper.Server.CurrentTime);
            });
        }
        public static IBMDSwitcherFairlightAudioMixer GetFairlightMixer(AtemMockServerWrapper helper)
        {
            var mixer = helper.Helper.SdkSwitcher as IBMDSwitcherFairlightAudioMixer;

            Assert.NotNull(mixer);
            return(mixer);
        }
Ejemplo n.º 30
0
        public void TestSource()
        {
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <TransitionStingerSetCommand, TransitionStingerGetCommand>("Source");

            AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper =>
            {
                int mpCount = helper.Helper.BuildLibState().MediaPlayers.Count;
                List <StingerSource> sources = Enum.GetValues(typeof(StingerSource)).OfType <StingerSource>().Where(s => ((int)s) < mpCount).ToList();
                if (sources.Count <= 1)
                {
                    return;
                }

                EachMixEffect <IBMDSwitcherTransitionStingerParameters>(helper, (stateBefore, meBefore, sdk, meId, i) =>
                {
                    tested = true;
                    Assert.NotNull(meBefore.Transition.Stinger);

                    StingerSource target = sources[i];
                    _BMDSwitcherStingerTransitionSource target2 = AtemEnumMaps.StingerSourceMap[target];
                    meBefore.Transition.Stinger.Source          = target;
                    helper.SendAndWaitForChange(stateBefore, () => { sdk.SetSource(target2); });
                }, sources.Count);
            });
            Assert.True(tested);
        }