GameState() public method

public GameState ( ) : Mock
return Mock
Beispiel #1
0
        public async Task RoomProperlyRendered_Test()
        {
            int threadID = AGSGame.UIThreadID;

            AGSGame.UIThreadID = Environment.CurrentManagedThreadId;
            try
            {
                _mocks.Room().Setup(m => m.ShowPlayer).Returns(false);
                AGSViewport viewport = new AGSViewport(new AGSDisplayListSettings(), new AGSCamera());
                viewport.RoomProvider = new AGSSingleRoomProvider(_mocks.Room().Object);
                _mocks.GameState().Setup(m => m.Viewport).Returns(viewport);
                _areas.Clear(); _areas.Add(getArea());
                _roomObjects.Clear(); _roomObjects.Add(_mocks.Object(true).Object);
                _uiObjects.Clear(); _uiObjects.Add(_mocks.Object(true).Object);

                IRendererLoop loop = getLoop();
                Assert.IsTrue(loop.Tick()); //First tick just to tell the display list about our viewport, the second tick will have the objects to render
                await _events.OnRepeatedlyExecute.InvokeAsync();

                Assert.IsTrue(loop.Tick());
                _renderer.Verify(r => r.Render(It.IsAny <IObject>(), It.IsAny <IViewport>()), Times.Exactly(2));
            }
            finally
            {
                AGSGame.UIThreadID = threadID;
            }
        }
        public void EmptyRoom_NotError_Test()
        {
            _mocks.Room().Setup(m => m.ShowPlayer).Returns(false);
            _mocks.GameState().Setup(m => m.GetSortedViewports()).Returns(new List <IViewport> {
                _mocks.GameState().Object.Viewport
            });
            _areas.Clear();
            _roomObjects.Clear();
            _uiObjects.Clear();

            IRendererLoop loop = getLoop();

            Assert.IsTrue(loop.Tick());
        }
 private IEnumerable <IAnimationComponent> getImplementors()
 {
     foreach (var container in ObjectTests.GetImplementors(_mocks, _mocks.GameState()))
     {
         yield return(container);
     }
 }
Beispiel #4
0
        public static Mocks Init()
        {
            ContainerBuilder builder = new ContainerBuilder();
            Mocks            mocks   = new Mocks();

            builder.RegisterInstance(mocks.Animation().Object);
            builder.RegisterInstance(mocks.AnimationState().Object);
            builder.RegisterInstance(mocks.GameState().Object);
            builder.RegisterInstance(mocks.Game().Object);
            builder.RegisterInstance(mocks.Player().Object);
            builder.RegisterInstance(mocks.Character().Object);
            builder.RegisterInstance(mocks.Room().Object);
            builder.RegisterInstance(mocks.Object().Object);
            builder.RegisterInstance(mocks.Viewport().Object);
            builder.RegisterInstance(mocks.Sprite().Object);
            builder.RegisterInstance(mocks.Image().Object);
            builder.RegisterInstance(mocks.Input().Object);
            builder.RegisterInstance(mocks.Cutscene().Object);
            builder.RegisterInstance(mocks.RoomTransitions().Object);
            builder.RegisterInstance(mocks.AudioSystem().Object);
            builder.RegisterInstance(new Mock <IRenderMessagePump> ().Object);
            builder.RegisterInstance(new Mock <IUpdateMessagePump>().Object);
            builder.RegisterInstance(new Mock <IGameEvents>().Object);
            builder.RegisterInstance(new Mock <IDisplayList>().Object);
            builder.RegisterSource(new AnyConcreteTypeNotAlreadyRegisteredSource());

            mocks.container = builder.Build();

            return(mocks);
        }
Beispiel #5
0
        public async Task ChangeRoom_WhenNotInRoom_Test()
        {
            Mock <IGameState>      state = _mocks.GameState();
            AGSBindingList <IRoom> rooms = new AGSBindingList <IRoom> (10);

            state.Setup(s => s.Rooms).Returns(rooms);

            foreach (IObject obj in GetImplementors(_mocks, state))
            {
                rooms.Clear();
                IRoom room = _mocks.Room(true).Object;
                rooms.Add(room);
                await obj.ChangeRoomAsync(room);

                Assert.AreEqual(room, obj.Room, "Room not changed for " + obj.Hotspot ?? "null");
                Assert.IsNull(obj.PreviousRoom, "Prev room not null for " + obj.Hotspot ?? "null");
            }
        }
        public void Init()
        {
            _mocks    = Mocks.Init();
            _resolver = Mocks.GetResolver();
            _resolver.Build();

            _areas       = new AGSBindingList <IArea>(1);
            _roomObjects = new AGSConcurrentHashSet <IObject>();
            _uiObjects   = new AGSConcurrentHashSet <IObject>();

            var room = _mocks.Room();

            room.Setup(m => m.Objects).Returns(_roomObjects);
            room.Setup(m => m.Areas).Returns(_areas);
            room.Setup(m => m.Background).Returns(() => null);
            _mocks.GameState().Setup(s => s.UI).Returns(_uiObjects);
        }
Beispiel #7
0
        public void Init()
        {
            _mocks       = Mocks.Init();
            _transitions = new Mock <IAGSRoomTransitions>();
            _resolver    = Mocks.GetResolver();
            _resolver.Build();

            _areas       = new AGSBindingList <IArea>(1);
            _roomObjects = new AGSConcurrentHashSet <IObject>();
            _uiObjects   = new AGSConcurrentHashSet <IObject>();
            _events      = _resolver.Container.Resolve <IGameEvents>(); //new AGSGameEvents(null, new AGSEvent(), null, null, null, null, _resolver);

            var room = _mocks.Room();

            room.Setup(m => m.Objects).Returns(_roomObjects);
            room.Setup(m => m.Areas).Returns(_areas);
            room.Setup(m => m.Background).Returns(() => null);
            _mocks.GameState().Setup(s => s.UI).Returns(_uiObjects);
        }