Game() public method

public Game ( ) : Mock
return Mock
Beispiel #1
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 #2
0
 private IRendererLoop getLoop()
 {
     _renderer = new Mock <IImageRenderer>();
     return(new AGSRendererLoop(_resolver, _mocks.Game().Object, _renderer.Object,
                                _mocks.Input().Object, new AGSWalkBehindsMap(null), _transitions.Object,
                                new Mock <IGLUtils>().Object));
 }
Beispiel #3
0
        private IRendererLoop getLoop()
        {
            _renderer = new Mock <IImageRenderer>();
            AGSDisplayList displayList = new AGSDisplayList(_mocks.GameState().Object, _mocks.Input().Object,
                                                            new AGSWalkBehindsMap(null), _renderer.Object, _events, new Mock <IAGSRoomTransitions>().Object);

            return(new AGSRendererLoop(_resolver, _mocks.Game().Object, _renderer.Object,
                                       _transitions.Object, new Mock <IGLUtils>().Object, new Mock <IGameWindow>().Object,
                                       new AGSEvent <DisplayListEventArgs>(), displayList, new Mock <IInput>().Object, new Mock <IMatrixUpdater>().Object));
        }
Beispiel #4
0
        public static IEnumerable <IObject> GetImplementors(Mocks mocks, Mock <IGameState> stateMock, IGameState state = null)
        {
            if (state == null && stateMock != null)
            {
                state = stateMock.Object;
            }
            mocks.Game().Setup(g => g.State).Returns(state);
            stateMock?.Setup(s => s.UI).Returns(new AGSConcurrentHashSet <IObject>());
            Mock <IInput> input    = new Mock <IInput>();
            Resolver      resolver = GetResolver();

            input.Setup(i => i.KeyUp).Returns(new Mock <IEvent <KeyboardEventArgs> >().Object);
            input.Setup(i => i.KeyDown).Returns(new Mock <IEvent <KeyboardEventArgs> >().Object);
            if (stateMock != null)
            {
                stateMock.Setup(s => s.Cutscene).Returns(mocks.Cutscene().Object);
            }

            Mock <IUIEvents> uiEvents = new Mock <IUIEvents>();
            Mock <IEvent <MouseButtonEventArgs> >   buttonEvent = new Mock <IEvent <MouseButtonEventArgs> >();
            Mock <IEvent <MousePositionEventArgs> > mouseEvent  = new Mock <IEvent <MousePositionEventArgs> >();

            uiEvents.Setup(u => u.MouseClicked).Returns(buttonEvent.Object);
            uiEvents.Setup(u => u.MouseDown).Returns(buttonEvent.Object);
            uiEvents.Setup(u => u.MouseUp).Returns(buttonEvent.Object);
            uiEvents.Setup(u => u.LostFocus).Returns(buttonEvent.Object);
            uiEvents.Setup(u => u.MouseEnter).Returns(mouseEvent.Object);
            uiEvents.Setup(u => u.MouseLeave).Returns(mouseEvent.Object);
            uiEvents.Setup(u => u.MouseMove).Returns(mouseEvent.Object);

            Mock <IGraphicsFactory> graphicsFactory = new Mock <IGraphicsFactory>();
            Func <ISprite>          getSprite       = () => new AGSSprite(resolver, mocks.MaskLoader().Object);

            graphicsFactory.Setup(g => g.GetSprite()).Returns(() => getSprite());
            AGSAnimationComponent animationComponent = new AGSAnimationComponent();

            Mock <IImage>           image           = new Mock <IImage>();
            Mock <IButtonComponent> buttonComponent = new Mock <IButtonComponent>();

            buttonComponent.Setup(b => b.HoverAnimation).Returns(new ButtonAnimation(new AGSSingleFrameAnimation(getSprite())));
            buttonComponent.Setup(b => b.IdleAnimation).Returns(new ButtonAnimation(new AGSSingleFrameAnimation(getSprite())));
            buttonComponent.Setup(b => b.PushedAnimation).Returns(new ButtonAnimation(new AGSSingleFrameAnimation(getSprite())));
            Mock <IAudioSystem>     audioSystem  = new Mock <IAudioSystem>();
            Mock <IRuntimeSettings> settings     = mocks.Settings();
            Mock <IRenderThread>    renderThread = new Mock <IRenderThread>();
            Mock <IUpdateThread>    updateThread = new Mock <IUpdateThread>();

            renderThread.Setup(u => u.RunBlocking(It.IsAny <Action>())).Callback <Action>(a => a());
            updateThread.Setup(u => u.RunBlocking(It.IsAny <Action>())).Callback <Action>(a => a());

            resolver.Builder.RegisterInstance(input.Object);
            resolver.Builder.RegisterInstance(state);
            resolver.Builder.RegisterInstance(uiEvents.Object);
            resolver.Builder.RegisterInstance(animationComponent).As <IAnimationComponent>();
            resolver.Builder.RegisterInstance(buttonComponent.Object);
            resolver.Builder.RegisterInstance(audioSystem.Object);
            resolver.Builder.RegisterInstance(new Mock <IRenderMessagePump>().Object);
            resolver.Builder.RegisterInstance(new Mock <IUpdateMessagePump>().Object);
            resolver.Builder.RegisterInstance(renderThread.Object);
            resolver.Builder.RegisterInstance(updateThread.Object);
            resolver.Builder.RegisterInstance(new Mock <ILabelRenderer>().Object);
            resolver.Builder.RegisterInstance(new Mock <ITexture>().Object);
            resolver.Builder.RegisterInstance(mocks.MaskLoader().Object).As <IMaskLoader>();
            resolver.Builder.RegisterInstance(settings.Object).As <IGameSettings>();
            resolver.Builder.RegisterInstance(settings.Object).As <IRuntimeSettings>();
            resolver.Builder.RegisterInstance(mocks.Game().Object);
            resolver.Build();

            Func <IObject> baseObj = () => new AGSObject("Test", resolver);

            mocks.Game().Setup(g => g.Events).Returns(resolver.Container.Resolve <IGameEvents>());
            mocks.Game().Setup(g => g.Factory).Returns(resolver.Container.Resolve <IGameFactory>());

            Mock <IOutfit> outfit = new Mock <IOutfit>();

            Func <IPanel> basePanel = () => new AGSPanel("Panel", resolver, image.Object);
            Func <ILabel> baseLabel = () => new AGSLabel("Label", resolver)
            {
                LabelRenderSize = new AGS.API.SizeF(100f, 50f)
            };
            var button = new AGSButton("Button", resolver)
            {
                LabelRenderSize = new AGS.API.SizeF(100f, 50f)
            };

            List <IObject> implmentors = new List <IObject>
            {
                baseObj().Hotspot("Object"),
                new AGSCharacter("Character", resolver, outfit.Object).Hotspot("Character"),
                basePanel().Hotspot("Panel"),
                baseLabel().Hotspot("Label"),
                button.Hotspot("Button"),
                new AGSInventoryWindow("Inventory", resolver, image.Object).Hotspot("Inventory"),
                new AGSSlider("Slider", resolver, image.Object).Hotspot("Slider"),
                new AGSCheckBox("Checkbox", resolver),
                new AGSTextbox("Textbox", resolver),
                new AGSComboBox("Combobox", resolver),
            };

            return(implmentors);
        }
 private IAGSRenderPipeline getPipeline(IDisplayList displayList)
 {
     return(new AGSRenderPipeline(_mocks.GameState().Object, displayList, _mocks.Game().Object,
                                  new AGSEvent <DisplayListEventArgs>(), _mocks.RoomTransitions().Object));
 }