예제 #1
0
        public void Live_Create_Dataset()
        {
            // Arrange
            var client = new GeckoConnect();
            var obj    = new GeckoDataset()
            {
                Fields = new Dictionary <string, IDatasetField>()
                {
                    { "amount", new DatasetField(DatasetFieldType.number, "Amount") },
                    { "timestamp", new DatasetField(DatasetFieldType.datetime, "Date") }
                },
                UniqueBy = new List <string>()
                {
                    "timestamp"
                }
            };
            var datasetName = $"test_{Guid.NewGuid().ToString()}";

            // Act
            Assert.AreNotEqual("<api key here>", this.apiKey);
            var result = client.CreateDataset(obj, datasetName, this.apiKey);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(datasetName, result.Id);
            Assert.IsTrue(DateTime.Now > result.CreatedAt);
            Assert.IsTrue(DateTime.Now > result.UpdatedAt);

            client.DeleteDataset(datasetName, this.apiKey);
        }
예제 #2
0
        public void Can_See_Error_Messages()
        {
            // Arrange
            try
            {
                var client = new GeckoConnect();
                var obj = new NumberAndSecondaryStat()
                {
                    DataItems = new DataItem[] {
                    new DataItem() { Text = "Visitors", Value = 4223 } ,
                    new DataItem() { Text = string.Empty, Value = 238 }
                }
                };

                var push = new PushPayload<NumberAndSecondaryStat>()
                {
                    ApiKey = Guid.NewGuid().ToString(),
                    Data = obj
                };

                // Act
                var result = client.Push<NumberAndSecondaryStat>(push, Guid.NewGuid().ToString());
            }
            catch (GeckoException gEx)
            {
                // Assert
                Assert.IsNotNull(gEx);
                Assert.IsNotNull(gEx.PushErrorContent);
                Assert.IsTrue(!string.IsNullOrEmpty(gEx.PushErrorContent.Error) || !string.IsNullOrEmpty(gEx.PushErrorContent.Message));
            }
        }
예제 #3
0
        public void Live_Create_Dataset()
        {
            // Arrange
            var client = new GeckoConnect();
            var obj = new GeckoDataset()
            {
                Fields = new Dictionary<string, IDatasetField>()
                {
                    {"amount", new DatasetField(DatasetFieldType.number, "Amount")},
                    {"timestamp", new DatasetField(DatasetFieldType.datetime, "Date")}
                },
                UniqueBy = new List<string>() { "timestamp" }
            };
            var datasetName = $"test_{Guid.NewGuid().ToString()}";

            // Act
            Assert.AreNotEqual("<api key here>", this.apiKey);
            var result = client.CreateDataset(obj, datasetName, this.apiKey);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(datasetName, result.Id);
            Assert.IsTrue(DateTime.Now > result.CreatedAt);
            Assert.IsTrue(DateTime.Now > result.UpdatedAt);

            client.DeleteDataset(datasetName, this.apiKey);
        }
예제 #4
0
        public void Live_Push_Monitoring()
        {
            // Arrange
            Random.Org.Random rand = new Random.Org.Random();
            var widgetKey          = MONITORING_WIDGETKEY; // replace this value with your own
            var obj = new GeckoMonitoring()
            {
                Status       = rand.Next(1, 2) % 2 == 1 ? MonitoringStatus.Up : MonitoringStatus.Down,
                Downtime     = DateTime.Now.AddDays(rand.Next(1, 60)).Humanize(),
                ResponseTime = string.Format("{0} ms", rand.Next(1, 1000))
            };

            var push = new PushPayload <GeckoMonitoring>()
            {
                ApiKey = _apiKey,
                Data   = obj
            };
            var client = new GeckoConnect();

            // Act
            Assert.AreNotEqual("<api key here>", _apiKey);
            Assert.AreNotEqual("<widget key here>", widgetKey);
            var result = client.Push <GeckoMonitoring>(push, widgetKey);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Success);
            Assert.IsTrue(string.IsNullOrWhiteSpace(result.Message));
        }
예제 #5
0
        public void Live_Replace_Data_In_Dataset()
        {
            // Arrange
            var client = new GeckoConnect();
            var obj    = new GeckoDataset()
            {
                Data = new List <Dictionary <string, object> >()
                {
                    new Dictionary <string, object>()
                    {
                        { "timestamp", "2016-01-01T12:00:00Z" },
                        { "amount", 819 }
                    },
                    new Dictionary <string, object>()
                    {
                        { "timestamp", "2016-01-02T12:00:00Z" },
                        { "amount", 409 }
                    },
                    new Dictionary <string, object>()
                    {
                        { "timestamp", "2016-01-03T12:00:00Z" },
                        { "amount", 164 }
                    }
                }
            };
            var datasetName = "test";

            // Act
            Assert.AreNotEqual("<api key here>", this.apiKey);
            var result = client.UpdateDataset(obj, datasetName, this.apiKey);

            // Assert
            Assert.IsNotNull(result);
        }
