Example #1
0
 public void TearDown()
 {
     EventTestingUtilities.DisconnectWebots();
     EventQueue.Nao.Clear();
     EventQueue.Goal.Clear();
     EventQueue.Nao.ClearSubscribers();
 }
Example #2
0
 public void FireTest()
 {
     EventTestingUtilities.RequireWebots();
     EventQueue.Nao.Post(haltEvent);
     // check not moving
     Assert.IsFalse(Walk.Instance.IsMoving());
 }
Example #3
0
 public void Init()
 {
     Logger.Clear();
     inputStream = EventTestingUtilities.BuildStream(ExpectedID);
     goalComs.SetStream(inputStream);
     pickupEvent = new PickupEvent();
 }
Example #4
0
 public void FireTest()
 {
     EventTestingUtilities.RequireWebots();
     EventQueue.Nao.Post(goToEvent);
     EventQueue.Nao.WaitFor();
     System.Threading.Thread.Sleep(500);
     Assert.IsTrue(Walk.Instance.IsMoving());
 }
Example #5
0
 public void AbortTest()
 {
     EventTestingUtilities.RequireWebots();
     Walk.Instance.StartWalking(1, 1, 0);
     EventQueue.Nao.Suspended = true;
     EventQueue.Nao.Post(haltEvent);
     haltEvent.Abort();
     EventQueue.Nao.Suspended = false;
     System.Threading.Thread.Sleep(500);
     Assert.IsTrue(Walk.Instance.IsMoving());
 }
Example #6
0
        public void UnpackTest()
        {
            CommunicationStream stream = EventTestingUtilities.BuildStream(
                1, 15, 15
                );

            goalComs.SetStream(stream);
            goToEvent = new GoToEvent();
            List <Point> nodes = (List <Point>)EventTestingUtilities.GetInstanceField(typeof(GoToEvent), goToEvent, "locations");

            Assert.AreEqual(new Point(1, 1), nodes[0]);
        }
Example #7
0
        public void InternalErrorTest()
        {
            EventTestingUtilities.RequireWebots();

            Mock <Grabber> mock = new Mock <Grabber>()
            {
                CallBase = true
            };

            mock.Setup(m => m.HoldingObject()).Throws(new Exception());
            Grabber.Instance = mock.Object;

            EventQueue.Goal.Suspended = true;;
            EventQueue.Nao.Post(pickupEvent);
            pickupEvent.WaitFor();

            Assert.IsInstanceOf <ErrorEvent>(EventQueue.Goal.Peek(),
                                             "An internal error has been encountered, expecting an ErrorEvent.");
        }
Example #8
0
        public void ObjectAbsentTest()
        {
            EventTestingUtilities.RequireWebots();

            Mock <Grabber> mock = new Mock <Grabber>()
            {
                CallBase = true
            };

            mock.Setup(m => m.HoldingObject()).Returns(false);
            Grabber.Instance = mock.Object;

            EventQueue.Goal.Suspended = true;;
            EventQueue.Nao.Post(putdownEvent);
            putdownEvent.WaitFor();

            Assert.IsInstanceOf <FailureEvent>(EventQueue.Goal.Peek(),
                                               "The Nao was not holding an object, therefore there is nothing to put down.");
        }
Example #9
0
        public void AbortObjectHeldTest()
        {
            EventTestingUtilities.RequireWebots();

            Mock <Grabber> mock = new Mock <Grabber>()
            {
                CallBase = true
            };

            mock.Setup(m => m.HoldingObject()).Returns(true);
            Grabber.Instance = mock.Object;

            EventQueue.Goal.Suspended   = true;;
            EventQueue.Nao.EventFiring += (naoEvent => naoEvent.Abort());
            EventQueue.Nao.Post(putdownEvent);
            putdownEvent.WaitFor();
            Assert.IsInstanceOf <FailureEvent>(EventQueue.Goal.Peek(),
                                               "The event was aborted before the Nao could drop the object.");
        }
