public void DeleteDataset_Throws_ServerError()
        {
            IKeenHttpClientProvider httpClientProvider = null;

            if (UseMocks)
            {
                httpClientProvider = GetMockHttpClientProviderForDeleteAsync("{}", HttpStatusCode.InternalServerError);
            }

            var client = new KeenClient(SettingsEnv, httpClientProvider);

            Assert.Throws <KeenException>(() => client.DeleteDataset(null));
            Assert.Throws <KeenException>(() => client.DeleteDataset(_datasetName));
        }
        public void Delete_Success()
        {
            IKeenHttpClientProvider httpClientProvider = null;

            if (UseMocks)
            {
                httpClientProvider = GetMockHttpClientProviderForDeleteAsync(string.Empty);
            }

            var client = new KeenClient(SettingsEnv, httpClientProvider);

            client.DeleteDataset("datasetName");
        }
示例#3
0
        public void DeleteDataset_Throws()
        {
            IKeenHttpClientProvider httpClientProvider = null;

            if (UseMocks)
            {
                httpClientProvider = GetMockHttpClientProviderForDeleteAsync("{}", HttpStatusCode.InternalServerError);
            }

            var client = new KeenClient(SettingsEnv, httpClientProvider);

            Assert.Throws <KeenException>(() => client.DeleteDataset(null));
            Assert.Throws <KeenException>(() => client.DeleteDataset(_datasetName));

            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.DeleteDataset(_datasetName));
        }
        public void DeleteDataset_Throws_WrongKey()
        {
            IKeenHttpClientProvider httpClientProvider = null;

            if (UseMocks)
            {
                httpClientProvider = GetMockHttpClientProviderForDeleteAsync(string.Empty);
            }

            var brokenClient = new KeenClient(new ProjectSettingsProvider("5011efa95f546f2ce2000000",
                                                                          null,
                                                                          Environment.GetEnvironmentVariable(KeenConstants.KeenWriteKey) ?? "",
                                                                          Environment.GetEnvironmentVariable(KeenConstants.KeenReadKey) ?? "",
                                                                          GetServerUrl()),
                                              httpClientProvider);

            Assert.Throws <KeenException>(() => brokenClient.DeleteDataset(_datasetName));
        }
示例#5
0
        public void DeleteDataset_Success()
        {
            var             client      = new KeenClient(SettingsEnv);
            Mock <IDataset> datasetMock = null;

            if (UseMocks)
            {
                datasetMock = new Mock <IDataset>();
                datasetMock.Setup(m => m.DeleteDatasetAsync(
                                      It.Is <string>(n => n == _datasetName)))
                .Returns(Task.Delay(0));

                client.Datasets = datasetMock.Object;
            }

            client.DeleteDataset(_datasetName);

            datasetMock?.VerifyAll();
        }