/// <summary> /// Gets the client configuration. /// </summary> protected virtual IgniteClientConfiguration GetClientConfiguration() { var port = _enableSsl ? 11110 : IgniteClientConfiguration.DefaultPort; return(new IgniteClientConfiguration { Endpoints = new List <string> { IPAddress.Loopback + ":" + port }, SocketTimeout = TimeSpan.FromSeconds(15), Logger = new ListLogger(new ConsoleLogger { MinLevel = LogLevel.Trace }), SslStreamFactory = _enableSsl ? new SslStreamFactory { CertificatePath = Path.Combine("Config", "Client", "thin-client-cert.pfx"), CertificatePassword = "******", SkipServerCertificateValidation = true, CheckCertificateRevocation = true, #if !NETCOREAPP SslProtocols = SslProtocols.Tls #else SslProtocols = SslProtocols.Tls12 #endif }
public void SetUp() { var greetingsConfig = new GreetingsConfig { Displays = new Displays { GreetPrefix = "Hello", GreetSuffix = "Bye" }, Toggles = new Toggles { ShowSecret = true } }; greetingsConfigOptions = A.Fake <IOptions <GreetingsConfig> >(); secrets = new Secrets { MySecret = "My Secret" }; A.CallTo(() => greetingsConfigOptions.Value).Returns(greetingsConfig); greetRepository = A.Fake <IGreetRepository>(); A.CallTo(() => greetRepository.PersonalInfo(TestName)).Returns("Personal Info"); log = new ListLogger <GreetService>(); greetService = new GreetService(greetRepository, greetingsConfigOptions, secrets, log); }
public async void function_http_trigger_should_return_401_if_SonarqubeSecretValidator_rejects_request() { // Arrange SetEnvironmentVariables(); var request = TestFactory.CreateHttpRequest(); var sonarqubeSecretValidator = new Mock <ISonarqubeSecretValidator>(); sonarqubeSecretValidator.Setup(x => x.IsValidSignature( request, It.IsAny <string>(), Environment.GetEnvironmentVariable(SonarqubeMSTeamsBridge.Setting_SonarqubeWebhookSecret)) ).Returns(false); var sonarqubeMSTeamsBridgeFunction = new SonarqubeMSTeamsBridge(null, sonarqubeSecretValidator.Object, null, null); ListLogger logger = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List); // Act var response = (StatusCodeResult)await sonarqubeMSTeamsBridgeFunction.Run(request, logger); // Assert Assert.Equal(401, response.StatusCode); Assert.Contains($"Sonarqube secret http header is missing or not valid. Config setting {SonarqubeMSTeamsBridge.Setting_SonarqubeWebhookSecret} must match secret in Sonarqube Webhook header {SonarqubeSecretValidator.SonarqubeAuthSignatureHeaderName}.", logger.Logs); }
/// <summary> /// Gets the client configuration. /// </summary> private static IgniteClientConfiguration GetClientConfiguration(ListLogger logger) { return(new IgniteClientConfiguration(IPAddress.Loopback.ToString()) { Logger = logger }); }
/// <summary> /// Constructor is called for every test. It is passed the fixtures, which are instantiated only once, just /// before the first test is run, to set the environment variables used by the test /// </summary> /// <param name="contactCreationFixture"></param> public CrmUpdateTests(TestContactCreationFixture contactCreationFixture, EnvironmentSetupFixture environmentSetupFixture) { this.contactCreationFixture = contactCreationFixture; this.environmentSetupFixture = environmentSetupFixture; this._errorQueue = new TestableAsyncCollector <string>(); this._logger = new ListLogger(); }
/// <summary> /// Initializes a new instance of the <see cref="SendWorkOrderAckTests"/> class. /// </summary> public SendWorkOrderAckTests() { // mock services passed to Function class constructor this.iconicsServiceMock = new Mock <IIconicsService>(); this.validationServiceMock = new Mock <IValidationService>(); this.errorQueueServiceMock = new Mock <IErrorQueueService>(); this.logger = LoggerFactory.CreateLogger(); }
internal void PostConstructorInitialize(ListLogger log) { if (log == null) { throw new ArgumentNullException(nameof(log)); } _log = _log ?? log; }
/// <summary> /// Initializes a new instance of the <see cref="CircuitBreakerActorTests"/> class. /// </summary> public CircuitBreakerActorTests() { Environment.SetEnvironmentVariable("WindowSize", "00:01:00"); Environment.SetEnvironmentVariable("FailureThreshold", "2"); // mock services passed to Function class constructor this.durableClientMock = new Mock <IDurableClient>(); this.logger = LoggerFactory.CreateLogger(); }
public void AddOneLogger() { ListLogger a = new ListLogger(); Logger.Add("a", a); Logger.Count.Should().Be(1); Logger.Contains("a").Should().BeTrue(); Logger.Get("a").Should().BeSameAs(a); }
public void KnowledgeableDeveRealizarLog() { var mensagemEsperada = "Timer trigger executada as"; var logger = new ListLogger(); knowledgeable.knowledgeable.RunAsync(null, logger); var mensagemLog = logger.Logs[0]; mensagemLog.Should().Contain(mensagemEsperada); }
protected override void OnTearDown() { base.OnTearDown(); webServiceClient = null; listLogger = null; if (repository != null) { repository.Dispose(); repository = null; } }
public void Close() { Logger.Info("hello"); Logger.Info("moto"); Logger.Close(); for (int i = 1; i <= LoggerCount; i++) { ListLogger lister = (ListLogger)Logger.Get(i.ToString()); lister.Messages.Count.Should().Be(2); } }
public void LogByLevel(string level) { const string message = "Message text!"; Logger.GetType().GetMethod(level).Invoke(Logger, new object[] { message }); for (int i = 1; i <= LoggerCount; i++) { ListLogger lister = (ListLogger)Logger.Get(i.ToString()); lister.Messages[0].Should().MatchRegex(MessageFormatTest.TimePattern).And.EndWith($"[{level.ToUpper()}] {message}"); } }
public void RemoveLogger() { ListLogger a = new ListLogger(); ListLogger b = new ListLogger(); Logger.Add("a", a); Logger.Add("b", b); bool removed = Logger.Remove("a"); removed.Should().BeTrue(); Logger.Count.Should().Be(1); Logger.Contains("a").Should().BeFalse(); Logger.Contains("b").Should().BeTrue(); }
public void AddTwoLoggers() { ListLogger a = new ListLogger(); ListLogger b = new ListLogger(); Logger.Add("a", a); Logger.Add("b", b); Logger.Count.Should().Be(2); Logger.Contains("a").Should().BeTrue(); Logger.Contains("b").Should().BeTrue(); Logger.Get("a").Should().BeSameAs(a); Logger.Get("b").Should().BeSameAs(b); }
public void AttemptToRemoveNonexistentLogger() { ListLogger a = new ListLogger(); ListLogger b = new ListLogger(); Logger.Add("a", a); Logger.Add("b", b); bool removed = Logger.Remove("c"); removed.Should().BeFalse(); Logger.Count.Should().Be(2); Logger.Contains("a").Should().BeTrue(); Logger.Contains("b").Should().BeTrue(); }
/// <summary> /// Initializes a new instance of the <see cref="CreateAlertFromIconicsFaultTests"/> class. /// </summary> public CreateAlertFromIconicsFaultTests() { Environment.SetEnvironmentVariable("ResourceId", "ResourceId"); Environment.SetEnvironmentVariable("CircuitRequestUri", "http://localhost/api/CircuitBreakerActor/AddFailure"); Environment.SetEnvironmentVariable("AppName", "AppName"); Environment.SetEnvironmentVariable("CircuitCode", "CircuitCode"); // mock services passed to Function class constructor this.dynamicsEntityServiceMock = new Mock <IDynamicsEntityService>(); this.validationServiceMock = new Mock <IValidationService>(); this.errorQueueServiceMock = new Mock <IErrorQueueService>(); this.httpClientMock = new Mock <HttpClient>(); this.logger = LoggerFactory.CreateLogger(); }
public void LogArtifact() { const string type = "Screenshot"; const string path = "path/to/screen.png"; Logger.LogArtifact(type, path); for (int i = 1; i <= LoggerCount; i++) { ListLogger lister = (ListLogger)Logger.Get(i.ToString()); lister.Messages.Count.Should().Be(1); lister.Messages[0].Should().MatchRegex(MessageFormatTest.TimePattern).And.EndWith($"[INFO] {type}: {path}"); } }
public static ILogger CreateLogger(LoggerTypes type = LoggerTypes.Null) { ILogger logger; if (type == LoggerTypes.List) { logger = new ListLogger(); } else { logger = NullLoggerFactory.Instance.CreateLogger("Null Logger"); } return(logger); }
/// <summary> /// Gets client request names from a given logger. /// </summary> protected static IEnumerable <string> GetServerRequestNames(ListLogger logger, string prefix = null) { // Full request class name examples: // org.apache.ignite.internal.processors.platform.client.binary.ClientBinaryTypeGetRequest // org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetRequest var messageRegex = new Regex( @"Client request received \[reqId=\d+, addr=/127.0.0.1:\d+, " + @"req=org\.apache\.ignite\.internal\.processors\.platform\.client\..*?" + prefix + @"(\w+)Request@"); return(logger.Entries .Select(m => messageRegex.Match(m.Message)) .Where(m => m.Success) .Select(m => m.Groups[1].Value)); }
public async void function_http_trigger_should_return_500_if_teamswebhook_config_is_missing() { // Arrange SetEnvironmentVariables(teamsWebhookUrl: null); var request = TestFactory.CreateHttpRequest(); var sonarqubeMSTeamsBridgeFunction = new SonarqubeMSTeamsBridge(null, null, null, null); ListLogger logger = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List); // Act var response = (StatusCodeResult)await sonarqubeMSTeamsBridgeFunction.Run(request, logger); // Assert Assert.Equal(500, response.StatusCode); Assert.Contains($"Required setting {SonarqubeMSTeamsBridge.Setting_TeamsWebhookUrl} is missing.", logger.Logs); }
protected override void OnSetUp() { base.OnSetUp(); database = new SimpleAmplaDatabase(); database.EnableModule(module); configuration = new SimpleAmplaConfiguration(); configuration.EnableModule(module); foreach (string location in locations) { configuration.AddLocation(module, location); } configuration.SetDefaultView(module, getViewFunc()); webServiceClient = new SimpleDataWebServiceClient(database, configuration, new SimpleSecurityWebServiceClient("User")); listLogger = new ListLogger(); repository = new AmplaRepository <TModel>(new LoggingDataWebServiceClient(webServiceClient, listLogger), CredentialsProvider.ForUsernameAndPassword(userName, password)); }
/// <summary></summary> public App() { InitializeComponent(); // register a singleton logger but as 2 different types ListLogger logger = new ListLogger("iOS", LogLevel.All); DependencyService.RegisterSingleton <ILogRepository>(logger); DependencyService.RegisterSingleton <ILogger>(logger); // register the back-end service as a singleton // we can register a mock here based on some startup setting //DependencyService.RegisterSingleton<IDataStore<GasStation>>( new MockDataStore() ); GasService gs = new GasService(APIBaseURL, FunctionKey); gs.Logger = logger; DependencyService.RegisterSingleton <IDataStore <GasStation> >(gs); // create the main page MainPage = new MainPage(); }
public async void function_http_trigger_should_return_200_if_valid_request_and_message_was_sent_to_msteams() { // Arrange SetEnvironmentVariables(); var request = TestFactory.CreateHttpRequest(); var sonarqubeSecretValidator = new Mock <ISonarqubeSecretValidator>(); sonarqubeSecretValidator.Setup(x => x.IsValidSignature( request, It.IsAny <string>(), Environment.GetEnvironmentVariable(SonarqubeMSTeamsBridge.Setting_SonarqubeWebhookSecret)) ).Returns(true); var sonarqubeToMSTeamsFilter = new Mock <ISonarqubeToMSTeamsFilter>(); sonarqubeToMSTeamsFilter.Setup(x => x.ShouldProcess( It.IsAny <object>(), It.IsAny <string>()) ).Returns(true); var sonarqubeToMSTeamsConverterMock = new Mock <ISonarqubeToMSTeamsConverter>(); sonarqubeToMSTeamsConverterMock.Setup(x => x.ToComplexCard( It.IsAny <object>(), It.IsAny <string>()) ).Returns(new MSTeamsComplexCard()); var httpClient = new HttpClient(new VoidOkHttpMessageHandler()); var sonarqubeMSTeamsBridgeFunction = new SonarqubeMSTeamsBridge(httpClient, sonarqubeSecretValidator.Object, sonarqubeToMSTeamsConverterMock.Object, sonarqubeToMSTeamsFilter.Object); ListLogger logger = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List); // Act var response = (StatusCodeResult)await sonarqubeMSTeamsBridgeFunction.Run(request, logger); // Assert Assert.Equal(200, response.StatusCode); }
public BotRunner(RPGClient c, BotConfig cfg, AddBotConfig add, string account) { this.log = new ListLogger("bot[" + account + "]-"); this.cfg = cfg; this.add = add; this.account = account; this.client = c; this.client.OnGateEntered += on_gate_connect_callback; this.client.GateClient.Listen <ClientEnterGateInQueueNotify>(on_gate_in_queue); foreach (var type in BotFactory.Instance.GetModuleTypes()) { var m = ReflectionUtil.CreateInterface <BotModule>(type, this); modules.Add(m.GetType(), m); } client.AddTimePeriodicMS(10000, (e) => { if (client.CurrentZoneLayer != null && client.GameClient != null && client.GameClient.IsHandshake) { client.GameClient.Request <ClientPong>(new ClientPing(), (s, a) => { }); } }); }
public void TestClientDisposalStopsReceiverThread([Values(true, false)] bool async) { Ignition.Start(TestUtils.GetTestConfiguration()); var logger = new ListLogger { EnabledLevels = new[] { LogLevel.Trace } }; var cfg = new IgniteClientConfiguration(GetClientConfiguration()) { Logger = logger }; using (var client = Ignition.StartClient(cfg)) { var cache = client.GetOrCreateCache <int, int>("c"); if (async) { cache.PutAsync(1, 1); } else { cache.Put(1, 1); } } var threadId = logger.Entries .Select(e => Regex.Match(e.Message, "Receiver thread #([0-9]+) started.")) .Where(m => m.Success) .Select(m => int.Parse(m.Groups[1].Value)) .First(); TestUtils.WaitForTrueCondition(() => logger.Entries.Any( e => e.Message == string.Format("Receiver thread #{0} stopped.", threadId))); }
public void Test2() { var container = new Container(); container.Register <IService, Service>(setup: Setup.With(trackDisposableTransient: true)); var logger = new ListLogger { Messages = new List <string>() }; container.RegisterInstance <ILogger>(logger); container.Register <Service1>(); container.Register <Service2>(); container.Register <Service3>(); using (var scope = container.OpenScope()) { var s = scope.Resolve <IService>(); } Assert.AreEqual("disposed", logger.Messages[0]); }
public ClassWithAlwaysCompletedAsync(ListLogger log) { _log = log ?? throw new ArgumentNullException(nameof(log)); }
public void InitListLogger() { Logger = new ListLogger(); }
/// <summary> /// Initializes a new instance of the <see cref="OpenCircuitOrchestratorTests"/> class. /// </summary> public OpenCircuitOrchestratorTests() { // mock services passed to Function class constructor this.durableOrchestrationContextMock = new Mock <IDurableOrchestrationContext>(); this.logger = LoggerFactory.CreateLogger(); }
public ListLoggerFactory(List<string> logStatements) { logger = new ListLogger(logStatements); }