Exemple #1
0
        public void Setup()
        {
            serviceProvider = new ServiceCollection().BuildBase()
                              .AddSingleton(A.Fake <ClientService>())
                              .AddSingleton <IScriptCommandFactory, ScriptCommandFactory>()
                              .AddSingleton(A.Fake <IScriptPluginServiceResolver>())
                              .BuildServiceProvider();
            fakeManager      = serviceProvider.GetRequiredService <IManager>();
            mockEventHandler = serviceProvider.GetRequiredService <EventHandlerMock>();

            var rconConnectionFactory = serviceProvider.GetRequiredService <IRConConnectionFactory>();

            A.CallTo(() => rconConnectionFactory.CreateConnection(A <string> .Ignored, A <int> .Ignored, A <string> .Ignored))
            .Returns(serviceProvider.GetRequiredService <IRConConnection>());

            A.CallTo(() => serviceProvider.GetRequiredService <IRConParser>().Configuration)
            .Returns(ConfigurationGenerators.CreateRConParserConfiguration(serviceProvider.GetRequiredService <IParserRegexFactory>()));

            A.CallTo(() => fakeManager.AddEvent(A <GameEvent> .Ignored))
            .Invokes((fakeCall) => mockEventHandler.HandleEvent(fakeManager, fakeCall.Arguments[0] as GameEvent));
        }
Exemple #2
0
        public void Setup()
        {
            serviceProvider = new ServiceCollection().BuildBase().BuildServiceProvider();

            fakeLogger         = serviceProvider.GetRequiredService <ILogger>();
            fakeManager        = serviceProvider.GetRequiredService <IManager>();
            fakeRConConnection = serviceProvider.GetRequiredService <IRConConnection>();
            fakeRConParser     = serviceProvider.GetRequiredService <IRConParser>();
            mockEventHandler   = serviceProvider.GetRequiredService <EventHandlerMock>();
            appConfig          = serviceProvider.GetRequiredService <ApplicationConfiguration>();

            var rconConnectionFactory = serviceProvider.GetRequiredService <IRConConnectionFactory>();

            A.CallTo(() => rconConnectionFactory.CreateConnection(A <string> .Ignored, A <int> .Ignored, A <string> .Ignored))
            .Returns(fakeRConConnection);

            A.CallTo(() => fakeRConParser.Configuration)
            .Returns(ConfigurationGenerators.CreateRConParserConfiguration(serviceProvider.GetRequiredService <IParserRegexFactory>()));

            A.CallTo(() => fakeManager.AddEvent(A <GameEvent> .Ignored))
            .Invokes((fakeCall) => mockEventHandler.HandleEvent(fakeManager, fakeCall.Arguments[0] as GameEvent));
        }