Exemplo n.º 1
0
 private void CheckShown(NavigationCommand cmd)
 {
     if (!IsVisible)
     {
         Show();
     }
 }
        public void GetWxeFunctionPermanentUrlWithDefaultWxeHandlerAndAdditionalUrlParameters()
        {
            WebConfigurationMock.Current = WebConfigurationFactory.GetExecutionEngineWithDefaultWxeHandler();

            string wxeHandler = Remotion.Web.Configuration.WebConfiguration.Current.ExecutionEngine.DefaultWxeHandler;

            NameValueCollection additionalUrlParameters = new NameValueCollection();

            additionalUrlParameters.Add("Parameter2", "Value2");

            string expectedUrl = wxeHandler.TrimStart('~');
            NameValueCollection expectedQueryString = new NameValueCollection();

            expectedQueryString.Add("Parameter1", _wxeFunctionParameter1Value);
            expectedQueryString.Add(WxeHandler.Parameters.WxeReturnToSelf, true.ToString());
            expectedQueryString.Add(additionalUrlParameters);
            expectedQueryString.Add(WxeHandler.Parameters.WxeFunctionType, _functionTypeName);
            expectedUrl += UrlUtility.FormatQueryString(expectedQueryString);

            NavigationCommand command = new NavigationCommand();

            command.Type = CommandType.WxeFunction;
            command.WxeFunctionCommand.TypeName   = _functionTypeName;
            command.WxeFunctionCommand.Parameters = _wxeFunctionParameters;
            string url = command.GetWxeFunctionPermanentUrl(additionalUrlParameters);

            Assert.That(url, Is.Not.Null);
            Assert.That(url, Is.EqualTo(expectedUrl));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="navigationManager">NavigationManager (Injected)</param>
 /// <param name="apiConnector">ApiConnector (Injected)</param>
 public DeckSearchViewModel(NavigationManager navigationManager, IApiConnector apiConnector)
     : base(navigationManager, apiConnector)
 {
     PracticeDeckCommand = new NavigationCommand(navigationManager)
     {
         CommandText       = Messages.Practice,
         IsRelative        = true,
         IsEnabledFunction = (parameter) => (parameter as Deck).CardCount > 0,
         ToolTip           = Messages.PracticeCommandToolTip.FormatWith(EntityNameHelper.GetName <Deck>()),
         TargetUriFactory  = (param) => $"/{(param as Deck).DeckId}/Practice"
     };
     AddCardCommand = new NavigationCommand(navigationManager)
     {
         CommandText      = Messages.NewCard,
         IsRelative       = true,
         ToolTip          = Components.Messages.NewCommandToolTip.FormatWith(EntityNameHelper.GetName <Card>()),
         TargetUriFactory = (param) => $"/{(param as Deck).DeckId}/Cards/New"
     };
     ShowStatisticsCommand = new NavigationCommand(navigationManager)
     {
         CommandText      = Messages.PracticeStatistics,
         IsRelative       = true,
         ToolTip          = Messages.ShowStatisticsCommandToolTip.FormatWith(EntityNameHelper.GetName <Deck>()),
         TargetUriFactory = (param) => $"/{(param as Deck).DeckId}/Statistics"
     };
 }
Exemplo n.º 4
0
        public void Setup()
        {
            _mocks = new MockRepository();

            _mockTabbedMenu = _mocks.PartialMock <TabbedMenu>();

            _mockNavigationCommand1 = _mocks.PartialMock <NavigationCommand>();
            _mocks.Replay(_mockNavigationCommand1);

            _mockNavigationCommand2 = _mocks.PartialMock <NavigationCommand>();
            _mocks.Replay(_mockNavigationCommand2);

            _mainMenuTab              = new MainMenuTab();
            _mainMenuTab.ItemID       = "MainMenuTab";
            _mainMenuTab.Command.Type = CommandType.None;
            _mainMenuTab.OwnerControl = _mockTabbedMenu;

            _mockSubMenuTab1 = CreateSubMenuTab("SubMenuTab1", _mockNavigationCommand1);
            _mainMenuTab.SubMenuTabs.Add(_mockSubMenuTab1);

            _mockSubMenuTab2 = CreateSubMenuTab("SubMenuTab2", _mockNavigationCommand2);
            _mainMenuTab.SubMenuTabs.Add(_mockSubMenuTab2);

            _mocks.BackToRecord(_mockSubMenuTab1);
            _mocks.BackToRecord(_mockSubMenuTab2);
            _mocks.BackToRecord(_mockNavigationCommand1);
            _mocks.BackToRecord(_mockNavigationCommand2);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Indicates whether a navigation would be valid if it were to be performed.
        /// </summary>
        /// <param name="command">The navigation command to test.</param>
        /// <param name="activity">The destination activity, if this is a choice navigation.</param>
        /// <returns>True if the navigation would be valid, false otherwise.</returns>
        /// <remarks>
        /// <para>
        /// This makes a partial copy of the activity tree for processing and attempts to
        /// perform a navigation on that copy.  This may result in poor performance if this
        /// is called many times, but the alternative is to duplicate most of the sequencing
        /// code with lots of special cases for changes of state that should have happened but
        /// could not because of the temporary nature of this request.  This makes it a
        /// maintenance nightmare, for something that should only rarely be called anyway
        /// except in the case of <Mth>LoadTableOfContents</Mth>.
        /// </para>
        /// <para>
        /// The case of <Mth>LoadTableOfContents</Mth> is tough, but steps are taken within
        /// that method to reduce the number of calls to this method to a bare minimum.
        /// </para>
        /// </remarks>
        protected bool IsNavigationValid(NavigationCommand command, Activity activity)
        {
            SeqNav seqNav;

            try
            {
                NavigatorData clone = CloneForNavigationTest();
                Activity      destination;

                if (activity != null)
                {
                    destination = clone.Activities[activity.ActivityId];
                }
                else
                {
                    destination = null;
                }
                if (m_packageFormat == PackageFormat.V1p3)
                {
                    seqNav = new Scorm2004SeqNav(clone);
                }
                else
                {
                    seqNav = new Scorm12SeqNav(clone);
                }
                seqNav.OverallSequencingProcess(command, destination);
            }
            catch (SequencingException)
            {
                // if there was a sequencing exception,
                // this is a failure condition.
                return(false);
            }
            return(true);
        }
        public void GetWxeFunctionPermanentUrlWithMappedFunctionTypeAndAdditionalUrlParameters()
        {
            string resource = "~/Test.wxe";

            UrlMappingConfiguration.Current.Mappings.Add(new UrlMappingEntry(_functionType, resource));
            string parameter1 = "Value1";

            NameValueCollection additionalUrlParameters = new NameValueCollection();

            additionalUrlParameters.Add("Parameter2", "Value2");

            string expectedUrl = resource.TrimStart('~');
            NameValueCollection expectedQueryString = new NameValueCollection();

            expectedQueryString.Add("Parameter1", parameter1);
            expectedQueryString.Add(WxeHandler.Parameters.WxeReturnToSelf, true.ToString());
            expectedQueryString.Add(additionalUrlParameters);
            expectedUrl += UrlUtility.FormatQueryString(expectedQueryString);

            NavigationCommand command = new NavigationCommand();

            command.Type = CommandType.WxeFunction;
            command.WxeFunctionCommand.TypeName   = _functionTypeName;
            command.WxeFunctionCommand.Parameters = "\"" + parameter1 + "\"";
            string url = command.GetWxeFunctionPermanentUrl(additionalUrlParameters);

            Assert.That(url, Is.Not.Null);
            Assert.That(url, Is.EqualTo(expectedUrl));
        }
Exemplo n.º 7
0
        public MarsRover(int coordX, int coordY, Direction direction, Plateau plateau, NavigationCommand[] navCommands)
        {
            if (plateau == null || (plateau.BottomLeftCoordX == plateau.TopRightCoordX && plateau.BottomLeftCoordY == plateau.TopRightCoordY))
            {
                //if Plateau initialization data is invalid/incomplete, we cannot create a rover that we can work with
                throw new ArgumentException("Plateau is invalid.");
            }

            if (navCommands == null || navCommands.Length == 0)
            {
                throw new ArgumentException("Invalid navigation commands");
            }

            Plateau = plateau;
            Direction = direction;
            NavigationCommands = navCommands;

            if (ValidateRoverCoordinates(coordX, coordY))
            {
                CoordX = coordX;
                CoordY = coordY;
            }
            else
            {
                //if initial values of Rover coordinates are not valid, place the rover in the approximate center of the plateau
                CoordX = Plateau.BottomLeftCoordX + (Plateau.TopRightCoordX - plateau.BottomLeftCoordY) / 2;
                CoordY = Plateau.BottomLeftCoordY + (Plateau.TopRightCoordY - plateau.BottomLeftCoordY) / 2;
            }
        }
Exemplo n.º 8
0
        public void Navigate_CommandsWithMovesOutOfBounds_ReturnSkippedMoves_AssignCorrectCoords()
        {
            var plateau = new Plateau
            {
                BottomLeftCoordX = 0,
                BottomLeftCoordY = 0,
                TopRightCoordX = 5,
                TopRightCoordY = 5
            };

            //the second move command will be out of bounds
            var commands = new NavigationCommand[] { NavigationCommand.M, NavigationCommand.M, NavigationCommand.R, NavigationCommand.M };

            var rover = new MarsRover(4, 5, App.Enums.Direction.E, plateau, commands);

            var result = rover.Navigate(commands);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Count, 1);
            Assert.AreEqual(result[0], 1);

            Assert.AreEqual(rover.CoordX, 5);
            Assert.AreEqual(rover.CoordY, 4);
            Assert.AreEqual(rover.Direction, Direction.S);
        }
        void setupRx()
        {
            if (rxObjectsSetup)
            {
                return;
            }

            NavigateBack = new ReactiveCommand(
                NavigationStack.CollectionCountChanged.StartWith(_NavigationStack.Count).Select(x => x > 1));
            NavigateBack.Subscribe(_ =>
                                   NavigationStack.RemoveAt(NavigationStack.Count - 1));

            Navigate = new NavigationCommand();
            Navigate.Subscribe(x => {
                var vm = x as IRoutableViewModel;
                if (vm == null)
                {
                    throw new Exception("Navigate must be called on an IRoutableViewModel");
                }

                NavigationStack.Add(vm);
            });

            NavigateAndReset = new NavigationCommand();
            NavigateAndReset.Subscribe(x => {
                NavigationStack.Clear();
                Navigate.Execute(x);
            });

            rxObjectsSetup = true;
        }
        public static bool ParseCommands(Gst.Query query, out NavigationCommand[] cmds)
        {
            uint len;

            cmds = null;
            if (!QueryParseCommandsLength(query, out len))
            {
                return(false);
            }

            cmds = new NavigationCommand[len];

            for (uint i = 0; i < len; i++)
            {
                NavigationCommand cmd;

                if (!QueryParseCommandsNth(query, i, out cmd))
                {
                    return(false);
                }
                cmds[i] = cmd;
            }

            return(true);
        }
Exemplo n.º 11
0
 public ShoppingListVM()
 {
     // Instantiate any Commands/Objects:
     Item              = new Item();
     RefreshCommand    = new RefreshCommand(this);
     NavCommand        = new NavigationCommand(this);
     NewItemNavCommand = new NavigationCommand(this, 1);
 }
Exemplo n.º 12
0
        public MainWindow()
        {
            InitializeComponent();

            NavigationCommand navigationCommand = App.Current.Resources["NavigationCommand"] as NavigationCommand;

            navigationCommand.MainWindow = this;
        }
Exemplo n.º 13
0
        private SubMenuTab CreateSubMenuTab(string itemID, NavigationCommand command)
        {
            SubMenuTab tab = _mocks.PartialMock <SubMenuTab>();

            _mocks.Replay(tab);
            tab.ItemID  = itemID;
            tab.Command = command;

            return(tab);
        }
Exemplo n.º 14
0
        public MainWindowModel(Window Window, ContentControl contentControl)
        {
            NavigateSettingsCommand = new NavigationCommand <SettingsPage>(contentControl);
            CloseCommand            = new CloseCommand(Window);
            FullscreenCommand       = new FullscreenCommand(Window);
            MinimizeCommand         = new MinimizeCommand(Window);
            RefreshCommand          = new RefreshCommand();

            MenuItems.Add(new MenuItem(PackIconKind.FileReport, Resources.App_Menu_Processed, Resources.App_Menu_Processed_Description, new NavigationCommand <ProcessedPage>(contentControl)));
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="navigationManager">NavigationManager (Injected)</param>
 public PageViewModelBase(NavigationManager navigationManager)
 {
     NavigationManager = navigationManager;
     CloseCommand      = new NavigationCommand(navigationManager)
     {
         Icon      = "oi oi-x",
         IsEnabled = true,
         TargetUri = "/",
         ToolTip   = Messages.CloseCommandToolTip
     };
 }
Exemplo n.º 16
0
        public void Part1_Example_Step1()
        {
            var command = NavigationCommand.FromString("F10");

            var ship = new Ship();

            ship.ProcessCommand(command);

            ship.Direction.Should().Be(Direction.East);
            ship.X.Should().Be(10);
            ship.Y.Should().Be(0);
        }
Exemplo n.º 17
0
        public void Part2_Example_Step1()
        {
            var ship    = new Ship();
            var command = NavigationCommand.FromString("F10");

            ship.ProcessWaypointCommand(command);

            ship.X.Should().Be(100);
            ship.Y.Should().Be(10);
            ship.Waypoint.X.Should().Be(10);
            ship.Waypoint.Y.Should().Be(1);
        }
Exemplo n.º 18
0
        public void Setup()
        {
            _mocks = new MockRepository();
            _mockWebSecurityAdapter = _mocks.StrictMock <IWebSecurityAdapter> ();
            _mockNavigationCommand  = _mocks.StrictMock <NavigationCommand> ();

            var serviceLocator = DefaultServiceLocator.Create();

            serviceLocator.RegisterMultiple <IWebSecurityAdapter> (() => _mockWebSecurityAdapter);
            serviceLocator.RegisterMultiple <IWxeSecurityAdapter>();
            _serviceLocatorScope = new ServiceLocatorScope(serviceLocator);
        }
        public void GetWxeFunctionPermanentUrlWithoutDefaultWxeHandler()
        {
            WebConfigurationMock.Current = null;
            string parameter1 = "Hello World!";

            NavigationCommand command = new NavigationCommand();

            command.Type = CommandType.WxeFunction;
            command.WxeFunctionCommand.TypeName   = _functionTypeName;
            command.WxeFunctionCommand.Parameters = "\"" + parameter1 + "\"";
            command.GetWxeFunctionPermanentUrl();
        }
Exemplo n.º 20
0
        public void MarsRover_InvalidPlateau_Exception()
        {
            var plateau = new Plateau
            {
                BottomLeftCoordX = 1,
                BottomLeftCoordY = 1,
                TopRightCoordX = 1,
                TopRightCoordY = 1
            };

            var commands = new NavigationCommand[] { NavigationCommand.M, NavigationCommand.M, NavigationCommand.R, NavigationCommand.M };
            var rover = new MarsRover(1, 2, App.Enums.Direction.E, plateau, commands);
        }
Exemplo n.º 21
0
        public List<int> Navigate(NavigationCommand[] navCommands)
        {
            var listSkippedCommands = new List<int>();

            for (var i = 0; i < navCommands.Length; i++)
            {
                if (!TryMove(navCommands[i]))
                {
                    listSkippedCommands.Add(i);
                }
            }

            return listSkippedCommands;
        }
Exemplo n.º 22
0
        public void Part1_Example_Step5()
        {
            var command = NavigationCommand.FromString("F11");

            var ship = new Ship()
            {
                X = 17, Y = 3, Direction = Direction.South
            };

            ship.ProcessCommand(command);

            ship.Direction.Should().Be(Direction.South);
            ship.X.Should().Be(17);
            ship.Y.Should().Be(-8);
        }
Exemplo n.º 23
0
 /// <summary>
 /// Performs a full SCORM 2004 or SCORM 1.2 navigation on the current activity tree.
 /// </summary>
 /// <param name="command">The navigation command to perform.</param>
 /// <param name="destination">The destination activity for choice navigation.</param>
 /// <returns>True if the attempt is completed and should not be returned to.</returns>
 protected bool Navigate(NavigationCommand command, Activity destination)
 {
     if (m_seqNav == null)
     {
         if (m_packageFormat == PackageFormat.V1p2 || m_packageFormat == PackageFormat.Lrm)
         {
             m_seqNav = new Scorm12SeqNav(this);
         }
         else
         {
             m_seqNav = new Scorm2004SeqNav(this);
         }
     }
     return(m_seqNav.OverallSequencingProcess(command, destination));
 }
Exemplo n.º 24
0
        public static Direction MoveCompass(Direction direction, NavigationCommand command)
        {
            var directionsRight = new Dictionary<Direction, Direction> { { Direction.N, Direction.E }, { Direction.E, Direction.S }, { Direction.S, Direction.W }, { Direction.W, Direction.N } };
            var directionsLeft = new Dictionary<Direction, Direction> { { Direction.N, Direction.W }, { Direction.W, Direction.S }, { Direction.S, Direction.E }, { Direction.E, Direction.N } };

            if (command == NavigationCommand.R)
            {
                return directionsRight[direction];
            }
            else if (command == NavigationCommand.L)
            {
                return directionsLeft[direction];
            }

            return direction;
        }
Exemplo n.º 25
0
        public void MarsRover_ValidRoverCoords_AssignRoverCoords()
        {
            var plateau = new Plateau
            {
                BottomLeftCoordX = 0,
                BottomLeftCoordY = 0,
                TopRightCoordX = 5,
                TopRightCoordY = 5
            };

            var commands = new NavigationCommand[] { NavigationCommand.M, NavigationCommand.M, NavigationCommand.R, NavigationCommand.M };
            var rover = new MarsRover(2, 3, App.Enums.Direction.E, plateau, commands);

            Assert.AreEqual(rover.CoordX, 2);
            Assert.AreEqual(rover.CoordY, 3);
        }
Exemplo n.º 26
0
        public static bool ParseCommands(Gst.Query query, out NavigationCommand[] cmds)
        {
            uint len;

            cmds = null;
            if (!QueryParseCommandsLength (query, out len))
                return false;

            cmds = new NavigationCommand[len];

            for (uint i = 0; i < len; i++) {
                NavigationCommand cmd;

                if (!QueryParseCommandsNth (query, i, out cmd))
                    return false;
                cmds[i] = cmd;
            }

            return true;
        }
Exemplo n.º 27
0
        public bool TryMove(NavigationCommand navCommand)
        {
            if (navCommand == NavigationCommand.M)
            {
                var newX = CoordX;
                var newY = CoordY;

                if (Direction == Direction.N)
                {
                    newY++;
                }
                else if (Direction == Direction.S)
                {
                    newY--;
                }
                else if (Direction == Direction.E)
                {
                    newX++;
                }
                else if (Direction == Direction.W)
                {
                    newX--;
                }

                if (!ValidateRoverCoordinates(newX, newY))
                {
                    return false;
                }

                CoordX = newX;
                CoordY = newY;
            }
            else
            {
                Direction = Util.MoveCompass(Direction, navCommand);
            }

            return true;
        }
Exemplo n.º 28
0
 public abstract void ValidateCommand(NavigationCommand? value);
Exemplo n.º 29
0
 /// <summary>
 /// Performs the requested sequencing/navigation using SCORM 2004 sequencing/navigation rules.
 /// </summary>
 /// <param name="command">The navigation command to perform.</param>
 /// <param name="destination"><c>Activity</c> that is the destination of a Choice navigation command.</param>
 /// <returns>True if the sequencing session has ended.</returns>
 /// <exception cref="SequencingException">Occurs when there is an invalid navigation performed.</exception>
 public abstract bool OverallSequencingProcess(NavigationCommand command, Activity destination);
Exemplo n.º 30
0
 /// <summary>
 /// Performs the requested sequencing/navigation using SCORM 2004 sequencing/navigation rules.
 /// </summary>
 /// <param name="command">The navigation command to perform.</param>
 /// <param name="destination"><c>Activity</c> that is the destination of a Choice navigation command.</param>
 /// <returns>True if the sequencing session has ended.</returns>
 /// <remarks>Corresponds to OP.1 in the SCORM 2004 Sequencing/Navigation manual, appendix C.</remarks>
 /// <exception cref="SequencingException">Occurs when there is an invalid navigation performed.</exception>
 public override bool OverallSequencingProcess(NavigationCommand command, Activity destination)
 {
     SequencingRequest? seqRequest;
     TerminationRequest? termRequest;
     Activity deliveryRequest = null;
     bool exitSession;
     Resources.Culture = LocalizationManager.GetCurrentCulture();
     m_command = command;
     ProcessNavigationRequest(destination, out seqRequest, out termRequest);
     if(termRequest != null)
     {
         SequencingRequest? newSeqRequest;
         newSeqRequest = ProcessTerminationRequest(termRequest.Value);
         if(newSeqRequest != null)
         {
             seqRequest = newSeqRequest;
         }
     }
     if(seqRequest != null)
     {
         ProcessSequencingRequest(seqRequest.Value, destination, out deliveryRequest, out exitSession);
         if(exitSession)
         {
             m_navigator.CurrentActivity = null;
             m_navigator.LogSequencing(SequencingEventType.FinalNavigation, m_command, Resources.NavigationFinishedDone);
             return true;
         }
     }
     if(deliveryRequest != null)
     {
         ProcessDeliveryRequest(deliveryRequest);
         ContentDeliveryEnvironment(deliveryRequest);
         m_navigator.LogSequencing(SequencingEventType.FinalNavigation, m_command, Resources.NavigationFinishedNewActivity, deliveryRequest.Key);
     }
     else
     {
         m_navigator.LogSequencing(SequencingEventType.FinalNavigation, m_command, Resources.NavigationFinishedDone);
     }
     return false;
 }
Exemplo n.º 31
0
 /// <summary>
 /// Provides a hook to log sequencing messages.
 /// </summary>
 /// <param name="eventType">The type of sequencing event.</param>
 /// <param name="command">The actual navigation command that initiated this event.</param>
 /// <param name="message">A string to be logged.</param>
 /// <param name="args">Arguments that may be supplied to the string to be logged.</param>
 public virtual void LogSequencing(SequencingEventType eventType, NavigationCommand command, string message, params object[] args)
 {
 }
Exemplo n.º 32
0
 /// <summary>
 /// Performs a full SCORM 2004 or SCORM 1.2 navigation on the current activity tree.
 /// </summary>
 /// <param name="command">The navigation command to perform.</param>
 /// <param name="destination">The destination activity for choice navigation.</param>
 /// <returns>True if the attempt is completed and should not be returned to.</returns>
 protected bool Navigate(NavigationCommand command, Activity destination)
 {
     if(m_seqNav == null)
     {
         if(m_packageFormat == PackageFormat.V1p2 || m_packageFormat == PackageFormat.Lrm)
         {
             m_seqNav = new Scorm12SeqNav(this);
         }
         else
         {
             m_seqNav = new Scorm2004SeqNav(this);
         }
     }
     return m_seqNav.OverallSequencingProcess(command, destination);
 }
Exemplo n.º 33
0
        public void TryMove_MoveInBounds_ReturnTrue_AssignCorrectCoords()
        {
            var plateau = new Plateau
            {
                BottomLeftCoordX = 0,
                BottomLeftCoordY = 0,
                TopRightCoordX = 5,
                TopRightCoordY = 5
            };

            var commands = new NavigationCommand[] { NavigationCommand.M, NavigationCommand.R, NavigationCommand.M, NavigationCommand.M, NavigationCommand.R };
            var rover = new MarsRover(4, 5, App.Enums.Direction.W, plateau, commands);

            var result = rover.TryMove(NavigationCommand.M);

            Assert.AreEqual(rover.CoordX, 3);
            Assert.AreEqual(rover.CoordY, 5);
            Assert.AreEqual(rover.Direction, Direction.W);
        }
Exemplo n.º 34
0
        public void TryMove_Right_ReturnTrue_KeepOldCoords_ChangeDirection()
        {
            var plateau = new Plateau
            {
                BottomLeftCoordX = 0,
                BottomLeftCoordY = 0,
                TopRightCoordX = 5,
                TopRightCoordY = 5
            };

            var commands = new NavigationCommand[] { NavigationCommand.M, NavigationCommand.R, NavigationCommand.M, NavigationCommand.M, NavigationCommand.R };
            var rover = new MarsRover(4, 5, App.Enums.Direction.N, plateau, commands);

            var result = rover.TryMove(NavigationCommand.R);

            Assert.AreEqual(rover.CoordX, 4);
            Assert.AreEqual(rover.CoordY, 5);
            Assert.AreEqual(rover.Direction, Direction.E);
        }
Exemplo n.º 35
0
        /// <summary>
        /// Indicates whether a navigation would be valid if it were to be performed.
        /// </summary>
        /// <param name="command">The navigation command to test.</param>
        /// <param name="activity">The destination activity, if this is a choice navigation.</param>
        /// <returns>True if the navigation would be valid, false otherwise.</returns>
        /// <remarks>
        /// <para>
        /// This makes a partial copy of the activity tree for processing and attempts to
        /// perform a navigation on that copy.  This may result in poor performance if this 
        /// is called many times, but the alternative is to duplicate most of the sequencing
        /// code with lots of special cases for changes of state that should have happened but 
        /// could not because of the temporary nature of this request.  This makes it a 
        /// maintenance nightmare, for something that should only rarely be called anyway 
        /// except in the case of <Mth>LoadTableOfContents</Mth>.
        /// </para>
        /// <para>
        /// The case of <Mth>LoadTableOfContents</Mth> is tough, but steps are taken within
        /// that method to reduce the number of calls to this method to a bare minimum.
        /// </para>
        /// </remarks>
        protected bool IsNavigationValid(NavigationCommand command, Activity activity)
        {
            SeqNav seqNav;

            try
            {
                NavigatorData clone = CloneForNavigationTest();
                Activity destination;

                if(activity != null)
                {
                    destination = clone.Activities[activity.ActivityId];
                }
                else
                {
                    destination = null;
                }
                if(m_packageFormat == PackageFormat.V1p3)
                {
                    seqNav = new Scorm2004SeqNav(clone);
                }
                else
                {
                    seqNav = new Scorm12SeqNav(clone);
                }
                seqNav.OverallSequencingProcess(command, destination);
            }
            catch(SequencingException)
            {
                // if there was a sequencing exception,
                // this is a failure condition.
                return false;
            }
            return true;
        }
Exemplo n.º 36
0
 /// <summary>
 /// Any valid enum value is valid.
 /// </summary>
 /// <param name="value">The value to validate.</param>
 public override void ValidateCommand(NavigationCommand? value)
 {
     switch(value)
     {
     // these are all valid values
     case null:
     case NavigationCommand.Abandon:
     case NavigationCommand.AbandonAll:
     case NavigationCommand.ChoiceStart:
     case NavigationCommand.Choose:
     case NavigationCommand.Continue:
     case NavigationCommand.ExitAll:
     case NavigationCommand.None:
     case NavigationCommand.Previous:
     case NavigationCommand.ResumeAll:
     case NavigationCommand.Start:
     case NavigationCommand.SuspendAll:
     case NavigationCommand.UnqualifiedExit:
         break;
     default:
         throw new ArgumentOutOfRangeException("value");
     }
 }
Exemplo n.º 37
0
        /// <summary>
        /// Determines if the passed navigation command is valid to execute or not.
        /// </summary>
        /// <param name="command">The navigation command to test.</param>
        /// <returns>True if the navigation would succeed, false otherwise.</returns>
        /// <exception cref="ArgumentOutOfRangeException">The command passed is not a valid enumeration value, or is equal to NavigationCommand.Choose.</exception>
	    public abstract bool IsNavigationValid(NavigationCommand command);
Exemplo n.º 38
0
 /// <summary>
 /// Performs any navigation request, except for Choice navigation.
 /// </summary>
 /// <param name="command">Navigation command to execute.</param>
 /// <exception cref="SequencingException">Thrown if the navigation fails because a sequencing rule failed.</exception>
 /// <exception cref="ArgumentOutOfRangeException">The command passed is not a valid enumeration value, or is equal to NavigationCommand.Choose.</exception>
 public abstract void Navigate(NavigationCommand command);
Exemplo n.º 39
0
 /// <summary>
 /// This is invalid for SCORM 1.2
 /// </summary>
 /// <param name="value">The value to validate</param>
 public override void ValidateCommand(NavigationCommand? value)
 {
     throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.OnlyValidForSCORMV1p3, "Command"));
 }
