public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(ServiceAuthenticationHelperVersion2Test).FullName); _httpClientMock = new Mock <IHttpClient>(); ServiceAuthenticationHelper.HttpClient = _httpClientMock.Object; ServiceAuthenticationHelper.ClearCache(); _authenticationHelper = new ServiceAuthenticationHelper(); _clientConfigurations = new List <ClientConfiguration> { new ClientConfiguration { Name = ClientName, Authentication = "Default" } }; _authentications = new List <ClientAuthorizationSettings> { new ClientAuthorizationSettings { Id = "Default", AuthorizationType = ClientAuthorizationSettings.AuthorizationTypeEnum.Basic, Username = "******", Password = "******" } }; CreateLeverConfiguration(); }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(nameof(ManyToOneTest)); var connectionString = TestSettings.ConnectionString; FulcrumAssert.IsNotNullOrWhiteSpace(connectionString); var manyTableMetadata = new SqlTableMetadata { TableName = "TestItem", CustomColumnNames = new[] { "Value", "IncreasingNumber", "NumberModulo", "DecreasingString", "ParentId" }, OrderBy = new string[] { } }; var oneTableMetadata = new SqlTableMetadata { TableName = "TestItem", CustomColumnNames = new[] { "Value" }, OrderBy = new string[] { } }; _oneStorage = new CrudSql <TestItemId <Guid> >(new DatabaseOptions { ConnectionString = connectionString }, oneTableMetadata); _manyStorage = new ManyToOneSql <TestItemManyToOneCreate <Guid, Guid?>, TestItemManyToOne <Guid, Guid?>, TestItemId <Guid> >( new DatabaseOptions { ConnectionString = connectionString }, manyTableMetadata, "ParentId", _oneStorage); }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(nameof(AzureStorageBlobCrdTestSearch)); var connectionString = TestSettings.ConnectionString; _storage = new CrudAzureStorageBlob <TestItemSort <Guid>, TestItemSort <Guid>, Guid>(connectionString, $"test-container-{Guid.NewGuid()}"); }
public void TestCaseInitialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(LogRequestResponseTests).FullName); FulcrumApplication.Context.CorrelationId = null; FulcrumApplication.Context.ClientTenant = null; FulcrumApplication.Context.LeverConfiguration = null; }
public void GenericBase_Can_Still_Log_Error() { FulcrumApplicationHelper.UnitTestSetup(nameof(BootstrapApplicationTests)); var loggerMock = new Mock <ISyncLogger>(); FulcrumApplication.Setup.SynchronousFastLogger = loggerMock.Object; LogRecord loggedRecord = null; loggerMock .Setup(x => x.LogSync(It.IsAny <LogRecord>())) .Callback((LogRecord logRecord) => { loggedRecord = logRecord; Console.WriteLine("LOGGED MESSAGE: " + logRecord.ToLogString()); }); try { FulcrumAssert.IsNotNull(null, "NIL"); UT.Assert.Fail("Expected exception"); } catch (Exception) { UT.Assert.IsNotNull(loggedRecord, "Expected a log record"); UT.Assert.AreEqual(LogSeverityLevel.Error, loggedRecord.SeverityLevel); } }
public void TestCaseInitialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(NexusTestContextHeaderTest).FullName); TestStartup.TranslatorService = new Mock <ITranslatorService>().Object; TestStartup.GetTranslatorClientName = () => Foo.ConsumerName; }
public static void ClassInitialize(TestContext context) { FulcrumApplicationHelper.UnitTestSetup(nameof(DistributionTest)); FulcrumApplication.Setup.SynchronousFastLogger = new MinimalFulcrumLogger(); _logger = new LoggerFactory().CreateLogger(nameof(DistributionTest)); _okResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(OkContent, Encoding.UTF8, "application/json") }; _runBackgroundJob = true; _asyncCallerConfigMock = new Mock <ILeverConfiguration>(); _asyncCallerServiceConfigMock = new Mock <ILeverServiceConfiguration>(); _asyncCallerServiceConfigMock.Setup(x => x.GetConfigurationForAsync(Tenant)).ReturnsAsync(_asyncCallerConfigMock.Object); // By using RequestQueueHelper.MemoryQueueConnectionString, the SDK uses MemoryQueue.Instance(QueueName) as the queue _asyncCallerConfigMock.Setup(x => x.MandatoryValue <string>("ConnectionString")).Returns(RequestQueueHelper.MemoryQueueConnectionString); // This project is based on SchemaVersion 1 _asyncCallerConfigMock.Setup(x => x.Value <int?>(nameof(AnonymousSchema.SchemaVersion))).Returns(1); _asyncCallerConfigMock.Setup(x => x.Value <double?>("DefaultDeadlineTimeSpanInSeconds")).Returns(60); Startup.AsyncCallerServiceConfiguration = _asyncCallerServiceConfigMock.Object; SimulateQueueTrigger(null); SimulateQueueTrigger(1); SimulateQueueTrigger(2); }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(TestLogHelper).FullName); // Mock fallback logger _callsToFallback = 0; var fallbackLoggerMock = new Mock <IFallbackLogger>(); fallbackLoggerMock .Setup(logger => logger.SafeLog(It.IsAny <LogSeverityLevel>(), It.IsAny <string>())) .Callback((LogSeverityLevel sl, string m) => Interlocked.Increment(ref _callsToFallback)); FulcrumApplication.Setup.FallbackLogger = fallbackLoggerMock.Object; // Mock async logger var asyncLoggerMock = new Mock <IAsyncLogger>(); asyncLoggerMock .Setup(logger => logger.LogAsync(It.IsAny <LogRecord>(), It.IsAny <CancellationToken>())) .Callback((LogRecord logRecord, CancellationToken ct) => { _loggedRecord = logRecord; _loggedCorrelationId = FulcrumApplication.Context.CorrelationId; }) .Returns(Task.CompletedTask); _queueLogger = new QueueToAsyncLogger(asyncLoggerMock.Object) { KeepQueueAliveTimeSpan = TimeSpan.Zero }; }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(nameof(AzureStorageV12BlobCrudTestEtag)); var connectionString = TestSettings.ConnectionString; _storage = new CrudAzureStorageContainer <TestItemBare, TestItemTimestamped <string> >(connectionString, $"test-container-{Guid.NewGuid()}"); }
public void InitializeTest() { FulcrumApplicationHelper.UnitTestSetup(nameof(LogTests)); var httpSenderMock = new Mock <IHttpClient>(); httpSenderMock.Setup(x => x.SimulateOutgoingCalls).Returns(true); Distributor.HttpSender = httpSenderMock.Object; var asyncCallerConfigMock = new Mock <ILeverConfiguration>(); var asyncCallerServiceConfigMock = new Mock <ILeverServiceConfiguration>(); asyncCallerServiceConfigMock.Setup(x => x.GetConfigurationForAsync(Tenant)).ReturnsAsync(asyncCallerConfigMock.Object); // By using RequestQueueHelper.MemoryQueueConnectionString, the SDK uses MemoryQueue.Instance(QueueName) as the queue asyncCallerConfigMock.Setup(x => x.MandatoryValue <string>("ConnectionString")).Returns(RequestQueueHelper.MemoryQueueConnectionString); asyncCallerConfigMock.Setup(x => x.Value <int?>(nameof(AnonymousSchema.SchemaVersion))).Returns(1); asyncCallerConfigMock.Setup(x => x.Value <double?>("DefaultDeadlineTimeSpanInSeconds")).Returns(60); var serviceConfigs = new Dictionary <Tenant, ILeverServiceConfiguration> { [Tenant] = asyncCallerServiceConfigMock.Object, }; Startup.AsyncCallerServiceConfiguration = serviceConfigs; }
public void TestCaseInitialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(TrackAggregatedRequestUrlsTest).FullName); _telemetryHandlerMock = new Mock <ITelemetryHandler>(); FulcrumApplication.Setup.TelemetryHandler = _telemetryHandlerMock.Object; }
public async Task Initialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(TestMemoryDistributedCache).FullName); var storage = new CrudMemory <CrudMemoryDistributedCache, CrudMemoryDistributedCache, string>(); var factory = new CrudMemoryDistributedCacheFactory(storage); _cache = await factory.GetOrCreateDistributedCacheAsync(typeof(TestMemoryDistributedCache).FullName); }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(RestClientTest).FullName); HttpClientMock = new Mock <IHttpClient>(); _httpSender = new HttpSender("http://example.se") { HttpClient = HttpClientMock.Object }; }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(nameof(AzureStorageQueueTest)); var connectionString = TestSettings.ConnectionString; Assert.IsNotNull(connectionString); _table = new AzureStorageTable <Car, Car>(connectionString, $"{nameof(AzureStorageTableTest)}V1"); }
public async Task InitializeAsync() { FulcrumApplicationHelper.UnitTestSetup(nameof(AzureStorageV12QueueTest)); var connectionString = TestSettings.ConnectionString; Assert.IsNotNull(connectionString); _queue = new AzureStorageQueue <Message>(connectionString, "test-queue"); await _queue.ClearAsync(); }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(ServiceAuthenticationHelperVersion2Test).FullName); _httpClientMock = new Mock <IHttpClient>(); ServiceAuthenticationHelper.HttpClient = _httpClientMock.Object; ServiceAuthenticationHelper.ClearCache(); _authenticationHelper = new ServiceAuthenticationHelper(); }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(TestLog).FullName); _callsToFallback = 0; var fallbackLoggerMock = new Mock <IFallbackLogger>(); fallbackLoggerMock .Setup(logger => logger.SafeLog(It.IsAny <LogSeverityLevel>(), It.IsAny <string>())) .Callback((LogSeverityLevel sl, string m) => Interlocked.Increment(ref _callsToFallback)); FulcrumApplication.Setup.FallbackLogger = fallbackLoggerMock.Object; }
public void Inititalize() { FulcrumApplicationHelper.UnitTestSetup(nameof(CrudTestValidated)); var connectionString = ConfigurationManager.AppSettings["ConnectionString"]; var tableMetadata = new SqlTableMetadata { TableName = "TestItem", CustomColumnNames = new[] { "Value" }, OrderBy = new string[] { } }; _storage = new CrudSql <TestItemBare, TestItemValidated <Guid> >(connectionString, tableMetadata); }
public async Task Initialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(PersonsControllerTest).FullName); _storage = new SqlServerStorage("Data Source=WIN-7B74C50VA4D;Initial Catalog=LeverExampleGdpr;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"); //_storage = new MemoryStorage(); var gdprCapability = new Mapper(_storage); await DeleteAll(); _kalleAnka = await CreateKalleAnkaAsync(); _personsController = new PersonsController(gdprCapability); }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(TestAutoCacheManyToOneRecursive).FullName); _storage = new ManyToOneMemory <ItemWithParentId, Guid>(item => item.ParentId); Cache = new MemoryDistributedCache(); DistributedCacheOptions = new DistributedCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromMilliseconds(1000) }; AutoCacheOptions = new AutoCacheOptions { AbsoluteExpirationRelativeToNow = DistributedCacheOptions.AbsoluteExpirationRelativeToNow }; _autoCache = new ManyToOneAutoCache <ItemWithParentId, Guid>(_storage, Cache, null, AutoCacheOptions); }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(TestAutoCacheCrud).FullName); _storage = new CrudMemory <string, string, Guid>(); Cache = new MemoryDistributedCache(); DistributedCacheOptions = new DistributedCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromMilliseconds(1000) }; AutoCacheOptions = new AutoCacheOptions { AbsoluteExpirationRelativeToNow = DistributedCacheOptions.AbsoluteExpirationRelativeToNow }; _autoCache = new CrudAutoCache <string, Guid>(_storage, ToGuid, Cache, null, AutoCacheOptions); }
public void Initialize() { _decoratedConsumerId = $"(id!~consumer!{_consumerId})"; FulcrumApplicationHelper.UnitTestSetup(typeof(TestTranslator).FullName); _translatorServiceMock = new Mock <ITranslatorService>(); _translatorServiceMock .Setup(ts => ts.TranslateAsync( It.IsAny <IEnumerable <string> >(), It.IsAny <string>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new Dictionary <string, string> { { $"{_decoratedConsumerId}", _producerId } }); _consumerTranslator = new Translator("consumer", _translatorServiceMock.Object); }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(CrudRestClientTests).FullName); HttpClientMock = new Mock <IHttpClient>(); var httpSender = new HttpSender(ResourcePath) { HttpClient = HttpClientMock.Object }; _client = new CrudRestClient <Person, Guid>(httpSender); _person = new Person() { GivenName = "Kalle", Surname = "Anka" }; }
public void Initialize() { _decoratedConsumerId = $"(foo.id!~consumer!{ConsumerId})"; _decoratedProducerId = $"(foo.id!~producer!{ProducerId})"; FulcrumApplicationHelper.UnitTestSetup(typeof(ValueTranslatorHttpSenderTest).FullName); _translatorServiceMock = new Mock <ITranslatorService>(); _translatorServiceMock .Setup(ts => ts.TranslateAsync( It.IsAny <IEnumerable <string> >(), It.IsAny <string>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new Dictionary <string, string> { { $"{_decoratedConsumerId}", ProducerId } }); ValueTranslatorHttpSender.TranslatorService = _translatorServiceMock.Object; }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(TestLogHelper).FullName); _loggedSeverityLevel = LogSeverityLevel.None; _loggedMessage = null; var fallbackLoggerMock = new Mock <IFallbackLogger>(); fallbackLoggerMock .Setup(logger => logger.SafeLog(It.IsAny <LogSeverityLevel>(), It.IsAny <string>())) .Callback((LogSeverityLevel sl, string m) => { _loggedSeverityLevel = sl; _loggedMessage = m; }); FulcrumApplication.Setup.FallbackLogger = fallbackLoggerMock.Object; }
public void Initialize() { _callsToFallback = 0; var fallbackLoggerMock = new Mock <IFallbackLogger>(); fallbackLoggerMock .Setup(logger => logger.SafeLog(It.IsAny <LogSeverityLevel>(), It.IsAny <string>())) .Callback((LogSeverityLevel sl, string m) => Interlocked.Increment(ref _callsToFallback)); FulcrumApplicationHelper.UnitTestSetup(typeof(TestBatchLogger).FullName); _loggedRecords = 0; _mockLogger = new Mock <ISyncLogger>(); _mockLogger.Setup(logger => logger.LogSync(It.IsAny <LogRecord>())).Callback((LogRecord _) => Interlocked.Increment(ref _loggedRecords)); FulcrumApplication.Setup.SynchronousFastLogger = new BatchLogger(_mockLogger.Object); FulcrumApplication.Setup.FallbackLogger = fallbackLoggerMock.Object; }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(CrudManyToOneRestClientTest).FullName); HttpClientMock = new Mock <IHttpClient>(); Libraries.Web.RestClientHelper.HttpSender.DefaultHttpClient = HttpClientMock.Object; var httpSender = new HttpSender(ResourcePath) { HttpClient = HttpClientMock.Object }; _client = new CrudManyToOneRestClient2 <Address, Guid>(httpSender, "Persons", "Addresses"); _address = new Address() { Street = "Paradisäppelvägen 111", City = "Ankeborg" }; }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(HttpSenderTest).FullName); _httpClientMock = new Mock <IHttpClient>(); _httpClientMock.Setup(s => s.SendAsync(It.IsAny <HttpRequestMessage>(), It.IsAny <CancellationToken>())) .Callback((HttpRequestMessage m, CancellationToken ct) => { _actualRequestMessage = m; _actualContent = null; if (m.Content != null) { m.Content.LoadIntoBufferAsync().Wait(ct); _actualContent = m.Content.ReadAsStringAsync().Result; } }) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)); }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(typeof(CrudManyToOneRecursiveRestClientTest).FullName); HttpClientMock = new Mock <IHttpClient>(); HttpSender.DefaultHttpClient = HttpClientMock.Object; var httpSender = new HttpSender(ResourcePath) { HttpClient = HttpClientMock.Object }; _oneManyClient = new CrudManyToOneRestClient2 <Person, Guid>(httpSender, "Persons", "Many"); _person = new Person() { GivenName = "Kalle", Surname = "Anka" }; }
public void Initialize() { FulcrumApplicationHelper.UnitTestSetup(nameof(CrudTestValidated)); var connectionString = TestSettings.ConnectionString; FulcrumAssert.IsNotNullOrWhiteSpace(connectionString); var tableMetadata = new SqlTableMetadata { TableName = "TestItem", CustomColumnNames = new[] { "Value" }, OrderBy = new string[] { } }; _storage = new CrudSql <TestItemBare, TestItemValidated <Guid> >(new DatabaseOptions { ConnectionString = connectionString }, tableMetadata); }