├── .github
└── pull_request_template.md
├── .gitignore
├── CHANGES.txt
├── CONTRIBUTORS-GUIDE.md
├── LICENSE.txt
├── README.md
├── Split.io.sln
├── Splitio-net-core-tests
├── Integration Tests
│ ├── JSONFileClientTests.cs
│ ├── LocalhostClientTests.cs
│ ├── RedisAdapterTests.cs
│ ├── RedisClientTests.cs
│ ├── SdkApiClientTests.cs
│ ├── SelfRefreshingSegmentFetcherTests.cs
│ ├── SelfRefreshingSplitClientTests.cs
│ ├── SelfRefreshingSplitFetcherTests.cs
│ └── SplitSdkApiClientTests.cs
├── Resources
│ ├── SplitsHelper.cs
│ ├── legacy-sample-data-non-alpha-numeric.csv
│ ├── legacy-sample-data.csv
│ ├── murmur3-64-128.csv
│ ├── murmur3-sample-data-non-alpha-numeric-v2.csv
│ ├── murmur3-sample-data-non-alpha-numeric.csv
│ ├── murmur3-sample-data-v2.csv
│ ├── murmur3-sample-data.csv
│ ├── regex.txt
│ ├── segment_payed.json
│ ├── split.yaml
│ ├── split.yml
│ ├── splits_staging.json
│ ├── splits_staging_2.json
│ ├── splits_staging_3.json
│ ├── splits_staging_4.json
│ ├── splits_staging_5.json
│ ├── splits_staging_6.json
│ ├── splits_staging_7.json
│ └── test.splits
├── Splitio-net-core-tests.csproj
└── Unit Tests
│ ├── Cache
│ ├── InMemoryMetricsCacheTests.cs
│ ├── InMemorySimpleCacheTests.cs
│ ├── Lru
│ │ ├── CacheTests.cs
│ │ ├── EnumeratorTests.cs
│ │ ├── IDictionaryTests.cs
│ │ ├── NodeTests.cs
│ │ └── TestData.cs
│ ├── RedisCacheBaseTests.cs
│ ├── RedisImpressionCacheTests.cs
│ ├── RedisMetricsCacheTests.cs
│ ├── RedisSegmentCacheTests.cs
│ ├── RedisSplitCacheTests.cs
│ ├── SegmentCacheTests.cs
│ └── SplitCacheTests.cs
│ ├── Client
│ ├── LocalhostClientForTesting.cs
│ ├── LocalhostClientUnitTests.cs
│ ├── SdkReadinessGatesUnitTests.cs
│ ├── SplitClientForTesting.cs
│ ├── SplitClientUnitTests.cs
│ ├── SplitFactoryUnitTests.cs
│ └── SplitManagerUnitTests.cs
│ ├── Common
│ ├── AuthApiClientTests.cs
│ ├── PushManagerTests.cs
│ ├── SyncManagerTests.cs
│ └── SynchronizerTests.cs
│ ├── CommonLibraries
│ └── TypeConverterUnitTests.cs
│ ├── Evaluator
│ └── EvaluatorTests.cs
│ ├── EventSource
│ ├── NotificationManagerKeeperTests.cs
│ ├── NotificationParserTests.cs
│ ├── NotificationPorcessorTests.cs
│ ├── SSEHandlerTests.cs
│ └── Workers
│ │ ├── SegmentsWorkerTests.cs
│ │ └── SplitsWorkerTests.cs
│ ├── Events
│ ├── EventsLogUnitTests.cs
│ └── RedisEventsLogUnitTests.cs
│ ├── Impressions
│ ├── ImpressionHasherTests.cs
│ ├── ImpressionsCountSenderTests.cs
│ ├── ImpressionsCounterTests.cs
│ ├── ImpressionsHelperTest.cs
│ ├── ImpressionsLogUnitTests.cs
│ ├── ImpressionsManagerTests.cs
│ ├── ImpressionsObserverTests.cs
│ ├── RedisImpressionsLogUnitTests.cs
│ └── TreatmentSdkApiClientTests.cs
│ ├── InputValidation
│ ├── ApiKeyValidatorTests.cs
│ ├── EventPropertiesValidatorTests.cs
│ ├── EventTypeValidatorTests.cs
│ ├── KeyValidatorTests.cs
│ ├── SplitNameValidatorTests.cs
│ └── TrafficTypeValidatorTests.cs
│ ├── Matchers
│ ├── AllKeysMatcherTests.cs
│ ├── AttributeMatcherTests.cs
│ ├── BetweenMatcherTests.cs
│ ├── CombiningMatcherTests.cs
│ ├── ContainsAllOfSetMatcherTests.cs
│ ├── ContainsAnyOfSetMatcherTests.cs
│ ├── ContainsStringMatcherTests.cs
│ ├── DependencyMatcherTests.cs
│ ├── EndsWithMatcherTests.cs
│ ├── EqualToBooleanMatcherTests.cs
│ ├── EqualToMatcherTests.cs
│ ├── EqualsToSetMatcherTests.cs
│ ├── GreaterOrEqualToMatcherTests.cs
│ ├── LessOrEqualToMatcherTests.cs
│ ├── MatchesStringMatcherTests.cs
│ ├── PartOfSetMatcherTests.cs
│ ├── SplitParserUnitTests.cs
│ ├── StartsWithMatcherTests.cs
│ ├── UserDefinedSegmentMatcherTests.cs
│ └── WhitelistMatcherTests.cs
│ ├── Metrics
│ ├── AsyncMetricsLogUnitTests.cs
│ ├── BinarySearchLatencyTrackerTests.cs
│ ├── InMemoryMetricsLogUnitTests.cs
│ └── RedisMetricsLogUnitTests.cs
│ ├── SegmentFetcher
│ ├── ApiSegmentChangeFetcherUnitTests.cs
│ ├── SelfRefreshingSegmentFetcherUnitTests.cs
│ └── SelfRefreshingSegmentUnitTests.cs
│ ├── Shared
│ ├── ConfigServiceTests.cs
│ └── FactoryInstantiationsServiceTests.cs
│ ├── SplitFetcher
│ └── ApiSplitChangeFetcherTests.cs
│ └── Splitter
│ └── SplitterTests.cs
├── Splitio-net-core.Integration-tests
├── BaseIntegrationTests.cs
├── EventSource
│ └── EventSourceClientTests.cs
├── HttpClientMock.cs
├── InMemoryTests.cs
├── PushClientTests.cs
├── RedisTests.cs
├── Resources
│ ├── EventBackend.cs
│ ├── IntegrationTestsImpressionListener.cs
│ ├── KeyImpressionBackend.cs
│ ├── StatusCodeEnum.cs
│ ├── split_changes.json
│ ├── split_changes_1.json
│ ├── split_segment1.json
│ ├── split_segment2.json
│ ├── split_segment3.json
│ ├── split_segment4.json
│ ├── split_segment4_empty.json
│ ├── split_segment4_updated.json
│ ├── split_segment4_updated_empty.json
│ ├── splits_push.json
│ ├── splits_push2.json
│ ├── splits_push3.json
│ └── splits_push4.json
└── Splitio-net-core.Integration-tests.csproj
├── Splitio-net-core.Redis
├── Services
│ ├── Cache
│ │ ├── Classes
│ │ │ ├── RedisAdapter.cs
│ │ │ ├── RedisCacheBase.cs
│ │ │ ├── RedisEventsCache.cs
│ │ │ ├── RedisImpressionsCache.cs
│ │ │ ├── RedisMetricsCache.cs
│ │ │ ├── RedisSegmentCache.cs
│ │ │ └── RedisSplitCache.cs
│ │ └── Interfaces
│ │ │ └── IRedisAdapter.cs
│ ├── Client
│ │ └── Classes
│ │ │ └── RedisClient.cs
│ ├── Domain
│ │ └── RedisConfig.cs
│ ├── Events
│ │ └── Classes
│ │ │ └── RedisEventsLog.cs
│ ├── Impressions
│ │ └── Classes
│ │ │ └── RedisImpressionLog.cs
│ ├── Metrics
│ │ └── Classes
│ │ │ └── RedisMetricsLog.cs
│ ├── Parsing
│ │ └── Classes
│ │ │ └── RedisSplitParser.cs
│ └── Shared
│ │ └── RedisBlockUntilReadyService.cs
├── Splitio.Redis.csproj
└── SplitioRedis.snk
├── Splitio.TestSupport
├── README.md
├── Samples
│ └── SampleTest.cs
├── SplitClientForTest.cs
├── SplitScenario.cs
├── SplitSuite.cs
├── SplitTest.cs
└── Splitio-net-core.TestSupport.csproj
├── appveyor.yml
├── lib
└── MurmurHash-net-core.dll
├── sonar-scanner.bat
└── src
└── Splitio-net-core
├── CommonLibraries
├── CurrentTimeHelper.cs
├── HTTPHeader.cs
├── HTTPResult.cs
├── ISdkApiClient.cs
├── PeriodicTaskFactory.cs
├── SdkApiClient.cs
└── TypeConverter.cs
├── Domain
├── AdapterType.cs
├── AlgorithmEnum.cs
├── AttributeMatcher.cs
├── AuthenticationResponse.cs
├── BaseConfig.cs
├── BetweenData.cs
├── CacheAdapterConfigurationOptions.cs
├── CombinerEnum.cs
├── CombiningMatcher.cs
├── ConditionDefinition.cs
├── ConditionType.cs
├── ConditionWithLogic.cs
├── ConfigurationOptions.cs
├── Constans.cs
├── DataTypeEnum.cs
├── DependencyData.cs
├── Event.cs
├── EventValidatorResult.cs
├── ImpressionsMode.cs
├── Key.cs
├── KeyImpression.cs
├── KeySelector.cs
├── Labels.cs
├── LightSplit.cs
├── MatcherDefinition.cs
├── MatcherGroupDefinition.cs
├── MatcherTypeEnum.cs
├── Mode.cs
├── MultipleEvaluatorResult.cs
├── Operations.cs
├── ParsedSplit.cs
├── PartitionDefinition.cs
├── ReadConfigData.cs
├── Segment.cs
├── SegmentChange.cs
├── SelfRefreshingConfig.cs
├── Split.cs
├── SplitBase.cs
├── SplitChange.cs
├── SplitResult.cs
├── StatusEnum.cs
├── TreatmentResult.cs
├── UnaryNumericData.cs
├── UserDefinedSegmentData.cs
├── ValidatorResult.cs
├── WhiteListData.cs
└── WrappedEvent.cs
├── Properties
└── AssemblyInfo.cs
├── Services
├── Cache
│ ├── Classes
│ │ ├── InMemoryMetricsCache.cs
│ │ ├── InMemoryReadinessGatesCache.cs
│ │ ├── InMemorySegmentCache.cs
│ │ └── InMemorySplitCache.cs
│ ├── Interfaces
│ │ ├── IMetricsCache.cs
│ │ ├── IReadinessGatesCache.cs
│ │ ├── ISegmentCache.cs
│ │ └── ISplitCache.cs
│ └── Lru
│ │ ├── CacheEnumerator.cs
│ │ ├── LruCache.cs
│ │ └── Node.cs
├── Client
│ ├── Classes
│ │ ├── JSONFileClient.cs
│ │ ├── LocalhostClient.cs
│ │ ├── SelfRefreshingClient.cs
│ │ ├── SplitClient.cs
│ │ ├── SplitFactory.cs
│ │ └── SplitManager.cs
│ └── Interfaces
│ │ ├── ISplitClient.cs
│ │ ├── ISplitFactory.cs
│ │ └── ISplitManager.cs
├── Common
│ ├── AuthApiClient.cs
│ ├── BackOff.cs
│ ├── IAuthApiClient.cs
│ ├── IBackOff.cs
│ ├── IPushManager.cs
│ ├── ISplitioHttpClient.cs
│ ├── ISyncManager.cs
│ ├── ISynchronizer.cs
│ ├── PushManager.cs
│ ├── SplitioHttpClient.cs
│ ├── SyncManager.cs
│ └── Synchronizer.cs
├── EngineEvaluator
│ ├── ISplitter.cs
│ └── Splitter.cs
├── Evaluator
│ ├── Evaluator.cs
│ └── IEvaluator.cs
├── EventSource
│ ├── EventReceivedEventArgs.cs
│ ├── EventSourceClient.cs
│ ├── FeedbackEventArgs.cs
│ ├── IEventSourceClient.cs
│ ├── INotificationManagerKeeper.cs
│ ├── INotificationParser.cs
│ ├── INotificationProcessor.cs
│ ├── ISSEHandler.cs
│ ├── Notification.cs
│ ├── NotificationManagerKeeper.cs
│ ├── NotificationParser.cs
│ ├── NotificationProcessor.cs
│ ├── ReadStreamException.cs
│ ├── SSEClientActions.cs
│ ├── SSEHandler.cs
│ └── Workers
│ │ ├── ISegmentsWorker.cs
│ │ ├── ISplitsWorker.cs
│ │ ├── IWorker.cs
│ │ ├── SegmentQueueDto.cs
│ │ ├── SegmentsWorker.cs
│ │ └── SplitsWorker.cs
├── Events
│ ├── Classes
│ │ ├── EventSdkApiClient.cs
│ │ └── EventsLog.cs
│ └── Interfaces
│ │ ├── IEventSdkApiClient.cs
│ │ └── IEventsLog.cs
├── Impressions
│ ├── Classes
│ │ ├── ImpressionHasher.cs
│ │ ├── ImpressionsCountSender.cs
│ │ ├── ImpressionsCounter.cs
│ │ ├── ImpressionsHelper.cs
│ │ ├── ImpressionsLog.cs
│ │ ├── ImpressionsManager.cs
│ │ ├── ImpressionsObserver.cs
│ │ └── TreatmentSdkApiClient.cs
│ └── Interfaces
│ │ ├── IImpressionHasher.cs
│ │ ├── IImpressionListener.cs
│ │ ├── IImpressionsCountSender.cs
│ │ ├── IImpressionsCounter.cs
│ │ ├── IImpressionsLog.cs
│ │ ├── IImpressionsManager.cs
│ │ ├── IImpressionsObserver.cs
│ │ └── ITreatmentSdkApiClient.cs
├── InputValidation
│ ├── Classes
│ │ ├── ApiKeyValidator.cs
│ │ ├── EventPropertiesValidator.cs
│ │ ├── EventTypeValidator.cs
│ │ ├── KeyValidator.cs
│ │ ├── SplitNameValidator.cs
│ │ └── TrafficTypeValidator.cs
│ └── Interfaces
│ │ ├── IApiKeyValidator.cs
│ │ ├── IEventPropertiesValidator.cs
│ │ ├── IEventTypeValidator.cs
│ │ ├── IKeyValidator.cs
│ │ ├── ISplitNameValidator.cs
│ │ └── ITrafficTypeValidator.cs
├── Logger
│ ├── CommonLogging.cs
│ ├── ISplitLogger.cs
│ ├── MicrosoftExtensionsLogging.cs
│ └── SplitLoggerFactoryExtensions.cs
├── Metrics
│ ├── Classes
│ │ ├── AsyncMetricsLog.cs
│ │ ├── BinarySearchLatencyTracker.cs
│ │ ├── Counter.cs
│ │ ├── InMemoryMetricsLog.cs
│ │ └── MetricsSdkApiClient.cs
│ └── Interfaces
│ │ ├── ILatencyTracker.cs
│ │ ├── IMetricsLog.cs
│ │ └── IMetricsSdkApiClient.cs
├── Parsing
│ ├── Classes
│ │ ├── AllKeysMatcher.cs
│ │ ├── BaseMatcher.cs
│ │ ├── BetweenMatcher.cs
│ │ ├── CompareMatcher.cs
│ │ ├── ContainsAllOfSetMatcher.cs
│ │ ├── ContainsAnyOfSetMatcher.cs
│ │ ├── ContainsStringMatcher.cs
│ │ ├── DependencyMatcher.cs
│ │ ├── EndsWithMatcher.cs
│ │ ├── EqualToBooleanMatcher.cs
│ │ ├── EqualToMatcher.cs
│ │ ├── EqualToSetMatcher.cs
│ │ ├── GreaterOrEqualToMatcher.cs
│ │ ├── InMemorySplitParser.cs
│ │ ├── LessOrEqualToMatcher.cs
│ │ ├── MatchesStringMatcher.cs
│ │ ├── PartOfSetMatcher.cs
│ │ ├── SplitParser.cs
│ │ ├── StartsWithMatcher.cs
│ │ ├── UserDefinedSegmentMatcher.cs
│ │ └── WhitelistMatcher.cs
│ └── Interfaces
│ │ ├── IMatcher.cs
│ │ └── ISplitParser.cs
├── SegmentFetcher
│ ├── Classes
│ │ ├── ApiSegmentChangeFetcher.cs
│ │ ├── JSONFileSegmentFetcher.cs
│ │ ├── SegmentChangeFetcher.cs
│ │ ├── SegmentFetcher.cs
│ │ ├── SegmentSdkApiClient.cs
│ │ ├── SegmentTaskQueue.cs
│ │ ├── SegmentTaskWorker.cs
│ │ ├── SelfRefreshingSegment.cs
│ │ └── SelfRefreshingSegmentFetcher.cs
│ └── Interfaces
│ │ ├── ISegment.cs
│ │ ├── ISegmentChangeFetcher.cs
│ │ ├── ISegmentFetcher.cs
│ │ ├── ISegmentSdkApiClient.cs
│ │ ├── ISegmentTaskQueue.cs
│ │ ├── ISelfRefreshingSegment.cs
│ │ └── ISelfRefreshingSegmentFetcher.cs
├── Shared
│ ├── Classes
│ │ ├── AbstractLocalhostFileService.cs
│ │ ├── BlockingQueue.cs
│ │ ├── ConfigService.cs
│ │ ├── FactoryInstantiationsService.cs
│ │ ├── InMemorySimpleCache.cs
│ │ ├── LocalhostFileService.cs
│ │ ├── NoopBlockUntilReadyService.cs
│ │ ├── SelfRefreshingBlockUntilReadyService.cs
│ │ ├── WrapperAdapter.cs
│ │ └── YamlLocalhostFileService.cs
│ └── Interfaces
│ │ ├── IBlockUntilReadyService.cs
│ │ ├── IConfigService.cs
│ │ ├── IFactoryInstantiationsService.cs
│ │ ├── ILocalhostFileService.cs
│ │ ├── ISimpleCache.cs
│ │ ├── ISimpleProducerCache.cs
│ │ └── IWrapperAdapter.cs
└── SplitFetcher
│ ├── Classes
│ ├── ApiSplitChangeFetcher.cs
│ ├── JSONFileSplitChangeFetcher.cs
│ ├── SelfRefreshingSplitFetcher.cs
│ ├── SplitChangeFetcher.cs
│ └── SplitSdkApiClient.cs
│ └── Interfaces
│ ├── ISplitChangeFetcher.cs
│ ├── ISplitFetcher.cs
│ └── ISplitSdkApiClient.cs
├── Splitio.csproj
├── Splitio.csproj.user
└── Splitio.snk
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | # .NET SDK
2 |
3 | ## What did you accomplish?
4 |
5 | ## How do we test the changes introduced in this PR?
6 |
7 | ## Extra Notes
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | src/Splitio-net-core/bin/Debug/netstandard1.6/*
2 | src/Splitio-net-core/obj/*
3 | TestResults/*
4 | .vs/config/applicationhost.config
5 | .vs/restore.dg
6 | .vs/Split.io-net-core/v14/.suo
7 | packages/*
8 | SplitioTests/bin/*
9 | SplitioTests/obj/*
10 | src/Splitio-net-core/bin/*
11 | .vs/Split.io-net-core/v15/.suo
12 | Splitio-net-core-tests/bin/*
13 | Splitio-net-core-tests/obj/*
14 | Splitio.TestSupport/bin
15 | Splitio.TestSupport/obj
16 | Splitio-net-core.Redis/obj
17 | Splitio-net-core.Redis/bin/
18 | .vs/Split.io-net-core/v15/Server/sqlite3/storage.ide-wal
19 | .vs/Split.io-net-core/v15/Server/sqlite3/storage.ide-shm
20 | .vs/Split.io-net-core/v15/Server/sqlite3/storage.ide
21 | .vs/Split.io-net-core/v15/Server/sqlite3/db.lock
22 | /Splitio-net-core-tests/TestResults
23 | /Splitio-net-frameworks-tests/bin/Debug
24 | /Splitio-net-frameworks-tests/obj/Debug
25 | /Splitio-net-frameworks-tests/Splitio-net-frameworks-tests.csproj.user
26 | /.vs
27 | *.user
28 | Splitio-net-frameworks-tests/bin/
29 | Splitio-net-frameworks-tests/obj/
30 | /Splitio-net-core.Integration-tests/bin
31 | /Splitio-net-core.Integration-tests/obj
32 |
--------------------------------------------------------------------------------
/CONTRIBUTORS-GUIDE.md:
--------------------------------------------------------------------------------
1 | # Contributing to the Split .NET SDK
2 |
3 | Split SDK is an open source project and we welcome feedback and contribution. The information below describes how to build the project with your changes, run the tests, and send the Pull Request(PR).
4 |
5 | ## Development
6 |
7 | ### Development process
8 |
9 | 1. Fork the repository and create a topic branch from `development` branch. Please use a descriptive name for your branch.
10 | 2. While developing, use descriptive messages in your commits. Avoid short or meaningless sentences like "fix bug".
11 | 3. Make sure to add tests for both positive and negative cases.
12 | 4. Run the build and make sure it runs with no errors.
13 | 5. Run all tests and make sure there are no failures.
14 | 6. `git push` your changes to GitHub within your topic branch.
15 | 7. Open a Pull Request(PR) from your forked repo and into the `development` branch of the original repository.
16 | 8. When creating your PR, please fill out all the fields of the PR template, as applicable, for the project.
17 | 9. Check for conflicts once the pull request is created to make sure your PR can be merged cleanly into `development`.
18 | 10. Keep an eye out for any feedback or comments from Split's SDK team.
19 |
20 | ### Running tests
21 | You can execute the following commands in .net-core-client folder to run the tests:
22 | - dotnet test .\Splitio-net-core-tests\
23 | - dotnet test .\Splitio-net-core.Integration-tests\
24 |
25 | # Contact
26 |
27 | If you have any other questions or need to contact us directly in a private manner send us a note at sdks@split.io
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright © 2021 Split Software, Inc.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Integration Tests/SplitSdkApiClientTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using Splitio.CommonLibraries;
3 | using Splitio.Services.SplitFetcher.Classes;
4 | using System.Threading.Tasks;
5 |
6 | namespace Splitio_Tests.Integration_Tests
7 | {
8 | [TestClass]
9 | public class SplitSdkApiClientTests
10 | {
11 | [TestMethod]
12 | [Ignore]
13 | public async Task ExecuteFetchSplitChangesSuccessful()
14 | {
15 | //Arrange
16 | var baseUrl = "http://sdk-aws-staging.split.io/api/";
17 | var httpHeader = new HTTPHeader()
18 | {
19 | authorizationApiKey = "///PUT API KEY HERE///",
20 | splitSDKMachineIP = "1.0.0.0",
21 | splitSDKMachineName = "localhost",
22 | splitSDKVersion = "net-0.0.0",
23 | splitSDKSpecVersion = "1.2",
24 | };
25 | var SplitSdkApiClient = new SplitSdkApiClient(httpHeader, baseUrl, 10000, 10000);
26 |
27 | //Act
28 | var result = await SplitSdkApiClient.FetchSplitChanges(-1);
29 |
30 | //Assert
31 | Assert.IsTrue(result.Contains("splits"));
32 | }
33 |
34 | [TestMethod]
35 | public async Task ExecuteGetShouldReturnEmptyIfNotAuthorized()
36 | {
37 | //Arrange
38 | var baseUrl = "https://sdk.aws.staging.split.io/api";
39 | var httpHeader = new HTTPHeader()
40 | {
41 | splitSDKMachineIP = "1.0.0.0",
42 | splitSDKMachineName = "localhost",
43 | splitSDKVersion = "net-0.0.0",
44 | splitSDKSpecVersion = "1.2"
45 | };
46 | var SplitSdkApiClient = new SplitSdkApiClient(httpHeader, baseUrl, 10000, 10000);
47 |
48 | //Act
49 | var result = await SplitSdkApiClient.FetchSplitChanges(-1);
50 |
51 | //Assert
52 | Assert.IsTrue(result == string.Empty);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Resources/segment_payed.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "payed",
3 | "added": [
4 | "abcdz",
5 | "bcadz",
6 | "xzydz"
7 | ],
8 | "removed": [],
9 | "since": -1,
10 | "till": 1470947453877
11 | }
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Resources/split.yaml:
--------------------------------------------------------------------------------
1 | # Always on
2 | - testing_split_on:
3 | treatment: "on"
4 | # This one will (or should) return control for non specified keys on whitelist
5 | - testing_split_only_wl:
6 | treatment: "whitelisted"
7 | keys: ["key_for_wl"]
8 | # Playing with whitelists
9 | - testing_split_with_wl:
10 | treatment: "not_in_whitelist"
11 | config: "{\"color\": \"green\"}"
12 | - testing_split_with_wl:
13 | treatment: "one_key_wl"
14 | keys: "key_for_wl"
15 | - testing_split_with_wl:
16 | treatment: "multi_key_wl"
17 | keys: ["key_for_wl_1", "key_for_wl_2"]
18 | config: "{\"color\": \"brown\"}"
19 | # All keys with config
20 | - testing_split_off_with_config:
21 | treatment: "off"
22 | config: "{\"color\": \"green\"}"
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Resources/split.yml:
--------------------------------------------------------------------------------
1 | # Always on
2 | - testing_split_on:
3 | treatment: "on"
4 | # This one will (or should) return control for non specified keys on whitelist
5 | - testing_split_only_wl:
6 | treatment: "whitelisted"
7 | keys: ["key_for_wl"]
8 | # Playing with whitelists
9 | - testing_split_with_wl:
10 | treatment: "not_in_whitelist"
11 | config: "{\"color\": \"green\"}"
12 | - testing_split_with_wl:
13 | treatment: "one_key_wl"
14 | keys: "key_for_wl"
15 | - testing_split_with_wl:
16 | treatment: "multi_key_wl"
17 | keys: ["key_for_wl_1", "key_for_wl_2"]
18 | config: "{\"color\": \"brown\"}"
19 | # All keys with config
20 | - testing_split_off_with_config:
21 | treatment: "off"
22 | config: "{\"color\": \"green\"}"
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Resources/splits_staging_7.json:
--------------------------------------------------------------------------------
1 | {
2 | "splits": [
3 | {
4 | "orgId": null,
5 | "environment": null,
6 | "trafficTypeId": null,
7 | "trafficTypeName": null,
8 | "name": "ta_bucket1_test",
9 | "algo": 2,
10 | "seed": -1222652054,
11 | "trafficAllocation": 1,
12 | "trafficAllocationSeed": -1667452163,
13 | "status": "ACTIVE",
14 | "killed": false,
15 | "defaultTreatment": "default_treatment",
16 | "conditions": [
17 | {
18 | "conditionType": "ROLLOUT",
19 | "matcherGroup": {
20 | "combiner": "AND",
21 | "matchers": [
22 | {
23 | "keySelector": {
24 | "trafficType": "user",
25 | "attribute": null
26 | },
27 | "matcherType": "ALL_KEYS",
28 | "negate": false,
29 | "userDefinedSegmentMatcherData": null,
30 | "whitelistMatcherData": null,
31 | "unaryNumericMatcherData": null,
32 | "betweenMatcherData": null
33 | }
34 | ]
35 | },
36 | "partitions": [
37 | {
38 | "treatment": "rollout_treatment",
39 | "size": 100
40 | }
41 | ]
42 | }
43 | ]
44 | }
45 | ]
46 | }
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Resources/test.splits:
--------------------------------------------------------------------------------
1 | # this is a comment
2 |
3 | reporting_v2 on # sdk.getTreatment(*, reporting_v2) will return 'on'
4 |
5 | double_writes_to_cassandra off
6 |
7 | other_test_feature on
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Unit Tests/Cache/Lru/IDictionaryTests.cs:
--------------------------------------------------------------------------------
1 | /*
2 | https://github.com/mwdavis84/LruCacheNet
3 | Copyright (c) 2018 Mark Davis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 | using Microsoft.VisualStudio.TestTools.UnitTesting;
25 | using Splitio.Services.Cache.Lru;
26 | using System.Collections.Generic;
27 |
28 | namespace Splitio_Tests.Unit_Tests.Cache.Lru
29 | {
30 | [TestClass]
31 | public class IDictionaryTests
32 | {
33 | ///
34 | /// Tests that a handful of IDictionary interface methods work
35 | ///
36 | [TestMethod, TestCategory("IDictionary")]
37 | public void DictionaryTests()
38 | {
39 | IDictionary data = new LruCache(10);
40 | data[0] = 1;
41 | Assert.AreEqual(1, data.Count);
42 | Assert.AreEqual(1, data[0]);
43 | Assert.AreEqual(1, data.Keys.Count);
44 | Assert.AreEqual(1, data.Values.Count);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Unit Tests/Cache/Lru/TestData.cs:
--------------------------------------------------------------------------------
1 | /*
2 | https://github.com/mwdavis84/LruCacheNet
3 | Copyright (c) 2018 Mark Davis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 | namespace Splitio_Tests.Unit_Tests.Cache.Lru
25 | {
26 | internal class TestData
27 | {
28 | public string TestValue1 { get; set; }
29 |
30 | public string TestValue2 { get; set; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Unit Tests/Cache/RedisImpressionCacheTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using Moq;
3 | using Splitio.Domain;
4 | using Splitio.Redis.Services.Cache.Classes;
5 | using Splitio.Redis.Services.Cache.Interfaces;
6 | using StackExchange.Redis;
7 | using System.Collections.Generic;
8 |
9 | namespace Splitio_Tests.Unit_Tests.Cache
10 | {
11 | [TestClass]
12 | public class RedisImpressionCacheTests
13 | {
14 | [TestMethod]
15 | public void AddImpressionSuccessfully()
16 | {
17 | //Arrange
18 | var key = "SPLITIO.impressions";
19 | var redisAdapterMock = new Mock();
20 | var cache = new RedisImpressionsCache(redisAdapterMock.Object, "10.0.0.1", "net-1.0.2", "machine_name_test");
21 | var impressions = new List
22 | {
23 | new KeyImpression { feature = "test", changeNumber = 100, keyName = "date", label = "testdate", time = 10000000 }
24 | };
25 |
26 | //Act
27 | cache.AddItems(impressions);
28 |
29 | //Assert
30 | redisAdapterMock.Verify(mock => mock.ListRightPush(key, It.IsAny()));
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Unit Tests/Client/LocalhostClientForTesting.cs:
--------------------------------------------------------------------------------
1 | using Splitio.Services.Client.Classes;
2 | using Splitio.Services.EngineEvaluator;
3 | using Splitio.Services.Logger;
4 |
5 | namespace Splitio_Tests.Unit_Tests.Client
6 | {
7 | public class LocalhostClientForTesting : LocalhostClient
8 | {
9 | public LocalhostClientForTesting(string filePath,
10 | ISplitLogger log = null,
11 | ISplitter splitter = null,
12 | bool isDestroyed = false) : base(filePath, log)
13 | {
14 | Destroyed = isDestroyed;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Unit Tests/Client/SdkReadinessGatesUnitTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using Splitio.Services.Client.Classes;
3 |
4 | namespace Splitio_Tests.Unit_Tests.Client
5 | {
6 | [TestClass]
7 | public class InMemoryReadinessGatesCacheUnitTests
8 | {
9 | [TestMethod]
10 | public void IsSDKReadyShouldReturnFalseIfSplitsAreNotReady()
11 | {
12 | //Arrange
13 | var gates = new InMemoryReadinessGatesCache();
14 |
15 | //Act
16 | var result = gates.IsSDKReady(0);
17 |
18 | //Assert
19 | Assert.IsFalse(result);
20 | }
21 |
22 | [TestMethod]
23 | public void IsSDKReadyShouldReturnFalseIfAnySegmentIsNotReady()
24 | {
25 | //Arrange
26 | var gates = new InMemoryReadinessGatesCache();
27 | gates.RegisterSegment("any");
28 | gates.SplitsAreReady();
29 |
30 | //Act
31 | var result = gates.IsSDKReady(0);
32 |
33 | //Assert
34 | Assert.IsFalse(result);
35 | }
36 |
37 | [TestMethod]
38 | public void IsSDKReadyShouldReturnTrueIfSplitsAndSegmentsAreReady()
39 | {
40 | //Arrange
41 | var gates = new InMemoryReadinessGatesCache();
42 | gates.RegisterSegment("any");
43 | gates.RegisterSegment("other");
44 | gates.SplitsAreReady();
45 | gates.SegmentIsReady("other");
46 | gates.SegmentIsReady("any");
47 |
48 | //Act
49 | var result = gates.IsSDKReady(0);
50 |
51 | //Assert
52 | Assert.IsTrue(result);
53 | }
54 |
55 | [TestMethod]
56 | public void RegisterSegmentShouldReturnFalseIfSplitsAreReady()
57 | {
58 | //Arrange
59 | var gates = new InMemoryReadinessGatesCache();
60 | gates.SplitsAreReady();
61 |
62 | //Act
63 | var result = gates.RegisterSegment("any");
64 |
65 | //Assert
66 | Assert.IsFalse(result);
67 | }
68 |
69 | [TestMethod]
70 | public void RegisterSegmentShouldReturnFalseIfSegmentNameEmpty()
71 | {
72 | //Arrange
73 | var gates = new InMemoryReadinessGatesCache();
74 |
75 | //Act
76 | var result = gates.RegisterSegment("");
77 |
78 | //Assert
79 | Assert.IsFalse(result);
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Unit Tests/Client/SplitClientForTesting.cs:
--------------------------------------------------------------------------------
1 | using Splitio.Services.Cache.Interfaces;
2 | using Splitio.Services.Client.Classes;
3 | using Splitio.Services.Evaluator;
4 | using Splitio.Services.Events.Interfaces;
5 | using Splitio.Services.Impressions.Interfaces;
6 | using Splitio.Services.InputValidation.Classes;
7 | using Splitio.Services.Logger;
8 | using Splitio.Services.Shared.Interfaces;
9 |
10 | namespace Splitio_Tests.Unit_Tests.Client
11 | {
12 | public class SplitClientForTesting : SplitClient
13 | {
14 | public SplitClientForTesting(ISplitLogger log,
15 | ISplitCache splitCache,
16 | IEventsLog eventsLog,
17 | IImpressionsLog impressionsLog,
18 | IBlockUntilReadyService blockUntilReadyService,
19 | IEvaluator evaluator,
20 | IImpressionsManager impressionsManager)
21 | : base(log)
22 | {
23 | _splitCache = splitCache;
24 | _eventsLog = eventsLog;
25 | _impressionsLog = impressionsLog;
26 | _blockUntilReadyService = blockUntilReadyService;
27 | _trafficTypeValidator = new TrafficTypeValidator(_splitCache, log);
28 | _evaluator = evaluator;
29 | _impressionsManager = impressionsManager;
30 |
31 | ApiKey = "SplitClientForTesting";
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Unit Tests/Events/RedisEventsLogUnitTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using Moq;
3 | using Splitio.Domain;
4 | using Splitio.Redis.Services.Events.Classes;
5 | using Splitio.Services.Shared.Interfaces;
6 | using System;
7 | using System.Collections.Generic;
8 |
9 | namespace Splitio_Tests.Unit_Tests.Events
10 | {
11 | [TestClass]
12 | public class RedisEventsLogUnitTests
13 | {
14 | private readonly Mock> _eventsCacheMock;
15 | private readonly RedisEvenstLog _redisEventsLog;
16 |
17 | public RedisEventsLogUnitTests()
18 | {
19 | _eventsCacheMock = new Mock>();
20 |
21 | _redisEventsLog = new RedisEvenstLog(_eventsCacheMock.Object);
22 | }
23 |
24 | [TestMethod]
25 | public void LogSuccessfully()
26 | {
27 | //Arrange
28 | var eventToLog = new Event { key = "Key1", eventTypeId = "testEventType", trafficTypeName = "testTrafficType", timestamp = 7000, value = 12.34 };
29 |
30 | var wrappedEvent = new WrappedEvent
31 | {
32 | Event = eventToLog,
33 | Size = 1024
34 | };
35 |
36 | //Act
37 | _redisEventsLog.Log(wrappedEvent);
38 |
39 | //Assert
40 | _eventsCacheMock.Verify(mock => mock.AddItems(It.IsAny>()), Times.Once());
41 | }
42 |
43 | [TestMethod]
44 | [ExpectedException(typeof(NotImplementedException))]
45 | public void Start_ReturnsException()
46 | {
47 | //Act
48 | _redisEventsLog.Start();
49 | }
50 |
51 | [TestMethod]
52 | [ExpectedException(typeof(NotImplementedException))]
53 | public void Stop_ReturnsException()
54 | {
55 | //Act
56 | _redisEventsLog.Stop();
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Unit Tests/Impressions/ImpressionsCounterTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using Splitio.Services.Impressions.Classes;
3 | using Splitio_Tests.Resources;
4 | using System;
5 | using System.Linq;
6 |
7 | namespace Splitio_Tests.Unit_Tests.Impressions
8 | {
9 | [TestClass]
10 | public class ImpressionsCounterTests
11 | {
12 | [TestMethod]
13 | public void IncBasicUsage()
14 | {
15 | // Arrange.
16 | var impressionsCounter = new ImpressionsCounter();
17 |
18 | impressionsCounter.Inc("feature1", SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 09, 15, 11, DateTimeKind.Utc)));
19 | impressionsCounter.Inc("feature1", SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 09, 20, 11, DateTimeKind.Utc)));
20 | impressionsCounter.Inc("feature1", SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 09, 50, 11, DateTimeKind.Utc)));
21 | impressionsCounter.Inc("feature2", SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 09, 50, 11, DateTimeKind.Utc)));
22 | impressionsCounter.Inc("feature2", SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 09, 55, 11, DateTimeKind.Utc)));
23 | impressionsCounter.Inc("feature1", SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 10, 50, 11, DateTimeKind.Utc)));
24 |
25 | // Act.
26 | var result = impressionsCounter.PopAll();
27 |
28 | // Assert.
29 | Assert.AreEqual(3, result.FirstOrDefault(x => x.Key.SplitName.Equals("feature1") && x.Key.TimeFrame.Equals(SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 09, 0, 0, DateTimeKind.Utc)))).Value);
30 | Assert.AreEqual(2, result.FirstOrDefault(x => x.Key.SplitName.Equals("feature2") && x.Key.TimeFrame.Equals(SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 09, 0, 0, DateTimeKind.Utc)))).Value);
31 | Assert.AreEqual(1, result.FirstOrDefault(x => x.Key.SplitName.Equals("feature1") && x.Key.TimeFrame.Equals(SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 10, 0, 0, DateTimeKind.Utc)))).Value);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Unit Tests/Impressions/ImpressionsHelperTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using Splitio.Services.Impressions.Classes;
3 | using Splitio_Tests.Resources;
4 | using System;
5 |
6 | namespace Splitio_Tests.Unit_Tests.Impressions
7 | {
8 | [TestClass]
9 | public class ImpressionsHelperTest
10 | {
11 | [TestMethod]
12 | public void TruncateTimeFrame()
13 | {
14 | var expected = SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 10, 0, 0, DateTimeKind.Utc));
15 | Assert.AreEqual(expected, ImpressionsHelper.TruncateTimeFrame(SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 10, 53, 12, DateTimeKind.Utc))));
16 | Assert.AreEqual(expected, ImpressionsHelper.TruncateTimeFrame(SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 10, 00, 00, DateTimeKind.Utc))));
17 | Assert.AreEqual(expected, ImpressionsHelper.TruncateTimeFrame(SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 10, 53, 00, DateTimeKind.Utc))));
18 | Assert.AreEqual(expected, ImpressionsHelper.TruncateTimeFrame(SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 10, 00, 12, DateTimeKind.Utc))));
19 |
20 | expected = SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 00, 00, 00, DateTimeKind.Utc));
21 | Assert.AreEqual(expected, ImpressionsHelper.TruncateTimeFrame(SplitsHelper.MakeTimestamp(new DateTime(2020, 09, 02, 00, 00, 00, DateTimeKind.Utc))));
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Unit Tests/InputValidation/ApiKeyValidatorTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using Moq;
3 | using Splitio.Services.InputValidation.Classes;
4 | using Splitio.Services.Logger;
5 |
6 | namespace Splitio_Tests.Unit_Tests.InputValidation
7 | {
8 | [TestClass]
9 | public class ApiKeyValidatorTests
10 | {
11 | private Mock _log;
12 | private ApiKeyValidator apiKeyValidator;
13 |
14 | [TestInitialize]
15 | public void Initialize()
16 | {
17 | _log = new Mock();
18 |
19 | apiKeyValidator = new ApiKeyValidator(_log.Object);
20 | }
21 |
22 | [TestMethod]
23 | public void Validate_WhenApiKeyIsEmpty_LogOneError()
24 | {
25 | //Arrange
26 | var apiKey = string.Empty;
27 |
28 | //Act
29 | apiKeyValidator.Validate(apiKey);
30 |
31 | //Assert
32 | _log.Verify(mock => mock.Error($"factory instantiation: you passed and empty api_key, api_key must be a non-empty string."), Times.Once());
33 | }
34 |
35 | [TestMethod]
36 | public void Validate_WhenApiKeyIsNull_LogOneError()
37 | {
38 | //Arrange
39 | string apiKey = null;
40 |
41 | //Act
42 | apiKeyValidator.Validate(apiKey);
43 |
44 | //Assert
45 | _log.Verify(mock => mock.Error($"factory instantiation: you passed a null api_key, api_key must be a non-empty string."), Times.Once());
46 | }
47 |
48 | [TestMethod]
49 | public void Validate_WhenApiKeyHasValue_NoLog()
50 | {
51 | //Arrange
52 | string apiKey = "api_key";
53 |
54 | //Act
55 | apiKeyValidator.Validate(apiKey);
56 |
57 | //Assert
58 | _log.Verify(mock => mock.Error(It.IsAny()), Times.Never());
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Unit Tests/Matchers/AllKeysMatcherTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using Splitio.Domain;
3 | using Splitio.Services.Parsing;
4 |
5 | namespace Splitio_Tests.Unit_Tests
6 | {
7 | [TestClass]
8 | public class AllKeysMatcherTests
9 | {
10 | [TestMethod]
11 | public void MatchShouldReturnTrueForAnyKey()
12 | {
13 | //Arrange
14 | var matcher = new AllKeysMatcher();
15 |
16 | //Act
17 | var result = matcher.Match(new Key("test", "test"));
18 |
19 | //Assert
20 | Assert.IsTrue(result);
21 | }
22 |
23 | [TestMethod]
24 | public void MatchShouldReturnFalseIfNull()
25 | {
26 | //Arrange
27 | var matcher = new AllKeysMatcher();
28 |
29 | //Act
30 | var result2 = matcher.Match(new Key((string)null, null));
31 |
32 | //Assert
33 | Assert.IsFalse(result2);
34 | }
35 |
36 | [TestMethod]
37 | public void MatchShouldReturnTrueForAnyStringKey()
38 | {
39 | //Arrange
40 | var matcher = new AllKeysMatcher();
41 |
42 | //Act
43 | var result = matcher.Match("test");
44 |
45 | //Assert
46 | Assert.IsTrue(result);
47 | }
48 |
49 | [TestMethod]
50 | public void MatchShouldReturnFalseIfNullString()
51 | {
52 | //Arrange
53 | var matcher = new AllKeysMatcher();
54 |
55 | //Act
56 | var result2 = matcher.Match((string)null);
57 |
58 | //Assert
59 | Assert.IsFalse(result2);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Splitio-net-core-tests/Unit Tests/SegmentFetcher/ApiSegmentChangeFetcherUnitTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using Moq;
3 | using Splitio.Services.SegmentFetcher.Classes;
4 | using Splitio.Services.SplitFetcher.Interfaces;
5 | using System;
6 | using System.Threading.Tasks;
7 |
8 | namespace Splitio_Tests.Unit_Tests.SegmentFetcher
9 | {
10 | [TestClass]
11 | public class ApiSegmentChangeFetcherUnitTests
12 | {
13 | [TestMethod]
14 | public async Task FetchSegmentChangesSuccessfull()
15 | {
16 | //Arrange
17 | var apiClient = new Mock();
18 | apiClient
19 | .Setup(x=>x.FetchSegmentChanges(It.IsAny(), It.IsAny()))
20 | .Returns(Task.FromResult(@"{
21 | 'name': 'payed',
22 | 'added': [
23 | 'abcdz',
24 | 'bcadz',
25 | 'xzydz'
26 | ],
27 | 'removed': [],
28 | 'since': -1,
29 | 'till': 1470947453877
30 | }"));
31 | var apiFetcher = new ApiSegmentChangeFetcher(apiClient.Object);
32 |
33 | //Act
34 | var result = await apiFetcher.Fetch("payed", -1);
35 |
36 | //Assert
37 | Assert.IsNotNull(result);
38 | Assert.AreEqual("payed", result.name);
39 | Assert.AreEqual(-1, result.since);
40 | Assert.AreEqual(1470947453877, result.till);
41 | Assert.AreEqual(3, result.added.Count);
42 | Assert.AreEqual(0, result.removed.Count);
43 | }
44 |
45 | [TestMethod]
46 | public async Task FetchSegmentChangesWithExcepionSouldReturnNull()
47 | {
48 | var apiClient = new Mock();
49 | apiClient
50 | .Setup(x => x.FetchSegmentChanges(It.IsAny(), It.IsAny()))
51 | .Throws(new Exception());
52 | var apiFetcher = new ApiSegmentChangeFetcher(apiClient.Object);
53 |
54 | //Act
55 | var result = await apiFetcher.Fetch("payed", -1);
56 |
57 | //Assert
58 | Assert.IsNull(result);
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Splitio-net-core.Integration-tests/Resources/EventBackend.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Splitio_net_core.Integration_tests.Resources
4 | {
5 | public class EventBackend
6 | {
7 | public string Key { get; set; }
8 | public string EventTypeId { get; set; }
9 | public string TrafficTypeName { get; set; }
10 | public double? Value { get; set; }
11 | public long Timestamp { get; set; }
12 | public Dictionary Properties { get; set; }
13 | }
14 |
15 | public class EventRedis
16 | {
17 | public MachineRedis M { get; set; }
18 | public EventBackend E { get; set; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Splitio-net-core.Integration-tests/Resources/IntegrationTestsImpressionListener.cs:
--------------------------------------------------------------------------------
1 | using Splitio.Domain;
2 | using Splitio.Services.Impressions.Interfaces;
3 | using Splitio.Services.Shared.Classes;
4 |
5 | namespace Splitio_net_core.Integration_tests.Resources
6 | {
7 | public class IntegrationTestsImpressionListener : IImpressionListener
8 | {
9 | BlockingQueue queue;
10 |
11 | public IntegrationTestsImpressionListener(int size)
12 | {
13 | queue = new BlockingQueue(size);
14 | }
15 |
16 | public void Log(KeyImpression impression)
17 | {
18 | if (queue.HasReachedMaxSize())
19 | {
20 | queue.Dequeue();
21 | }
22 |
23 | queue.Enqueue(impression);
24 | }
25 |
26 | public BlockingQueue GetQueue()
27 | {
28 | return queue;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Splitio-net-core.Integration-tests/Resources/KeyImpressionBackend.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Splitio_net_core.Integration_tests.Resources
4 | {
5 | public class KeyImpressionBackend
6 | {
7 | public string F { get; set; }
8 | public List I { get; set; }
9 | }
10 |
11 | public class ImpressionData
12 | {
13 | public string K { get; set; }
14 | public string B { get; set; }
15 | public string T { get; set; }
16 | public string R { get; set; }
17 | public long? C { get; set; }
18 | public long? M { get; set; }
19 | }
20 |
21 | public class KeyImpressionRedis
22 | {
23 | public MachineRedis M { get; set; }
24 | public InfoRedis I { get; set; }
25 | }
26 |
27 | public class MachineRedis
28 | {
29 | public string S { get; set; }
30 | public string I { get; set; }
31 | public string N { get; set; }
32 | }
33 |
34 | public class InfoRedis
35 | {
36 | public string K { get; set; }
37 | public string B { get; set; }
38 | public string F { get; set; }
39 | public string T { get; set; }
40 | public string R { get; set; }
41 | public long? C { get; set; }
42 | public long? M { get; set; }
43 | }
44 |
45 | public class ImpressionCount
46 | {
47 | public List Pf { get; set; }
48 | }
49 |
50 | public class ImpressionCountData
51 | {
52 | public string F { get; set; }
53 | public long M { get; set; }
54 | public int Rc { get; set; }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Splitio-net-core.Integration-tests/Resources/StatusCodeEnum.cs:
--------------------------------------------------------------------------------
1 | namespace Splitio_net_core.Integration_tests.Resources
2 | {
3 | public enum StatusCodeEnum
4 | {
5 | BadRequest = 400,
6 | InternalServerError = 500
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Splitio-net-core.Integration-tests/Resources/split_changes.json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/splitio/.net-core-client/619ef84a06f44914d6d03a673ffdeab0d36039b8/Splitio-net-core.Integration-tests/Resources/split_changes.json
--------------------------------------------------------------------------------
/Splitio-net-core.Integration-tests/Resources/split_changes_1.json:
--------------------------------------------------------------------------------
1 | {
2 | "splits": [],
3 | "since": 1506703262916,
4 | "till": 1506703262916
5 | }
--------------------------------------------------------------------------------
/Splitio-net-core.Integration-tests/Resources/split_segment1.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "segment1",
3 | "added": [
4 | "Test"
5 | ],
6 | "removed": [],
7 | "since": -1,
8 | "till": 1470947453877
9 | }
--------------------------------------------------------------------------------
/Splitio-net-core.Integration-tests/Resources/split_segment2.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "segment2",
3 | "added": [
4 | "testo2222",
5 | "a_new_split_2"
6 | ],
7 | "removed": [],
8 | "since": -1,
9 | "till": 1470947453878
10 | }
--------------------------------------------------------------------------------
/Splitio-net-core.Integration-tests/Resources/split_segment3.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "segment3",
3 | "added": [
4 | "testo2222",
5 | "test_string_without_attr",
6 | "Test_Save_1"
7 | ],
8 | "removed": [],
9 | "since": -1,
10 | "till": -1
11 | }
--------------------------------------------------------------------------------
/Splitio-net-core.Integration-tests/Resources/split_segment4.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "segment4",
3 | "added": [
4 | "test_in_segment"
5 | ],
6 | "removed": [],
7 | "since": -1,
8 | "till": 1470947453878
9 | }
--------------------------------------------------------------------------------
/Splitio-net-core.Integration-tests/Resources/split_segment4_empty.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "segment4",
3 | "added": [
4 | "test_in_segment"
5 | ],
6 | "removed": [],
7 | "since": 1470947453878,
8 | "till": 1470947453878
9 | }
--------------------------------------------------------------------------------
/Splitio-net-core.Integration-tests/Resources/split_segment4_updated.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "segment4",
3 | "added": [],
4 | "removed": [ "test_in_segment" ],
5 | "since": 1470947453878,
6 | "till": 1470947453879
7 | }
--------------------------------------------------------------------------------
/Splitio-net-core.Integration-tests/Resources/split_segment4_updated_empty.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "segment4",
3 | "added": [],
4 | "removed": [ "test_in_segment" ],
5 | "since": 1470947453879,
6 | "till": 1470947453879
7 | }
--------------------------------------------------------------------------------
/Splitio-net-core.Integration-tests/Resources/splits_push2.json:
--------------------------------------------------------------------------------
1 | {
2 | "splits": [],
3 | "since": 1585948850109,
4 | "till": 1585948850109
5 | }
--------------------------------------------------------------------------------
/Splitio-net-core.Integration-tests/Resources/splits_push4.json:
--------------------------------------------------------------------------------
1 | {
2 | "splits": [],
3 | "since": 1585948850111,
4 | "till": 1585948850111
5 | }
--------------------------------------------------------------------------------
/Splitio-net-core.Redis/Services/Cache/Classes/RedisCacheBase.cs:
--------------------------------------------------------------------------------
1 | using Splitio.Redis.Services.Cache.Interfaces;
2 |
3 | namespace Splitio.Redis.Services.Cache.Classes
4 | {
5 | public abstract class RedisCacheBase
6 | {
7 | private const string RedisKeyPrefixFormat = "SPLITIO/{sdk-language-version}/{instance-id}/";
8 |
9 | protected IRedisAdapter _redisAdapter;
10 |
11 | protected string RedisKeyPrefix;
12 | protected string UserPrefix;
13 | protected string SdkVersion;
14 | protected string MachineIp;
15 | protected string MachineName;
16 |
17 | public RedisCacheBase(IRedisAdapter redisAdapter,
18 | string userPrefix = null)
19 | {
20 | _redisAdapter = redisAdapter;
21 |
22 | UserPrefix = userPrefix;
23 | RedisKeyPrefix = "SPLITIO.";
24 |
25 | if (!string.IsNullOrEmpty(userPrefix))
26 | {
27 | RedisKeyPrefix = userPrefix + "." + RedisKeyPrefix;
28 | }
29 | }
30 |
31 | public RedisCacheBase(IRedisAdapter redisAdapter,
32 | string machineIP,
33 | string sdkVersion,
34 | string machineName,
35 | string userPrefix = null)
36 | {
37 | _redisAdapter = redisAdapter;
38 |
39 | UserPrefix = userPrefix;
40 | MachineIp = machineIP;
41 | SdkVersion = sdkVersion;
42 | MachineName = machineName;
43 |
44 | RedisKeyPrefix = RedisKeyPrefixFormat
45 | .Replace("{sdk-language-version}", sdkVersion)
46 | .Replace("{instance-id}", machineIP);
47 |
48 | if (!string.IsNullOrEmpty(userPrefix))
49 | {
50 | RedisKeyPrefix = userPrefix + "." + RedisKeyPrefix;
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Splitio-net-core.Redis/Services/Cache/Classes/RedisEventsCache.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Newtonsoft.Json;
3 | using Splitio.Domain;
4 | using Splitio.Redis.Services.Cache.Interfaces;
5 | using Splitio.Services.Shared.Interfaces;
6 |
7 | namespace Splitio.Redis.Services.Cache.Classes
8 | {
9 | public class RedisEventsCache : RedisCacheBase, ISimpleCache
10 | {
11 | private readonly string _machineName;
12 | private readonly string _machineIP;
13 | private readonly string _sdkVersion;
14 |
15 | public RedisEventsCache(IRedisAdapter redisAdapter,
16 | string machineName,
17 | string machineIP,
18 | string sdkVersion,
19 | string userPrefix = null) : base(redisAdapter, userPrefix)
20 | {
21 | _machineName = machineName;
22 | _machineIP = machineIP;
23 | _sdkVersion = sdkVersion;
24 | }
25 |
26 | public void AddItems(IList items)
27 | {
28 | foreach (var item in items)
29 | {
30 | var eventJson = JsonConvert.SerializeObject(new
31 | {
32 | m = new { s = _sdkVersion, i = _machineIP, n = _machineName },
33 | e = item.Event
34 | });
35 |
36 | _redisAdapter.ListRightPush($"{RedisKeyPrefix}events", eventJson);
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Splitio-net-core.Redis/Services/Cache/Classes/RedisImpressionsCache.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using Splitio.Domain;
3 | using Splitio.Redis.Services.Cache.Interfaces;
4 | using Splitio.Services.Shared.Interfaces;
5 | using StackExchange.Redis;
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Linq;
9 |
10 | namespace Splitio.Redis.Services.Cache.Classes
11 | {
12 | public class RedisImpressionsCache : RedisCacheBase, ISimpleCache
13 | {
14 | public RedisImpressionsCache(IRedisAdapter redisAdapter,
15 | string machineIP,
16 | string sdkVersion,
17 | string machineName,
18 | string userPrefix = null) : base(redisAdapter, machineIP, sdkVersion, machineName, userPrefix)
19 | { }
20 |
21 | public void AddItems(IList items)
22 | {
23 | var key = string.Format("{0}SPLITIO.impressions", string.IsNullOrEmpty(UserPrefix) ? string.Empty : $"{UserPrefix}.");
24 |
25 | var impressions = items.Select(item => JsonConvert.SerializeObject(new
26 | {
27 | m = new { s = SdkVersion, i = MachineIp, n = MachineName },
28 | i = new { k = item.keyName, b = item.bucketingKey, f = item.feature, t = item.treatment, r = item.label, c = item.changeNumber, m = item.time }
29 | }));
30 |
31 | var lengthRedis = _redisAdapter.ListRightPush(key, impressions.Select(i => (RedisValue)i).ToArray());
32 |
33 | if (lengthRedis == items.Count)
34 | {
35 | _redisAdapter.KeyExpire(key, new TimeSpan(0, 0, 3600));
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Splitio-net-core.Redis/Services/Cache/Interfaces/IRedisAdapter.cs:
--------------------------------------------------------------------------------
1 | using StackExchange.Redis;
2 | using System;
3 |
4 | namespace Splitio.Redis.Services.Cache.Interfaces
5 | {
6 | public interface IRedisAdapter
7 | {
8 | bool Set(string key, string value);
9 |
10 | string Get(string key);
11 |
12 | RedisValue[] MGet(RedisKey[] keys);
13 |
14 | RedisKey[] Keys(string pattern);
15 |
16 | bool Del(string key);
17 |
18 | long Del(RedisKey[] keys);
19 |
20 | bool SAdd(string key, RedisValue value);
21 |
22 | long SAdd(string key, RedisValue[] values);
23 |
24 | long SRem(string key, RedisValue[] values);
25 |
26 | long ListRightPush(string key, RedisValue value);
27 |
28 | long ListRightPush(string key, RedisValue[] values);
29 |
30 | bool SIsMember(string key, string value);
31 |
32 | RedisValue[] SMembers(string key);
33 |
34 | long IcrBy(string key, long delta);
35 |
36 | void Flush();
37 |
38 | bool IsConnected();
39 |
40 | bool KeyExpire(string key, TimeSpan expiry);
41 |
42 | RedisValue[] ListRange(RedisKey key, long start = 0, long stop = -1);
43 |
44 | void Connect();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Splitio-net-core.Redis/Services/Domain/RedisConfig.cs:
--------------------------------------------------------------------------------
1 | using Splitio.Domain;
2 |
3 | namespace Splitio.Redis.Services.Domain
4 | {
5 | public class RedisConfig : BaseConfig
6 | {
7 | public string RedisHost { get; set; }
8 | public string RedisPort { get; set; }
9 | public string RedisPassword { get; set; }
10 | public string RedisUserPrefix { get; set; }
11 | public int RedisDatabase { get; set; }
12 | public int RedisConnectTimeout { get; set; }
13 | public int RedisConnectRetry { get; set; }
14 | public int RedisSyncTimeout { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Splitio-net-core.Redis/Services/Events/Classes/RedisEventsLog.cs:
--------------------------------------------------------------------------------
1 | using Splitio.Domain;
2 | using Splitio.Services.Events.Interfaces;
3 | using Splitio.Services.Shared.Interfaces;
4 | using System.Collections.Generic;
5 |
6 | namespace Splitio.Redis.Services.Events.Classes
7 | {
8 | public class RedisEvenstLog : IEventsLog
9 | {
10 | private readonly ISimpleCache _eventsCache;
11 |
12 | public RedisEvenstLog(ISimpleCache eventsCache)
13 | {
14 | _eventsCache = eventsCache;
15 | }
16 |
17 | public void Log(WrappedEvent wrappedEvent)
18 | {
19 | _eventsCache.AddItems(new List { wrappedEvent });
20 | }
21 |
22 | public void Start()
23 | {
24 | throw new System.NotImplementedException();
25 | }
26 |
27 | public void Stop()
28 | {
29 | throw new System.NotImplementedException();
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/Splitio-net-core.Redis/Services/Impressions/Classes/RedisImpressionLog.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Splitio.Domain;
3 | using Splitio.Services.Impressions.Interfaces;
4 | using Splitio.Services.Shared.Interfaces;
5 |
6 | namespace Splitio.Redis.Services.Impressions.Classes
7 | {
8 | public class RedisImpressionLog : IImpressionsLog
9 | {
10 | private readonly ISimpleCache _impressionsCache;
11 |
12 | public RedisImpressionLog(ISimpleCache impressionsCache)
13 | {
14 | _impressionsCache = impressionsCache;
15 | }
16 |
17 | public void Log(IList impressions)
18 | {
19 | _impressionsCache.AddItems(impressions);
20 | }
21 |
22 | public void Start()
23 | {
24 | throw new System.NotImplementedException();
25 | }
26 |
27 | public void Stop()
28 | {
29 | throw new System.NotImplementedException();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Splitio-net-core.Redis/Services/Metrics/Classes/RedisMetricsLog.cs:
--------------------------------------------------------------------------------
1 | using Splitio.Services.Cache.Interfaces;
2 | using Splitio.Services.Metrics.Interfaces;
3 |
4 | namespace Splitio.Redis.Services.Metrics.Classes
5 | {
6 | public class RedisMetricsLog : IMetricsLog
7 | {
8 | IMetricsCache metricsCache;
9 |
10 | public RedisMetricsLog(IMetricsCache metricsCache)
11 | {
12 | this.metricsCache = metricsCache;
13 | }
14 |
15 | public void Count(string counterName, long delta)
16 | {
17 | if (string.IsNullOrEmpty(counterName) || delta <= 0)
18 | {
19 | return;
20 | }
21 |
22 | metricsCache.IncrementCount(counterName, delta);
23 | }
24 |
25 | public void Time(string operation, long miliseconds)
26 | {
27 | if (string.IsNullOrEmpty(operation) || miliseconds < 0)
28 | {
29 | return;
30 | }
31 |
32 | metricsCache.SetLatency(operation, miliseconds);
33 | }
34 |
35 | public void Gauge(string gauge, long value)
36 | {
37 | if (string.IsNullOrEmpty(gauge) || value < 0)
38 | {
39 | return;
40 | }
41 |
42 | metricsCache.SetGauge(gauge, value);
43 | }
44 |
45 | public void Clear()
46 | {
47 | return;
48 | }
49 |
50 | public void Start()
51 | {
52 | return;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Splitio-net-core.Redis/Services/Parsing/Classes/RedisSplitParser.cs:
--------------------------------------------------------------------------------
1 | using Splitio.Domain;
2 | using Splitio.Services.Cache.Interfaces;
3 | using Splitio.Services.Parsing;
4 |
5 | namespace Splitio.Redis.Services.Parsing.Classes
6 | {
7 | public class RedisSplitParser : SplitParser
8 | {
9 | public RedisSplitParser(ISegmentCache segmentsCache)
10 | {
11 | _segmentsCache = segmentsCache;
12 | }
13 |
14 | protected override IMatcher GetInSegmentMatcher(MatcherDefinition matcherDefinition, ParsedSplit parsedSplit)
15 | {
16 | var matcherData = matcherDefinition.userDefinedSegmentMatcherData;
17 |
18 | return new UserDefinedSegmentMatcher(matcherData.segmentName, _segmentsCache);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Splitio-net-core.Redis/Services/Shared/RedisBlockUntilReadyService.cs:
--------------------------------------------------------------------------------
1 | using Splitio.Redis.Services.Cache.Interfaces;
2 | using Splitio.Services.Shared.Interfaces;
3 | using System;
4 | using System.Diagnostics;
5 | using System.Threading;
6 |
7 | namespace Splitio.Redis.Services.Shared
8 | {
9 | public class RedisBlockUntilReadyService : IBlockUntilReadyService
10 | {
11 | private readonly IRedisAdapter _redisAdapter;
12 |
13 | public RedisBlockUntilReadyService(IRedisAdapter redisAdapter)
14 | {
15 | _redisAdapter = redisAdapter;
16 | }
17 |
18 | public void BlockUntilReady(int blockMilisecondsUntilReady)
19 | {
20 | if (!IsSdkReady())
21 | {
22 | var ready = false;
23 | var clock = new Stopwatch();
24 | clock.Start();
25 |
26 | while (clock.ElapsedMilliseconds <= blockMilisecondsUntilReady)
27 | {
28 | if (IsSdkReady())
29 | {
30 | ready = true;
31 | break;
32 | }
33 | }
34 |
35 | if (!ready) throw new TimeoutException($"SDK was not ready in {blockMilisecondsUntilReady}. Could not connect to Redis");
36 | }
37 | }
38 |
39 | public bool IsSdkReady()
40 | {
41 | return _redisAdapter.IsConnected();
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Splitio-net-core.Redis/SplitioRedis.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/splitio/.net-core-client/619ef84a06f44914d6d03a673ffdeab0d36039b8/Splitio-net-core.Redis/SplitioRedis.snk
--------------------------------------------------------------------------------
/Splitio.TestSupport/SplitClientForTest.cs:
--------------------------------------------------------------------------------
1 | using Splitio.Domain;
2 | using Splitio.Services.Logger;
3 | using System.Collections.Generic;
4 |
5 | namespace Splitio.Services.Client.Classes
6 | {
7 | public class SplitClientForTest : SplitClient
8 | {
9 | private Dictionary _tests;
10 |
11 | public SplitClientForTest(ISplitLogger log) : base(log)
12 | {
13 | _tests = new Dictionary();
14 | }
15 |
16 | public override void Destroy()
17 | {
18 | _tests = new Dictionary();
19 | }
20 |
21 | public void ClearTreatments()
22 | {
23 | _tests = new Dictionary();
24 | }
25 |
26 | public void RegisterTreatments(Dictionary treatments)
27 | {
28 | foreach (var treatment in treatments)
29 | {
30 | if (!_tests.ContainsKey(treatment.Key))
31 | {
32 | _tests.Add(treatment.Key, treatment.Value);
33 | }
34 | }
35 | }
36 |
37 | public void RegisterTreatment(string feature, string treatment)
38 | {
39 | _tests.Add(feature, treatment);
40 | }
41 |
42 | public string GetTreatment(string key, string feature)
43 | {
44 | return _tests.ContainsKey(feature) ? _tests[feature] : "control";
45 | }
46 |
47 | public override string GetTreatment(string key, string feature, Dictionary attributes = null)
48 | {
49 | return GetTreatment(key, feature);
50 | }
51 |
52 | public override string GetTreatment(Key key, string feature, Dictionary attributes = null)
53 | {
54 | return _tests.ContainsKey(feature) ? _tests[feature] : "control";
55 | }
56 | }
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/Splitio.TestSupport/SplitScenario.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Reflection;
5 | using Xunit;
6 |
7 | namespace Splitio.TestSupport
8 | {
9 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
10 | public class SplitScenario : ClassDataAttribute
11 | {
12 | public SplitTest[] features { get; private set; }
13 |
14 | [JsonConstructor]
15 | public SplitScenario(SplitTest[] features) : base(typeof(object))
16 | {
17 | this.features = features;
18 | }
19 |
20 | public SplitScenario(string features) : base(typeof(object))
21 | {
22 | this.features = JsonConvert.DeserializeObject(features);
23 | }
24 |
25 | public override IEnumerable