예제 #6
0
        public void Live_Push_Geckometer()
        {
            // Arrange
            var widgetKey = GECKOMETER_WIDGETKEY;        // replace this value with your own
            var obj       = new GeckoMeterChart()
            {
                Item   = 0.9m,
                Format = "percent",
                Min    = new DataItem()
                {
                    Text = "Min", Value = 0.0m
                },
                Max = new DataItem()
                {
                    Text = "Max", Value = 1.0m
                }
            };

            var push = new PushPayload <GeckoMeterChart>()
            {
                ApiKey = _apiKey,
                Data   = obj
            };
            var client = new GeckoConnect();

            // Act
            Assert.AreNotEqual("<api key here>", _apiKey);
            Assert.AreNotEqual("<widget key here>", widgetKey);
            var result = client.Push <GeckoMeterChart>(push, widgetKey);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Success);
            Assert.IsTrue(string.IsNullOrWhiteSpace(result.Message));
        }
예제 #7
0
        public void Live_Push_NumberAndSecondaryStat()
        {
            // Arrange
            var widgetKey = NUMBERANDSTAT_WIDGETKEY;        // replace this value with your own
            var obj       = new NumberAndSecondaryStat()
            {
                DataItems = new DataItem[] {
                    new DataItem()
                    {
                        Text = "Visitors", Value = 4223
                    },
                    new DataItem()
                    {
                        Text = string.Empty, Value = 238
                    }
                }
            };

            var push = new PushPayload <NumberAndSecondaryStat>()
            {
                ApiKey = _apiKey,
                Data   = obj
            };
            var client = new GeckoConnect();

            // Act
            Assert.AreNotEqual("<api key here>", _apiKey);
            Assert.AreNotEqual("<widget key here>", widgetKey);
            var result = client.Push <NumberAndSecondaryStat>(push, widgetKey);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Success);
            Assert.IsTrue(string.IsNullOrWhiteSpace(result.Message));
        }
예제 #8
0
        public void Live_Replace_Data_In_Dataset()
        {
            // Arrange
            var client = new GeckoConnect();
            var obj = new GeckoDataset()
            {
                Data = new List<Dictionary<string, object>>()
                {
                    new Dictionary<string, object>()
                    {
                        { "timestamp", "2016-01-01T12:00:00Z" },
                        { "amount", 819 }
                    },
                    new Dictionary<string, object>()
                    {
                        { "timestamp", "2016-01-02T12:00:00Z" },
                        { "amount", 409 }
                    },
                    new Dictionary<string, object>()
                    {
                        { "timestamp", "2016-01-03T12:00:00Z" },
                        { "amount", 164 }
                    }
                }
            };
            var datasetName = "test";

            // Act
            Assert.AreNotEqual("<api key here>", this.apiKey);
            var result = client.UpdateDataset(obj, datasetName, this.apiKey);

            // Assert
            Assert.IsNotNull(result);
        }
예제 #9
0
        public void Live_Replace_Data_In_Dataset()
        {
            // Arrange
            var client = new GeckoConnect();

            var obj = new GeckoDataset()
            {
                Fields = new Dictionary <string, IDatasetField>()
                {
                    { "amount", new DatasetField(DatasetFieldType.Number, "Amount") },
                    { "timestamp", new DatasetField(DatasetFieldType.DateTime, "Date") }
                },
                UniqueBy = new List <string>()
                {
                    "timestamp"
                }
            };
            var datasetName = $"test_{Guid.NewGuid().ToString()}";

            // Act
            var result = client.CreateDataset(obj, datasetName, _apiKey);

            var obj2 = new GeckoDataset()
            {
                Data = new List <Dictionary <string, object> >()
                {
                    new Dictionary <string, object>()
                    {
                        { "timestamp", "2016-01-01T12:00:00Z" },
                        { "amount", 819 }
                    },
                    new Dictionary <string, object>()
                    {
                        { "timestamp", "2016-01-02T12:00:00Z" },
                        { "amount", 409 }
                    },
                    new Dictionary <string, object>()
                    {
                        { "timestamp", "2016-01-03T12:00:00Z" },
                        { "amount", 164 }
                    }
                }
            };

            // Act
            Assert.AreNotEqual("<api key here>", _apiKey);
            var result2 = client.UpdateDataset(obj2, datasetName, _apiKey);

            // Assert
            Assert.IsNotNull(result);

            client.DeleteDataset(datasetName, _apiKey);
        }
