public void Inititalize()
        {
            FulcrumApplicationHelper.UnitTestSetup(nameof(CrudTestEtag));
            var connectionString = ConfigurationManager.AppSettings["ConnectionString"];
            var tableMetadata    = new SqlTableMetadata
            {
                TableName         = "TestItem",
                EtagColumnName    = "Etag",
                CustomColumnNames = new[] { "Value" },
                OrderBy           = new string[] { }
            };

            _storage = new CrudSql <TestItemBare, TestItemEtag <Guid> >(connectionString, tableMetadata);
        }
Пример #2
0
 public void RunTimeLevel_Cant_Be_None()
 {
     try
     {
         // Before bug fix 4.20.1 this would through exception due to Log.LogError doing validation on ApplicationSetup,
         // which had no chance of setting the ApplicationSetup properties because the logging intervened
         FulcrumApplicationHelper.RuntimeSetup("app-name", new Tenant("o", "e"), RunTimeLevelEnum.None);
         UT.Assert.Fail("Expected exception");
     }
     catch (Exception e)
     {
         UT.Assert.IsTrue(e.Message.Contains(nameof(RunTimeLevelEnum.None)),
                          $"Expected error message to contain {nameof(RunTimeLevelEnum.None)}, but it didn't. Was {e.Message}");
     }
 }
Пример #3
0
 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);
 }
Пример #4
0
 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(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);
 }
Пример #6
0
        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;
        }
Пример #7
0
        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(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"
            };
        }
Пример #9
0
 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(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(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"
            };
        }
Пример #12
0
        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"
            };
        }
Пример #13
0
        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);
        }
        public async Task Initialize()
        {
            FulcrumApplicationHelper.UnitTestSetup(nameof(CrdTestSearch));
            var connectionString = TestSettings.ConnectionString;

            FulcrumAssert.IsNotNullOrWhiteSpace(connectionString);
            var tableMetadata = new SqlTableMetadata
            {
                TableName         = "TestItem",
                CustomColumnNames = new[] { "Value", "IncreasingNumber", "NumberModulo", "DecreasingString" },
                OrderBy           = new string[] {}
            };

            _storage = new CrudSql <TestItemSort <Guid>, TestItemSort <Guid> >(new DatabaseOptions
            {
                ConnectionString = connectionString
            }, tableMetadata);
            await _storage.DeleteAllAsync();
        }
Пример #15
0
 public void Initialize()
 {
     FulcrumApplicationHelper.UnitTestSetup(nameof(CrudTestId));
     var connectionString = TestSettings.ConnectionString;
     FulcrumAssert.IsNotNullOrWhiteSpace(connectionString);
     var tableMetadata = new SqlTableMetadata
     {
         TableName = "TestItem",
         CustomColumnNames = new[] { "Value" },
         OrderBy = new string[] { }
     };
     var options = new DatabaseOptions
     {
         ConnectionString = connectionString,
         DefaultLockTimeSpan = TimeSpan.FromSeconds(30)
     };
     options.DistributedLockTable = new DistributedLockTable(options);
     _storage = new CrudSql<TestItemBare, TestItemId<Guid>>(options, tableMetadata);
 }
        public void Initialize()
        {
            FulcrumApplicationHelper.UnitTestSetup(nameof(CircuitBreakerTests));
            _coolDownStrategyMock = new Mock <ICoolDownStrategy>();
            _coolDownStrategyMock
            .Setup(strategy => strategy.Reset());
            _coolDownStrategyMock
            .Setup(strategy => strategy.StartNextCoolDownPeriod());
            var circuitBreakerOptions = new CircuitBreakerWithThrottlingOptions
            {
                CoolDownStrategy = _coolDownStrategyMock.Object,
                CancelConcurrentRequestsWhenOneFails   = false,
                ThrottlingCoolDownStrategy             = _coolDownStrategyMock.Object,
                ConcurrencyThresholdForChokingResolved = 100
            };

            _circuitBreakersUnderTest = new ICircuitBreaker[]
            {
                new CircuitBreaker(circuitBreakerOptions),
                new CircuitBreakerWithThrottling(circuitBreakerOptions)
            };
        }
Пример #17
0
        public void Initialize()
        {
            FulcrumApplicationHelper.UnitTestSetup(typeof(ClientConfigTest).FullName);

            _clientConfigurations = new List <ClientConfiguration>
            {
                // Both request headers and authentication
                new ClientConfiguration
                {
                    Name           = ClientName,
                    RequestHeaders = new Dictionary <string, string>
                    {
                        { "foo", "bar" }
                    },
                    Authentication = "auth"
                },
                // Request headers, but no authentication
                new ClientConfiguration
                {
                    Name           = ClientNameNoAuth,
                    RequestHeaders = new Dictionary <string, string>
                    {
                        { "baz", "boz" }
                    }
                },
                // Authentication, but no request headers
                new ClientConfiguration
                {
                    Name           = ClientName2,
                    Authentication = "auth"
                },
                // No authentication and no request headers
                new ClientConfiguration
                {
                    Name = ClientName4
                }
            };
            CreateLeverConfiguration();
        }
 public void Initialize()
 {
     FulcrumApplicationHelper.UnitTestSetup(nameof(TestFulcrumAssert));
 }
Пример #19
0
 public void Initialize()
 {
     FulcrumApplicationHelper.UnitTestSetup(nameof(TestNexusContext));
 }
 public void TestCaseInitialize()
 {
     FulcrumApplicationHelper.UnitTestSetup(typeof(BusinessApiOutPipeTests).FullName);
 }
 /// <inheritdoc />
 public MemoryCrudTestParameters() : base(new CrudMemory <TestItemBare, Guid>())
 {
     FulcrumApplicationHelper.UnitTestSetup(nameof(MemoryCrudTestParameters));
 }
 public void Initialize()
 {
     FulcrumApplicationHelper.UnitTestSetup(typeof(TestMemoryQueue).FullName);
 }
 public void RunBeforeEachTestMethod()
 {
     FulcrumApplicationHelper.UnitTestSetup(typeof(TestSchemaParser).FullName);
 }
 public void TestCaseInitialize()
 {
     FulcrumApplicationHelper.UnitTestSetup(typeof(LogRequestResponseTests).FullName);
 }
 public void Initialize()
 {
     FulcrumApplicationHelper.UnitTestSetup(nameof(TestConfigurationManagerAppSettings));
 }
Пример #26
0
 public void Initialize()
 {
     FulcrumApplicationHelper.UnitTestSetup(typeof(TestThreadHelper).FullName);
     FulcrumApplication.Setup.ThreadHandler   = new BasicThreadHandler();
     FulcrumApplication.Context.CorrelationId = Guid.NewGuid().ToString();
 }
Пример #27
0
 public void RunBeforeEachTestMethod()
 {
     FulcrumApplicationHelper.UnitTestSetup(typeof(StatusCodeToFulcrumErrorTests).FullName);
 }
Пример #28
0
 public void RunBeforeEachTestMethod()
 {
     FulcrumApplicationHelper.UnitTestSetup(typeof(ExceptionConverterTests).FullName);
 }
Пример #29
0
 public void RunForEveryTestCase()
 {
     FulcrumApplicationHelper.UnitTestSetup(typeof(LogRequestAndResponseTest).FullName);
 }
Пример #30
0
 public void Initialize()
 {
     FulcrumApplicationHelper.UnitTestSetup(nameof(TestAsyncLocalContextValueProvider));
     _provider = new AsyncLocalContextValueProvider();
 }