Skip to content

Commit

Permalink
Merge pull request #8 from configcat/sdkkey
Browse files Browse the repository at this point in the history
Sdkkey
  • Loading branch information
ConfigCat authored Apr 9, 2020
2 parents 4f81547 + caab1cf commit 60e0cac
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 68 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ dotnet add package ConfigCat.Client
using ConfigCat.Client;
```

### 3. Go to <a href="https://app.configcat.com/connect" target="_blank">Connect your application</a> tab to get your *API Key*:
![API-KEY](https://raw.githubusercontent.com/ConfigCat/.net-sdk/master/media/readme01.png "API-KEY")
### 3. Go to <a href="https://app.configcat.com/sdkkey" target="_blank">Connect your application</a> tab to get your *SDK Key*:
![SDK-KEY](https://raw.githubusercontent.com/ConfigCat/.net-sdk/master/media/readme01.png "SDK-KEY")

### 4. Create a **ConfigCat** client instance:
```c#
var client = new ConfigCatClient("#YOUR-API-KEY#");
var client = new ConfigCatClient("#YOUR-SDK-KEY#");
```

> We strongly recommend using the *ConfigCat Client* as a Singleton object in your application.
Expand Down Expand Up @@ -84,8 +84,8 @@ var isMyAwesomeFeatureEnabled = client.GetValue(
## Polling Modes
The ConfigCat SDK supports 3 different polling mechanisms to acquire the setting values from ConfigCat. After latest setting values are downloaded, they are stored in the internal cache then all requests are served from there. Read more about Polling Modes and how to use them at [ConfigCat Docs](https://docs.configcat.com/docs/sdk-reference/csharp/).

## Support
If you need help how to use this SDK feel free to to contact the ConfigCat Staff on https://configcat.com. We're happy to help.
## Need help?
https://configcat.com/support

## Contributing
Contributions are welcome.
Expand Down
Binary file modified media/readme01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion samples/ASP.NETCore/WebApplication/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void ConfigureServices(IServiceCollection services)

var configCatClient = new ConfigCatClient(new LazyLoadConfiguration
{
ApiKey = Configuration["ConfigCatApiKey"],
SdkKey = Configuration["ConfigCatSdkKey"],
CacheTimeToLiveSeconds = 120
});
configCatClient.LogLevel = LogLevel.Info;
Expand Down
2 changes: 1 addition & 1 deletion samples/ASP.NETCore/WebApplication/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"Default": "Warning"
}
},
"ConfigCatApiKey": "PKDVCLf-Hq-h-kCzMp-L7Q/HhOWfwVtZ0mb30i9wi17GQ"
"ConfigCatSdkKey": "PKDVCLf-Hq-h-kCzMp-L7Q/HhOWfwVtZ0mb30i9wi17GQ"

}
2 changes: 1 addition & 1 deletion samples/ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Program
{
static void Main(string[] args)
{
// Creating the ConfigCat client instance using the API key
// Creating the ConfigCat client instance using the SDK Key
var client = new ConfigCatClient("PKDVCLf-Hq-h-kCzMp-L7Q/HhOWfwVtZ0mb30i9wi17GQ");

// Setting log level to Info to show detailed feature flag evaluation
Expand Down
2 changes: 1 addition & 1 deletion samples/FileLoggerSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static void Main(string[] args)

var clientConfiguration = new AutoPollConfiguration
{
ApiKey = "YOUR-API-KEY",
SdkKey = "YOUR-SDK-KEY",
Logger = new MyFileLogger(filePath, logLevel),
PollIntervalSeconds = 5
};
Expand Down
14 changes: 7 additions & 7 deletions src/ConfigCat.Client.Tests/BaseUrlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ namespace ConfigCat.Client.Tests
[TestClass]
public class BaseUrlTests
{
private const string APIKEY = "PKDVCLf-Hq-h-kCzMp-L7Q/psuH7BGHoUmdONrzzUOY7A";
private const string SDKKEY = "PKDVCLf-Hq-h-kCzMp-L7Q/psuH7BGHoUmdONrzzUOY7A";

private readonly Uri workingBaseUrl = new Uri("https://cdn.configcat.com");
private readonly Uri notWorkingBaseUrl = new Uri("https://thiswillnotwork.configcat.com");

[TestMethod]
public void BaseUrl_Override_AutoPoll_Works()
{
var client = ConfigCatClientBuilder.Initialize(APIKEY)
var client = ConfigCatClientBuilder.Initialize(SDKKEY)
.WithAutoPoll()
.WithBaseUrl(workingBaseUrl)
.Create();

var actual = client.GetValue("stringDefaultCat", "N/A");
Assert.AreEqual("Cat", actual);

client = ConfigCatClientBuilder.Initialize(APIKEY)
client = ConfigCatClientBuilder.Initialize(SDKKEY)
.WithAutoPoll()
.WithBaseUrl(notWorkingBaseUrl)
.Create();
Expand All @@ -34,15 +34,15 @@ public void BaseUrl_Override_AutoPoll_Works()
[TestMethod]
public void BaseUrl_Override_ManualPoll_Works()
{
var client = ConfigCatClientBuilder.Initialize(APIKEY)
var client = ConfigCatClientBuilder.Initialize(SDKKEY)
.WithManualPoll()
.WithBaseUrl(workingBaseUrl)
.Create();
client.ForceRefresh();
var actual = client.GetValue("stringDefaultCat", "N/A");
Assert.AreEqual("Cat", actual);

client = ConfigCatClientBuilder.Initialize(APIKEY)
client = ConfigCatClientBuilder.Initialize(SDKKEY)
.WithManualPoll()
.WithBaseUrl(notWorkingBaseUrl)
.Create();
Expand All @@ -54,15 +54,15 @@ public void BaseUrl_Override_ManualPoll_Works()
[TestMethod]
public void BaseUrl_Override_LazyLoad_Works()
{
var client = ConfigCatClientBuilder.Initialize(APIKEY)
var client = ConfigCatClientBuilder.Initialize(SDKKEY)
.WithLazyLoad()
.WithBaseUrl(workingBaseUrl)
.Create();

var actual = client.GetValue("stringDefaultCat", "N/A");
Assert.AreEqual("Cat", actual);

client = ConfigCatClientBuilder.Initialize(APIKEY)
client = ConfigCatClientBuilder.Initialize(SDKKEY)
.WithLazyLoad()
.WithBaseUrl(notWorkingBaseUrl)
.Create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace ConfigCat.Client.Tests
[TestClass]
public class BasicConfigCatClientIntegrationTests
{
private const string APIKEY = "PKDVCLf-Hq-h-kCzMp-L7Q/psuH7BGHoUmdONrzzUOY7A";
private const string SDKKEY = "PKDVCLf-Hq-h-kCzMp-L7Q/psuH7BGHoUmdONrzzUOY7A";

private static readonly IConfigCatClient client = new ConfigCatClient(APIKEY);
private static readonly IConfigCatClient client = new ConfigCatClient(SDKKEY);

private static readonly ILogger consoleLogger = new ConsoleLogger(LogLevel.Debug);

Expand All @@ -26,7 +26,7 @@ public static void ClassCleanup()
public void ManualPollGetValue()
{
IConfigCatClient manualPollClient = ConfigCatClientBuilder
.Initialize(APIKEY)
.Initialize(SDKKEY)
.WithLogger(consoleLogger)
.WithManualPoll()
.Create();
Expand All @@ -40,7 +40,7 @@ public void ManualPollGetValue()
public void AutoPollGetValue()
{
IConfigCatClient client = ConfigCatClientBuilder
.Initialize(APIKEY)
.Initialize(SDKKEY)
.WithLogger(consoleLogger)
.WithAutoPoll()
.WithMaxInitWaitTimeSeconds(30)
Expand All @@ -54,7 +54,7 @@ public void AutoPollGetValue()
public void LazyLoadGetValue()
{
IConfigCatClient client = ConfigCatClientBuilder
.Initialize(APIKEY)
.Initialize(SDKKEY)
.WithLogger(consoleLogger)
.WithLazyLoad()
.WithCacheTimeToLiveSeconds(30)
Expand All @@ -67,7 +67,7 @@ public void LazyLoadGetValue()
public async Task ManualPollGetValueAsync()
{
IConfigCatClient client = ConfigCatClientBuilder
.Initialize(APIKEY)
.Initialize(SDKKEY)
.WithLogger(consoleLogger)
.WithManualPoll()
.Create();
Expand All @@ -81,7 +81,7 @@ public async Task ManualPollGetValueAsync()
public async Task AutoPollGetValueAsync()
{
IConfigCatClient client = ConfigCatClientBuilder
.Initialize(APIKEY)
.Initialize(SDKKEY)
.WithLogger(consoleLogger)
.WithAutoPoll()
.WithMaxInitWaitTimeSeconds(30)
Expand All @@ -95,7 +95,7 @@ public async Task AutoPollGetValueAsync()
public async Task LazyLoadGetValueAsync()
{
IConfigCatClient client = ConfigCatClientBuilder
.Initialize(APIKEY)
.Initialize(SDKKEY)
.WithLogger(consoleLogger)
.WithLazyLoad()
.WithCacheTimeToLiveSeconds(30)
Expand All @@ -108,7 +108,7 @@ public async Task LazyLoadGetValueAsync()
public void GetAllKeys()
{
IConfigCatClient manualPollClient = ConfigCatClientBuilder
.Initialize(APIKEY)
.Initialize(SDKKEY)
.WithLogger(consoleLogger)
.WithManualPoll()
.Create();
Expand Down
8 changes: 4 additions & 4 deletions src/ConfigCat.Client.Tests/ConfigCacheTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ConfigCat.Client.Tests
[TestClass]
public class ConfigCacheTests
{
private const string APIKEY = "PKDVCLf-Hq-h-kCzMp-L7Q/psuH7BGHoUmdONrzzUOY7A";
private const string SDKKEY = "PKDVCLf-Hq-h-kCzMp-L7Q/psuH7BGHoUmdONrzzUOY7A";

[TestMethod]
public void ConfigCache_Override_AutoPoll_Works()
Expand All @@ -20,7 +20,7 @@ public void ConfigCache_Override_AutoPoll_Works()

configCacheMock.Setup(c => c.Get()).Returns(() => cachedConfig);

var client = ConfigCatClientBuilder.Initialize(APIKEY).WithAutoPoll().WithConfigCache(configCacheMock.Object).Create();
var client = ConfigCatClientBuilder.Initialize(SDKKEY).WithAutoPoll().WithConfigCache(configCacheMock.Object).Create();

var actual = client.GetValue("stringDefaultCat", "N/A");
Assert.AreEqual("Cat", actual);
Expand All @@ -41,7 +41,7 @@ public void ConfigCache_Override_ManualPoll_Works()

configCacheMock.Setup(c => c.Get()).Returns(() => cachedConfig);

var client = ConfigCatClientBuilder.Initialize(APIKEY).WithManualPoll().WithConfigCache(configCacheMock.Object).Create();
var client = ConfigCatClientBuilder.Initialize(SDKKEY).WithManualPoll().WithConfigCache(configCacheMock.Object).Create();

configCacheMock.Verify(c => c.Set(It.IsAny<ProjectConfig>()), Times.Never);
configCacheMock.Verify(c => c.Get(), Times.Never);
Expand Down Expand Up @@ -71,7 +71,7 @@ public void ConfigCache_Override_LazyLoad_Works()

configCacheMock.Setup(c => c.Get()).Returns(() => cachedConfig);

var client = ConfigCatClientBuilder.Initialize(APIKEY).WithLazyLoad().WithConfigCache(configCacheMock.Object).Create();
var client = ConfigCatClientBuilder.Initialize(SDKKEY).WithLazyLoad().WithConfigCache(configCacheMock.Object).Create();

var actual = client.GetValue("stringDefaultCat", "N/A");
Assert.AreEqual("Cat", actual);
Expand Down
36 changes: 18 additions & 18 deletions src/ConfigCat.Client.Tests/ConfigCatClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,29 @@ public void TestInitialize()

[ExpectedException(typeof(ArgumentException))]
[TestMethod]
public void CreateAnInstance_WhenApiKeyIsEmpty_ShouldThrowArgumentNullException()
public void CreateAnInstance_WhenSdkKeyIsEmpty_ShouldThrowArgumentNullException()
{
string apiKey = string.Empty;
string sdkKey = string.Empty;

new ConfigCatClient(apiKey);
new ConfigCatClient(sdkKey);
}

[ExpectedException(typeof(ArgumentException))]
[TestMethod]
public void CreateAnInstance_WhenApiKeyIsNull_ShouldThrowArgumentNullException()
public void CreateAnInstance_WhenSdkKeyIsNull_ShouldThrowArgumentNullException()
{
string apiKey = null;
string sdkKey = null;

new ConfigCatClient(apiKey);
new ConfigCatClient(sdkKey);
}

[ExpectedException(typeof(ArgumentException))]
[TestMethod]
public void CreateAnInstance_WhenAutoPollConfigurationApiKeyIsNull_ShouldThrowArgumentNullException()
public void CreateAnInstance_WhenAutoPollConfigurationSdkKeyIsNull_ShouldThrowArgumentNullException()
{
var clientConfiguration = new AutoPollConfiguration
{
ApiKey = null
SdkKey = null
};

new ConfigCatClient(clientConfiguration);
Expand All @@ -63,7 +63,7 @@ public void CreateAnInstance_WhenAutoPollConfigurationPollIntervalsZero_ShouldTh
{
var clientConfiguration = new AutoPollConfiguration
{
ApiKey = "hsdrTr4sxbHdSgdhHRZds346hdgsS2vfsgf/GsdrTr4sxbHdSgdhHRZds346hdOPsSgvfsgf",
SdkKey = "hsdrTr4sxbHdSgdhHRZds346hdgsS2vfsgf/GsdrTr4sxbHdSgdhHRZds346hdOPsSgvfsgf",
PollIntervalSeconds = 0
};

Expand All @@ -72,11 +72,11 @@ public void CreateAnInstance_WhenAutoPollConfigurationPollIntervalsZero_ShouldTh

[ExpectedException(typeof(ArgumentException))]
[TestMethod]
public void CreateAnInstance_WhenConfigurationApiKeyIsEmpty_ShouldThrowArgumentNullException()
public void CreateAnInstance_WhenConfigurationSdkKeyIsEmpty_ShouldThrowArgumentNullException()
{
var clientConfiguration = new AutoPollConfiguration
{
ApiKey = string.Empty
SdkKey = string.Empty
};

new ConfigCatClient(clientConfiguration);
Expand All @@ -88,7 +88,7 @@ public void CreateAnInstance_WhenLazyLoadConfigurationTimeToLiveSecondsIsZero_Sh
{
var clientConfiguration = new LazyLoadConfiguration
{
ApiKey = "hsdrTr4sxbHdSgdhHRZds346hdgsS2vfsgf/GsdrTr4sxbHdSgdhHRZds346hdOPsSgvfsgf",
SdkKey = "hsdrTr4sxbHdSgdhHRZds346hdgsS2vfsgf/GsdrTr4sxbHdSgdhHRZds346hdOPsSgvfsgf",
CacheTimeToLiveSeconds = 0
};

Expand Down Expand Up @@ -128,7 +128,7 @@ public void CreateAnInstance_WhenLoggerIsNull_ShouldThrowArgumentNullException()
{
var clientConfiguration = new AutoPollConfiguration
{
ApiKey = "hsdrTr4sxbHdSgdhHRZds346hdgsS2vfsgf/GsdrTr4sxbHdSgdhHRZds346hdOPsSgvfsgf",
SdkKey = "hsdrTr4sxbHdSgdhHRZds346hdgsS2vfsgf/GsdrTr4sxbHdSgdhHRZds346hdOPsSgvfsgf",
Logger = null
};

Expand All @@ -141,24 +141,24 @@ public void CreateAnInstance_WithValidConfiguration_ShouldCreateAnInstance()
{
var config = new AutoPollConfiguration
{
ApiKey = "hsdrTr4sxbHdSgdhHRZds346hdgsS2vfsgf/GsdrTr4sxbHdSgdhHRZds346hdOPsSgvfsgf"
SdkKey = "hsdrTr4sxbHdSgdhHRZds346hdgsS2vfsgf/GsdrTr4sxbHdSgdhHRZds346hdOPsSgvfsgf"
};

new ConfigCatClient(config);
}

[TestMethod]
public void CreateAnInstance_WithApiKey_ShouldCreateAnInstance()
public void CreateAnInstance_WithSdkKey_ShouldCreateAnInstance()
{
string apiKey = "hsdrTr4sxbHdSgdhHRZds346hdgsS2vfsgf/GsdrTr4sxbHdSgdhHRZds346hdOPsSgvfsgf";
string sdkKey = "hsdrTr4sxbHdSgdhHRZds346hdgsS2vfsgf/GsdrTr4sxbHdSgdhHRZds346hdOPsSgvfsgf";

new ConfigCatClient(apiKey);
new ConfigCatClient(sdkKey);
}

[TestMethod]
public void CreateConfigurationBuilderInstance_ShouldCreateAnInstance()
{
var builder = ConfigCatClient.Create("APIKEY");
var builder = ConfigCatClient.Create("SDKKEY");

Assert.IsNotNull(builder);
}
Expand Down
8 changes: 4 additions & 4 deletions src/ConfigCat.Client.Tests/CustomHttpClientHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace ConfigCat.Client.Tests
[TestClass]
public class CustomHttpClientHandlerTests
{
private const string APIKEY = "PKDVCLf-Hq-h-kCzMp-L7Q/psuH7BGHoUmdONrzzUOY7A";
private const string SDKKEY = "PKDVCLf-Hq-h-kCzMp-L7Q/psuH7BGHoUmdONrzzUOY7A";
private readonly MyHttpClientHandler httpClientHandler = new MyHttpClientHandler();

[TestInitialize]
Expand All @@ -21,7 +21,7 @@ public void AutoPoll_WithHttpClientHandlerOverride_ShouldReturnCatUseCustomImple
{
// Arrange

var client = ConfigCatClientBuilder.Initialize(APIKEY)
var client = ConfigCatClientBuilder.Initialize(SDKKEY)
.WithAutoPoll()
.WithHttpClientHandler(httpClientHandler)
.Create();
Expand All @@ -41,7 +41,7 @@ public void ManualPoll_WithHttpClientHandlerOverride_ShouldReturnCatUseCustomImp
{
// Arrange

var client = ConfigCatClientBuilder.Initialize(APIKEY)
var client = ConfigCatClientBuilder.Initialize(SDKKEY)
.WithManualPoll()
.WithHttpClientHandler(httpClientHandler)
.Create();
Expand All @@ -62,7 +62,7 @@ public void LazyLoad_WithHttpClientHandlerOverride_ShouldReturnCatUseCustomImple
{
// Arrange

var client = ConfigCatClientBuilder.Initialize(APIKEY)
var client = ConfigCatClientBuilder.Initialize(SDKKEY)
.WithLazyLoad()
.WithHttpClientHandler(httpClientHandler)
.Create();
Expand Down
Loading

0 comments on commit 60e0cac

Please sign in to comment.