예제 #10
0
        public void Live_Push_BarChart()
        {
            // Arrange
            var widgetKey = BARCHART_WIDGETKEY;        // replace this value with your own
            var obj       = new GeckoBarChart()
            {
                XAxis = new GeckoBarChartXAxis()
                {
                    Labels = new List <string> {
                        "2000", "2001", "2002", "2003", "2004", "2005"
                    }
                },
                YAxis = new GeckoBarChartYAxis()
                {
                    Format = "currency",
                    Unit   = "USD"
                },
                Series = new List <GeckoBarChartSeries>()
                {
                    new GeckoBarChartSeries()
                    {
                        Data = new List <int> {
                            1000, 1500, 30600, 28800, 22300, 36900
                        }
                    }
                }
            };

            var push = new PushPayload <GeckoBarChart>()
            {
                ApiKey = _apiKey,
                Data   = obj
            };
            var client = new GeckoConnect();
            var json   = JsonConvert.SerializeObject(push, Formatting.Indented); // Just for curiosity sake

            // Act
            Assert.AreNotEqual("<api key here>", _apiKey);
            Assert.AreNotEqual("<widget key here>", widgetKey);
            var result = client.Push <GeckoBarChart>(push, widgetKey);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Success);
            Assert.IsTrue(string.IsNullOrWhiteSpace(result.Message));
        }
예제 #11
0
        public void Live_Can_Delete_Unknown_Dataset()
        {
            // Arrange
            var client      = new GeckoConnect();
            var datasetName = Guid.NewGuid().ToString();

            // Act
            Assert.AreNotEqual("<api key here>", this.apiKey);
            try
            {
                var result = client.DeleteDataset(datasetName, this.apiKey);
                Assert.Fail("Expected an exception");
            }
            catch (GeckoException geckoException)
            {
                Assert.AreEqual("Dataset not found", geckoException.DatasetErrorContent.Error.Message);
            }
        }
예제 #12
0
        public void Live_Can_Delete_Unknown_Dataset()
        {
            // Arrange
            var client = new GeckoConnect();
            var datasetName = Guid.NewGuid().ToString();

            // Act
            Assert.AreNotEqual("<api key here>", this.apiKey);
            try
            {
                var result = client.DeleteDataset(datasetName, this.apiKey);
                Assert.Fail("Expected an exception");
            }
            catch (GeckoException geckoException)
            {
                Assert.AreEqual("Dataset not found", geckoException.DatasetErrorContent.Error.Message);
            }
        }
예제 #13
0
        public void Live_Push_RagNumbers()
        {
            // Arrange
            var widgetKey = RAGNUMBERS_WIDGETKEY;        // replace this value with your own
            var obj       = new GeckoItems()
            {
                DataItems = new DataItem[3] {
                    new DataItem()
                    {
                        Value = 16, Text = "Long past due"
                    },
                    new DataItem()
                    {
                        Value = 64, Text = "Overdue"
                    },
                    new DataItem()
                    {
                        Value = 32, Text = "Due"
                    }
                }
            };

            var push = new PushPayload <GeckoItems>()
            {
                ApiKey = _apiKey,
                Data   = obj
            };
            var client = new GeckoConnect();
            var json   = JsonConvert.SerializeObject(push, Formatting.Indented); // Just for curiosity sake

            // Act
            Assert.AreNotEqual("<api key here>", _apiKey);
            Assert.AreNotEqual("<widget key here>", widgetKey);
            var result = client.Push <GeckoItems>(push, widgetKey);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Success);
            Assert.IsTrue(string.IsNullOrWhiteSpace(result.Message));
        }
예제 #14
0
        public void Can_See_Error_Messages()
        {
            // Arrange
            try
            {
                var client = new GeckoConnect();
                var obj    = new NumberAndSecondaryStat()
                {
                    DataItems = new DataItem[] {
                        new DataItem()
                        {
                            Text = "Visitors", Value = 4223
                        },
                        new DataItem()
                        {
                            Text = string.Empty, Value = 238
                        }
                    }
                };

                var push = new PushPayload <NumberAndSecondaryStat>()
                {
                    ApiKey = Guid.NewGuid().ToString(),
                    Data   = obj
                };

                // Act
                var result = client.Push <NumberAndSecondaryStat>(push, Guid.NewGuid().ToString());
            }
            catch (GeckoException gEx)
            {
                // Assert
                Assert.IsNotNull(gEx);
                Assert.IsNotNull(gEx.PushErrorContent);
                Assert.IsTrue(!string.IsNullOrEmpty(gEx.PushErrorContent.Error) || !string.IsNullOrEmpty(gEx.PushErrorContent.Message));
            }
        }