Exemplo n.º 40
0
 /// <summary>
 /// Performs the requested sequencing/navigation using SCORM 1.2 sequencing/navigation rules.
 /// </summary>
 /// <param name="command">The navigation command to perform.</param>
 /// <param name="destination"><c>Activity</c> that is the destination of a Choice navigation command.</param>
 /// <returns>True if the sequencing session has ended.</returns>
 /// <exception cref="SequencingException">Occurs when there is an invalid navigation performed.</exception>
 public override bool OverallSequencingProcess(NavigationCommand command, Activity destination)
 {
     switch(command)
     {
     case NavigationCommand.Abandon:
         Abandon();
         break;
     case NavigationCommand.AbandonAll:
         AbandonAll();
         return true;
     case NavigationCommand.Choose:
         Choose(destination);
         break;
     case NavigationCommand.Continue:
         Continue();
         break;
     case NavigationCommand.ExitAll:
         ExitAll();
         return true;
     case NavigationCommand.Previous:
         Previous();
         break;
     case NavigationCommand.ResumeAll:
         ResumeAll();
         break;
     case NavigationCommand.Start:
         Start();
         break;
     case NavigationCommand.SuspendAll:
         SuspendAll();
         return true;
     case NavigationCommand.UnqualifiedExit:
         UnqualifiedExit();
         break;
     default:
         throw new LearningComponentsInternalException("SSN0001");
     }
     return false;
 }