public void ValidSingleBackupItem()
        {
            BackupItem[] items = new BackupItem[1];
            items[0] = getBackupItem(1);

            //BackupJSon
            DeviceBackupJSON json = new DeviceBackupJSON();
            json.i = TestGlobals.validSerial;
            json.s = 4;
            json.b = items;

            Uri uri = new Uri(TestGlobals.testServer, "/api/DeviceBackup/");

            results.WriteLine(DateTime.Now);

            AsyncContext.Run(async () => await new HTTPSCalls().RunPostAsync(uri, json));
            string statusCode = HTTPSCalls.result.Key.Property("StatusCode").Value.ToString();

            results.WriteLine("Json posted:");
            results.WriteLine(json.ToString());
            results.WriteLine("Server: " + TestGlobals.testServer);
            results.WriteLine("Expected result: 201");
            results.WriteLine("Actual result: " + statusCode);
            results.WriteLine("Test result: " + HTTPSCalls.result.Key.ToString());
            results.WriteLine();

            Assert.AreEqual("201", statusCode);
        }
        public void NullSerial()
        {
            BackupItem[] items = new BackupItem[3];
            items[0] = getBackupItem(1);
            items[1] = getBackupItem(2);
            items[2] = getBackupItem(3);

            DeviceBackupJSON serialJson = new DeviceBackupJSON();
            serialJson.s = 6;
            serialJson.b = items;
            serialJson.i = null;

            Uri uri = new Uri(TestGlobals.testServer, "/api/DeviceBackup/");

            results.WriteLine(DateTime.Now);

            AsyncContext.Run(async () => await new HTTPSCalls().RunPostAsync(uri, serialJson));
            string statusCode = HTTPSCalls.result.Key.Property("StatusCode").Value.ToString();

            results.WriteLine("Json posted:");
            results.WriteLine(serialJson.ToString());
            results.WriteLine("Server: " + TestGlobals.testServer);
            results.WriteLine("Expected result: 400");
            results.WriteLine("Actual result: " + statusCode);
            results.WriteLine("Test result: " + HTTPSCalls.result.Key.ToString());
            results.WriteLine();

            Assert.AreEqual("400", statusCode);
        }
        public void ValidBackupItemsSimDyn()
        {
            BackupItem[] items = new BackupItem[2];
            items[0] = new BackupItem();
            items[0].d = "~20/12345|";
            items[0].s = 442;
            items[0].t = new DateTime(2015, 5, 11, 2, 4, 22, 295);
            items[0].c = false;

            items[1] = getBackupItem(1);

            DeviceBackupJSON serialJson = new DeviceBackupJSON();
            serialJson.s = 6;
            serialJson.b = items;
            serialJson.i = TestGlobals.validSerial;

            Uri uri = new Uri(TestGlobals.testServer, "/api/DeviceBackup/");

            results.WriteLine(DateTime.Now);

            AsyncContext.Run(async () => await new HTTPSCalls().RunPostAsync(uri, serialJson));
            string statusCode = HTTPSCalls.result.Key.Property("StatusCode").Value.ToString();

            results.WriteLine("Json posted:");
            results.WriteLine(serialJson.ToString());
            results.WriteLine("Server: " + TestGlobals.testServer);
            results.WriteLine("Expected result: " + "201");
            results.WriteLine("Actual result: " + statusCode);
            results.WriteLine("Test result: " + HTTPSCalls.result.Key.ToString());
            results.WriteLine();

            Assert.AreEqual("201", statusCode);
        }
        public void MalformedBackupItems()
        {
            string[] items = new string[2];
            items[0] = "code11";
            items[1] = "code56";
            DeviceBackupJSON json = new DeviceBackupJSON();
            json.s = 652;
            json.b = items;
            //json.i = TestGlobals.validSerial;

            Uri uri = new Uri(TestGlobals.testServer, "/api/DeviceBackup/");

            results.WriteLine(DateTime.Now);

            AsyncContext.Run(async () => await new HTTPSCalls().RunPostAsync(uri, json));
            string statusCode = HTTPSCalls.result.Key.Property("StatusCode").Value.ToString();

            Console.WriteLine(HTTPSCalls.result.ToString());

            results.WriteLine("Json posted:");
            results.WriteLine(json.ToString());
            results.WriteLine("Server: " + TestGlobals.testServer);
            results.WriteLine("Expected result: 400");
            results.WriteLine("Actual result: " + statusCode);
            results.WriteLine("Test result: " + HTTPSCalls.result.Key.ToString());
            results.WriteLine();

            Assert.AreEqual("400", statusCode);
        }