예제 #15
0
        public void Live_Push_BarChart()
        {
            // Arrange
            var widgetKey = "<widget key here>";        // replace this value with your own
            var obj = new GeckoBarChart()
            {
                XAxis = new GeckoBarChartXAxis()
                {
                    Labels = new List<string> { "2000", "2001", "2002", "2003", "2004", "2005" }
                },
                YAxis = new GeckoBarChartYAxis()
                {
                    Format = "currency",
                    Unit = "USD"
                },
                Series = new List<GeckoBarChartSeries>()
                {
                    new GeckoBarChartSeries(){
                        Data = new List<int>{ 1000, 1500, 30600, 28800, 22300, 36900 }
                    }
                }
            };

            var push = new PushPayload<GeckoBarChart>()
            {
                ApiKey = this.apiKey,
                Data = obj
            };
            var client = new GeckoConnect();
            var json = JsonConvert.SerializeObject(push, Formatting.Indented);  // Just for curiosity sake

            // Act
            Assert.AreNotEqual("<api key here>", this.apiKey);
            Assert.AreNotEqual("<widget key here>", widgetKey);
            var result = client.Push<GeckoBarChart>(push, widgetKey);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Success);
            Assert.IsTrue(string.IsNullOrWhiteSpace(result.Message));
        }
예제 #16
0
        public void Live_Push_Bullet()
        {
            // Arrange
            var widgetKey = "<api widget here>";        // replace this value with your own
            var obj = new GeckoBulletChart()
            {
                Orientation = "horizontal",
                Item = new GeckoBulletItem()
                {
                    Axis = new GeckoBulletAxis() { Points = new System.Collections.Generic.List<string> { "0", "50", "100", "150", "200", "250" } },
                    Comparative = new GeckoBulletPointString() { Point = "220" },
                    Label = "Revenue",
                    Measure = new GeckoBulletMeasure()
                    {
                        Current = new GeckoBulletRangeItemString()
                        {
                            End = "235",
                            Start = "0"
                        }
                    },
                    Range = new System.Collections.Generic.List<GeckoBulletRangeItem>() {
                        new GeckoBulletRangeItem(){ Color = "red", End = 125, Start = 0},
                        new GeckoBulletRangeItem(){ Color = "amber", End = 200, Start = 126},
                        new GeckoBulletRangeItem(){ Color = "green", End = 250, Start = 201}
                    },
                    SubLabel = "U.S. $ (1,000s)"
                }
            };

            var push = new PushPayload<GeckoBulletChart>()
            {
                ApiKey = this.apiKey,
                Data = obj
            };
            var client = new GeckoConnect();
            var json = JsonConvert.SerializeObject(push, Formatting.Indented);  // Just for curiosity sake

            // Act
            Assert.AreNotEqual("<api key here>", this.apiKey);
            Assert.AreNotEqual("<widget key here>", widgetKey);
            var result = client.Push<GeckoBulletChart>(push, widgetKey);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Success);
            Assert.IsTrue(string.IsNullOrWhiteSpace(result.Message));
        }
예제 #17
0
        public void Live_Push_Geckometer()
        {
            // Arrange
            var widgetKey = "<widget key here>";        // replace this value with your own
            var obj = new GeckoMeterChart()
            {
                Item = 0.9m,
                Format = "percent",
                Min = new DataItem() { Text = "Min", Value = 0.0m },
                Max = new DataItem() { Text = "Max", Value = 1.0m }
            };

            var push = new PushPayload<GeckoMeterChart>()
            {
                ApiKey = this.apiKey,
                Data = obj
            };
            var client = new GeckoConnect();

            // Act
            Assert.AreNotEqual("<api key here>", this.apiKey);
            Assert.AreNotEqual("<widget key here>", widgetKey);
            var result = client.Push<GeckoMeterChart>(push, widgetKey);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Success);
            Assert.IsTrue(string.IsNullOrWhiteSpace(result.Message));
        }
