public void TestIsDropFrameTimecode()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.HyperDecks, helper =>
            {
                ImmutableList <ICommand> allCommands = helper.Server.GetParsedDataDump();
                List <HyperDeckSettingsGetCommand> settingsCommands = allCommands.OfType <HyperDeckSettingsGetCommand>().ToList();
                List <HyperDeckStorageGetCommand> sourceCommands    = allCommands.OfType <HyperDeckStorageGetCommand>().ToList();

                foreach (IBMDSwitcherHyperDeck deck in GetHyperDecks(helper))
                {
                    deck.GetId(out long id);
                    HyperDeckSettingsGetCommand cmd   = settingsCommands.Single(c => c.Id == id);
                    HyperDeckStorageGetCommand srcCmd = sourceCommands.Single(c => c.Id == id);

                    // Force it to be connected
                    AtemState stateBefore = helper.Helper.BuildLibState();
                    cmd.Status            = HyperDeckConnectionStatus.Connected;
                    stateBefore.Hyperdecks[(int)id].Settings.Status = HyperDeckConnectionStatus.Connected;
                    stateBefore.Hyperdecks[(int)id].Player.State    = HyperDeckPlayerState.Idle;
                    helper.SendFromServerAndWaitForChange(stateBefore, cmd);

                    stateBefore = helper.Helper.BuildLibState();
                    HyperdeckState hyperdeckState = stateBefore.Hyperdecks[(int)id];

                    for (int i = 0; i < 5; i++)
                    {
                        hyperdeckState.Storage.IsDropFrameTimecode =
                            srcCmd.IsDropFrameTimecode             = !hyperdeckState.Storage.IsDropFrameTimecode;

                        helper.SendFromServerAndWaitForChange(stateBefore, srcCmd);
                    }
                }
            });
        }
        public void TestRemainingRecordTime()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.HyperDecks, helper =>
            {
                ImmutableList <ICommand> allCommands = helper.Server.GetParsedDataDump();
                List <HyperDeckSettingsGetCommand> settingsCommands = allCommands.OfType <HyperDeckSettingsGetCommand>().ToList();
                List <HyperDeckStorageGetCommand> sourceCommands    = allCommands.OfType <HyperDeckStorageGetCommand>().ToList();

                foreach (IBMDSwitcherHyperDeck deck in GetHyperDecks(helper))
                {
                    deck.GetId(out long id);

                    HyperDeckSettingsGetCommand cmd   = settingsCommands.Single(c => c.Id == id);
                    HyperDeckStorageGetCommand srcCmd = sourceCommands.Single(c => c.Id == id);

                    // Force it to be connected
                    AtemState stateBefore = helper.Helper.BuildLibState();
                    cmd.Status            = HyperDeckConnectionStatus.Connected;
                    stateBefore.Hyperdecks[(int)id].Settings.Status = HyperDeckConnectionStatus.Connected;
                    stateBefore.Hyperdecks[(int)id].Player.State    = HyperDeckPlayerState.Idle;
                    helper.SendFromServerAndWaitForChange(stateBefore, cmd);

                    HyperdeckState deckState = stateBefore.Hyperdecks[(int)id];

                    // Now try the stuff
                    for (int i = 0; i < 5; i++)
                    {
                        uint hours   = (uint)Randomiser.RangeInt(1, 20);
                        uint minutes = (uint)Randomiser.RangeInt(1, 59);
                        uint seconds = (uint)Randomiser.RangeInt(1, 59);
                        uint frames  = (uint)Randomiser.RangeInt(1, 20);
                        srcCmd.RemainingRecordTime = deckState.Storage.RemainingRecordTime = new HyperDeckTime
                        {
                            Hour = hours, Minute = minutes, Second = seconds, Frame = frames
                        };

                        helper.SendFromServerAndWaitForChange(stateBefore, srcCmd);
                    }
                }
            });
        }
        public void TestStorageMediaStatus()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.HyperDecks, helper =>
            {
                List <HyperDeckSettingsGetCommand> settingsCommands = helper.Server.GetParsedDataDump().OfType <HyperDeckSettingsGetCommand>().ToList();

                foreach (IBMDSwitcherHyperDeck deck in GetHyperDecks(helper))
                {
                    deck.GetId(out long id);
                    HyperDeckSettingsGetCommand cmd = settingsCommands.Single(c => c.Id == id);

                    // Force it to be connected
                    AtemState stateBefore = helper.Helper.BuildLibState();
                    cmd.Status            = HyperDeckConnectionStatus.Connected;
                    stateBefore.Hyperdecks[(int)id].Settings.Status = HyperDeckConnectionStatus.Connected;
                    stateBefore.Hyperdecks[(int)id].Player.State    = HyperDeckPlayerState.Idle;
                    helper.SendFromServerAndWaitForChange(stateBefore, cmd);

                    stateBefore = helper.Helper.BuildLibState();
                    HyperdeckState hyperdeckState             = stateBefore.Hyperdecks[(int)id];
                    hyperdeckState.Storage.ActiveStorageMedia = 0;

                    var storageCmd = new HyperDeckStorageGetCommand
                    {
                        Id = (uint)id,
                        ActiveStorageMedia = hyperdeckState.Storage.ActiveStorageMedia,
                        CurrentClipId      = hyperdeckState.Storage.CurrentClipId,
                        FrameRate          = hyperdeckState.Storage.FrameRate,
                        TimeScale          = hyperdeckState.Storage.TimeScale,
                    };

                    for (int i = 0; i < 5; i++)
                    {
                        hyperdeckState.Storage.ActiveStorageStatus = storageCmd.ActiveStorageStatus =
                            Randomiser.EnumValue <HyperDeckStorageStatus>();

                        helper.SendFromServerAndWaitForChange(stateBefore, storageCmd);
                    }
                }
            });
        }
        public void TestCurrentTimelineTime()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.HyperDecks, helper =>
            {
                ImmutableList <ICommand> allCommands = helper.Server.GetParsedDataDump();
                List <HyperDeckSettingsGetCommand> settingsCommands = allCommands.OfType <HyperDeckSettingsGetCommand>().ToList();
                List <HyperDeckPlayerGetCommand> playerCommands     = allCommands.OfType <HyperDeckPlayerGetCommand>().ToList();

                foreach (IBMDSwitcherHyperDeck deck in GetHyperDecks(helper))
                {
                    deck.GetId(out long id);

                    HyperDeckSettingsGetCommand cmd   = settingsCommands.Single(c => c.Id == id);
                    HyperDeckPlayerGetCommand playCmd = playerCommands.Single(c => c.Id == id);

                    // Force it to be connected
                    AtemState stateBefore = helper.Helper.BuildLibState();
                    cmd.Status            = HyperDeckConnectionStatus.Connected;
                    stateBefore.Hyperdecks[(int)id].Settings.Status = HyperDeckConnectionStatus.Connected;
                    stateBefore.Hyperdecks[(int)id].Player.State    = HyperDeckPlayerState.Idle;
                    helper.SendFromServerAndWaitForChange(stateBefore, cmd);

                    // Define a clip
                    stateBefore.Hyperdecks[(int)id].Clips =
                        UpdaterUtil.CreateList(1, i => new HyperdeckState.ClipState());
                    helper.SendFromServerAndWaitForChange(stateBefore, new HyperDeckClipCountCommand
                    {
                        Id        = (uint)id,
                        ClipCount = 1,
                    });
                    var clipCmd = new HyperDeckClipInfoCommand
                    {
                        HyperdeckId = (uint)id,
                        ClipId      = 0,
                        Name        = "something 123",
                        Duration    = new HyperDeckTime {
                            Hour = 24
                        },
                        TimelineStart = new HyperDeckTime(),
                        TimelineEnd   = new HyperDeckTime {
                            Hour = 24
                        },
                    };
                    AtemStateBuilder.Update(stateBefore, clipCmd);
                    helper.SendFromServerAndWaitForChange(stateBefore, clipCmd);
                    stateBefore = helper.Helper.BuildLibState();

                    // Set the clip to be playing
                    HyperDeckStorageGetCommand srcCmd = new HyperDeckStorageGetCommand
                    {
                        Id = (uint)id,
                        ActiveStorageMedia  = 0,
                        CurrentClipId       = 0,
                        FrameRate           = 50000,
                        TimeScale           = 1000,
                        RemainingRecordTime = new HyperDeckTime(),
                    };
                    AtemStateBuilder.Update(stateBefore, srcCmd);
                    helper.SendFromServerAndWaitForChange(stateBefore, srcCmd);
                    stateBefore = helper.Helper.BuildLibState();

                    HyperdeckState deckState = stateBefore.Hyperdecks[(int)id];

                    // Now try the stuff
                    for (int i = 0; i < 5; i++)
                    {
                        uint hours   = (uint)Randomiser.RangeInt(1, 20);
                        uint minutes = (uint)Randomiser.RangeInt(1, 59);
                        uint seconds = (uint)Randomiser.RangeInt(1, 59);
                        uint frames  = (uint)Randomiser.RangeInt(1, 20);
                        deckState.Player.ClipTime = new HyperDeckTime();
                        playCmd.TimelineTime      = deckState.Player.TimelineTime = new HyperDeckTime
                        {
                            Hour = hours, Minute = minutes, Second = seconds, Frame = frames
                        };

                        helper.SendFromServerAndWaitForChange(stateBefore, playCmd);
                    }
                }
            });
        }