Settings() public method

public Settings ( ) : Mock
return Mock
示例#1
0
 private IRendererLoop getLoop(IDisplayList displayList = null, IAGSRenderPipeline pipeline = null)
 {
     displayList = displayList ?? getDisplayList();
     pipeline    = pipeline ?? getPipeline(displayList);
     return(new AGSRendererLoop(_mocks.Settings().Object, _mocks.GameState().Object,
                                new Mock <IGLUtils>().Object, new Mock <IWindowInfo>().Object, pipeline,
                                new Mock <IMatrixUpdater>().Object));
 }
示例#2
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);
        }