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;

            DeviceBackup operation = new DeviceBackup(TestGlobals.testServer, serialJson);

            Test backupTest = new Test(operation);
            backupTest.setTestName("ValidBackupItemSimDyn");
            backupTest.setExpectedResult ("201");

            results.WriteLine (DateTime.Now);
            results.WriteLine ("current test: " + backupTest.ToString () + " " + backupTest.getTestName ());

            AsyncContext.Run(async () => await new HTTPSCalls().runTest(backupTest, HTTPOperation.POST));
            string statusCode = HTTPSCalls.result.Key.Property("StatusCode").Value.ToString();

            results.WriteLine("Json posted:");
            results.WriteLine (operation.getJson().ToString());
            results.WriteLine ("Server: " + TestGlobals.testServer);
            results.WriteLine ("Expected result: " + backupTest.getActualResult());
            results.WriteLine ("Actual result: " + statusCode);
            results.WriteLine ("Test result: " + backupTest.result ());
            results.WriteLine ();

            Assert.AreEqual("201", statusCode);
        }
        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;

            //BackupOperation
            DeviceBackup operation = new DeviceBackup(TestGlobals.testServer, json);

            //Test
            Test backupTest = new Test(operation);
            backupTest.setTestName("ValidSingleBackupItem");
            backupTest.setExpectedResult ("201");

            results.WriteLine (DateTime.Now);
            results.WriteLine ("current test: " + backupTest.ToString () + " " + backupTest.getTestName ());

            AsyncContext.Run(async () => await new HTTPSCalls().runTest(backupTest, HTTPOperation.POST));
            string statusCode = HTTPSCalls.result.Key.Property("StatusCode").Value.ToString();

            results.WriteLine("Json posted:");
            results.WriteLine (operation.getJson().ToString());
            results.WriteLine ("Server: " + TestGlobals.testServer);
            results.WriteLine ("Expected result: " + backupTest.getActualResult());
            results.WriteLine ("Actual result: " + statusCode);
            results.WriteLine ("Test result: " + backupTest.result ());
            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;

            DeviceBackup operation = new DeviceBackup(TestGlobals.testServer, serialJson);

            Test backupTest = new Test(operation);
            backupTest.setTestName("NullSerial");
            backupTest.setExpectedResult ("400");

            results.WriteLine (DateTime.Now);
            results.WriteLine ("current test: " + backupTest.ToString () + " " + backupTest.getTestName ());

            AsyncContext.Run(async () => await new HTTPSCalls().runTest(backupTest, HTTPOperation.POST));
            string statusCode = HTTPSCalls.result.Key.Property("StatusCode").Value.ToString();

            results.WriteLine("Json posted:");
            results.WriteLine (operation.getJson().ToString());
            results.WriteLine ("Server: " + TestGlobals.testServer);
            results.WriteLine ("Expected result: " + backupTest.getActualResult());
            results.WriteLine ("Actual result: " + statusCode);
            results.WriteLine ("Test result: " + backupTest.result ());
            results.WriteLine ();

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