public void CreateDataset_Throws_ServerError() { IKeenHttpClientProvider httpClientProvider = null; if (UseMocks) { httpClientProvider = GetMockHttpClientProviderForDeleteAsync("{}", HttpStatusCode.InternalServerError); } var client = new KeenClient(SettingsEnv, httpClientProvider); Assert.Throws <KeenException>(() => client.CreateDataset(null)); }
public void CreateDataset_Success() { var apiResponse = File.ReadAllText($"{GetApiResponsesPath()}/GetDatasetDefinition.json"); IKeenHttpClientProvider httpClientProvider = null; if (UseMocks) { httpClientProvider = GetMockHttpClientProviderForPutAsync(apiResponse); } var client = new KeenClient(SettingsEnv, httpClientProvider); var newDataSet = CreateDatasetDefinition(); var dataset = client.CreateDataset(newDataSet); AssertDatasetIsPopulated(dataset); }
public void CreateDataset_Throws_WrongKey() { var apiResponse = File.ReadAllText($"{GetApiResponsesPath()}/GetDatasetDefinition.json"); IKeenHttpClientProvider httpClientProvider = null; if (UseMocks) { httpClientProvider = GetMockHttpClientProviderForPutAsync(apiResponse); } var brokenClient = new KeenClient(new ProjectSettingsProvider("5011efa95f546f2ce2000000", null, Environment.GetEnvironmentVariable(KeenConstants.KeenWriteKey) ?? "", Environment.GetEnvironmentVariable(KeenConstants.KeenReadKey) ?? "", GetServerUrl()), httpClientProvider); Assert.Throws <KeenException>(() => brokenClient.CreateDataset(CreateDatasetDefinition())); }
public void CreateDataset_Success() { var result = new DatasetDefinition(); var client = new KeenClient(SettingsEnv); Mock <IDataset> datasetMock = null; if (UseMocks) { datasetMock = new Mock <IDataset>(); datasetMock.Setup(m => m.CreateDatasetAsync( It.Is <DatasetDefinition>(n => n != null))) .ReturnsAsync(result); client.Datasets = datasetMock.Object; } var datasetDefinition = client.CreateDataset(new DatasetDefinition()); Assert.IsNotNull(datasetDefinition); datasetMock?.VerifyAll(); }
public void CreateDataset_Throws() { IKeenHttpClientProvider httpClientProvider = null; if (UseMocks) { httpClientProvider = GetMockHttpClientProviderForDeleteAsync("{}", HttpStatusCode.InternalServerError); } var client = new KeenClient(SettingsEnv, httpClientProvider); Assert.Throws <KeenException>(() => client.CreateDataset(null)); var brokenClient = new KeenClient(new ProjectSettingsProvider("5011efa95f546f2ce2000000", null, Environment.GetEnvironmentVariable("KEEN_WRITE_KEY") ?? "", Environment.GetEnvironmentVariable("KEEN_READ_KEY") ?? "", Environment.GetEnvironmentVariable("KEEN_SERVER_URL") ?? KeenConstants.ServerAddress + "/" + KeenConstants.ApiVersion + "/"), httpClientProvider); Assert.Throws <KeenException>(() => brokenClient.CreateDataset(CreateDatasetDefinition())); }