예제 #18
0
        public void Live_Push_Monitoring()
        {
            // Arrange
            Random.Org.Random rand = new Random.Org.Random();
            var widgetKey = "<widget key here>";        // replace this value with your own
            var obj = new GeckoMonitoring()
            {
                Status = rand.Next(1, 2) % 2 == 1 ? MonitoringStatus.Up : MonitoringStatus.Down,
                Downtime = DateTime.Now.AddDays(rand.Next(1, 60)).Humanize(),
                ResponseTime = string.Format("{0} ms", rand.Next(1, 1000))
            };

            var push = new PushPayload<GeckoMonitoring>()
            {
                ApiKey = this.apiKey,
                Data = obj
            };
            var client = new GeckoConnect();

            // Act
            Assert.AreNotEqual("<api key here>", this.apiKey);
            Assert.AreNotEqual("<widget key here>", widgetKey);
            var result = client.Push<GeckoMonitoring>(push, widgetKey);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Success);
            Assert.IsTrue(string.IsNullOrWhiteSpace(result.Message));
        }
예제 #19
0
        public void Live_Push_NumberAndSecondaryStat()
        {
            // Arrange
            var widgetKey = "<widget key here>";        // replace this value with your own
            var obj = new NumberAndSecondaryStat()
            {
                DataItems = new DataItem[] {
                    new DataItem() { Text = "Visitors", Value = 4223 } ,
                    new DataItem() { Text = string.Empty, Value = 238 }
                }
            };

            var push = new PushPayload<NumberAndSecondaryStat>()
            {
                ApiKey = this.apiKey,
                Data = obj
            };
            var client = new GeckoConnect();

            // Act
            Assert.AreNotEqual("<api key here>", this.apiKey);
            Assert.AreNotEqual("<widget key here>", widgetKey);
            var result = client.Push<NumberAndSecondaryStat>(push, widgetKey);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Success);
            Assert.IsTrue(string.IsNullOrWhiteSpace(result.Message));
        }
예제 #20
0
        public void Live_Push_Bullet()
        {
            // Arrange
            var widgetKey = BULLET_WIDGETKEY;        // replace this value with your own
            var obj       = new GeckoBulletChart()
            {
                Orientation = "horizontal",
                Item        = new GeckoBulletItem()
                {
                    Axis = new GeckoBulletAxis()
                    {
                        Points = new System.Collections.Generic.List <string> {
                            "0", "50", "100", "150", "200", "250"
                        }
                    },
                    Comparative = new GeckoBulletPointString()
                    {
                        Point = "220"
                    },
                    Label   = "Revenue",
                    Measure = new GeckoBulletMeasure()
                    {
                        Current = new GeckoBulletRangeItemString()
                        {
                            End   = "235",
                            Start = "0"
                        }
                    },
                    Range = new System.Collections.Generic.List <GeckoBulletRangeItem>()
                    {
                        new GeckoBulletRangeItem()
                        {
                            Color = "red", End = 125, Start = 0
                        },
                        new GeckoBulletRangeItem()
                        {
                            Color = "amber", End = 200, Start = 126
                        },
                        new GeckoBulletRangeItem()
                        {
                            Color = "green", End = 250, Start = 201
                        }
                    },
                    SubLabel = "U.S. $ (1,000s)"
                }
            };

            var push = new PushPayload <GeckoBulletChart>()
            {
                ApiKey = _apiKey,
                Data   = obj
            };
            var client = new GeckoConnect();
            var json   = JsonConvert.SerializeObject(push, Formatting.Indented); // Just for curiosity sake

            // Act
            Assert.AreNotEqual("<api key here>", _apiKey);
            Assert.AreNotEqual("<widget key here>", widgetKey);
            var result = client.Push <GeckoBulletChart>(push, widgetKey);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Success);
            Assert.IsTrue(string.IsNullOrWhiteSpace(result.Message));
        }
예제 #21
0
        public void Live_Push_RagNumbers()
        {
            // Arrange
            var widgetKey = "<widget key here>";        // replace this value with your own
            var obj = new GeckoItems()
            {
                DataItems = new DataItem[3] {
                    new DataItem() { Value = 16, Text = "Long past due" },
                    new DataItem() { Value = 64, Text = "Overdue" },
                    new DataItem() { Value = 32, Text = "Due" }
                }
            };

            var push = new PushPayload<GeckoItems>()
            {
                ApiKey = this.apiKey,
                Data = obj
            };
            var client = new GeckoConnect();
            var json = JsonConvert.SerializeObject(push, Formatting.Indented);  // Just for curiosity sake

            // Act
            Assert.AreNotEqual("<api key here>", this.apiKey);
            Assert.AreNotEqual("<widget key here>", widgetKey);
            var result = client.Push<GeckoItems>(push, widgetKey);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Success);
            Assert.IsTrue(string.IsNullOrWhiteSpace(result.Message));
        }