Example #10
0
        public void InternalErrorTest()
        {
            EventTestingUtilities.RequireWebots();

            Mock <Grabber> mock = new Mock <Grabber>()
            {
                CallBase = true
            };

            mock.Setup(m => m.HoldingObject()).Throws(new Exception());
            Grabber.Instance = mock.Object;

            EventQueue.Goal.Suspended = true;;
            EventQueue.Nao.Post(putdownEvent);
            putdownEvent.WaitFor();

            Assert.IsInstanceOf <ErrorEvent>(EventQueue.Goal.Peek(),
                                             "There is a serious internal error in Grabber.HoldingObject.");
        }
Example #11
0
        public void ObjectAlreadyHeldTest()
        {
            EventTestingUtilities.RequireWebots();

            Mock <Grabber> mock = new Mock <Grabber>()
            {
                CallBase = true
            };

            mock.Setup(m => m.HoldingObject()).Returns(true);
            Grabber.Instance = mock.Object;

            EventQueue.Goal.Suspended = true;;
            EventQueue.Nao.Post(pickupEvent);
            pickupEvent.WaitFor();

            Assert.IsInstanceOf <FailureEvent>(EventQueue.Goal.Peek(),
                                               "The Nao is already holding an object, therefore cannot pick up a new one.");
        }
Example #12
0
        public void ValidFireObjectNotHeldTest()
        {
            EventTestingUtilities.RequireWebots();

            Mock <Grabber> mock = new Mock <Grabber>()
            {
                CallBase = true
            };

            mock.Setup(m => m.HoldingObject()).Returns(false);
            Grabber.Instance = mock.Object;

            EventQueue.Goal.Suspended = true;;
            EventQueue.Nao.Post(pickupEvent);
            pickupEvent.WaitFor();

            Assert.IsInstanceOf <FailureEvent>(EventQueue.Goal.Peek(),
                                               "The event was executed but the Nao is not holding anything.");
        }
Example #13
0
        public void InvalidFireObjectDroppedTest()
        {
            EventTestingUtilities.RequireWebots();

            Mock <Grabber> mock = new Mock <Grabber>()
            {
                CallBase = true
            };

            mock.Setup(m => m.HoldingObject()).Returns(false);
            mock.Setup(m => m.PutDown()).Throws(new Exception());
            Grabber.Instance = mock.Object;

            EventQueue.Goal.Suspended = true;;
            EventQueue.Nao.Post(putdownEvent);
            putdownEvent.WaitFor();

            Assert.IsInstanceOf <SuccessEvent>(EventQueue.Goal.Peek(),
                                               @"The Nao caught an exception while trying to put the object down,
                but it still dropped the object. Therefore, expect success.");
        }
Example #14
0
        public void InvalidFireObjectHeldTest()
        {
            EventTestingUtilities.RequireWebots();

            Mock <Grabber> mock = new Mock <Grabber>()
            {
                CallBase = true
            };

            mock.Setup(m => m.HoldingObject()).Returns(true);
            mock.Setup(m => m.PutDown()).Throws(new Exception());
            Grabber.Instance = mock.Object;

            EventQueue.Goal.Suspended = true;;
            EventQueue.Nao.Post(putdownEvent);
            putdownEvent.WaitFor();

            Assert.IsInstanceOf <FailureEvent>(EventQueue.Goal.Peek(),
                                               @"The Nao caught an exception while trying to put the object down,
                and still holds it at the end.");
        }
Example #15
0
        public void ValidFireObjectHeldTest()
        {
            EventTestingUtilities.RequireWebots();

            Mock <Grabber> mock = new Mock <Grabber>()
            {
                CallBase = true
            };
            int callCounter = 0;

            mock.Setup(m => m.HoldingObject())
            .Returns(() => callCounter > 0)
            .Callback(() => callCounter++);
            Grabber.Instance = mock.Object;

            EventQueue.Goal.Suspended = true;;
            EventQueue.Nao.Post(pickupEvent);
            pickupEvent.WaitFor();

            Assert.IsInstanceOf <SuccessEvent>(EventQueue.Goal.Peek(),
                                               "The event was successfully executed.");
        }
Example #16
0
 public void TearDown()
 {
     goalComs.SetStream(emptyStream);
     EventTestingUtilities.DisconnectWebots();
 }
Example #17
0
 public void initOnce()
 {
     emptyStream = EventTestingUtilities.BuildStream();
     goalComs    = new GoalComsStub(emptyStream);
 }
Example #18
0
 public void TearDown()
 {
     EventTestingUtilities.DisconnectWebots();
 }