//[Test()]
        public void ASCIIScanCode()
        {
            DeviceScanJSON testJson = new DeviceScanJSON ();
            testJson.i = TestGlobals.validSerial;
            testJson.d = "!\"#&)(";
            testJson.b = null;
            testJson.s = 4;
            DeviceScan testDScan = new DeviceScan(TestGlobals.testServer, testJson);

            Test scanTest = new Test(testDScan);
            scanTest.setTestName("ASCIIScanCode");
            scanTest.setExpectedResult ("201");

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

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

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

            Assert.AreEqual("201", statusCode);
        }
示例#2
0
        //Do test, output results to file.
        public static async Task runTest(Test currentTest)
        {
            //Get start time
            int startTime = seconds;

            Console.WriteLine("Test starting");
            //Do tests
            await testType(currentTest);

            Console.WriteLine("Test ending");
            //Get end time
            int endTime   = seconds;
            int timeDelta = endTime - startTime;

            if (results != null)
            {
                //Output results
                //Test
                results.WriteLine("Summary:");
                results.WriteLine("Current test: " + currentTest.ToString() + " " + currentTest.getTestName());
                //clm();

                try
                {
                    results.WriteLine("Input JSON:");
                    results.WriteLine(currentTest.getOperation().getJson().ToString());
                }
                catch (Exception)
                {
                    results.WriteLine("No JSON attached to this operation");
                }

                results.WriteLine("Input URI: " + currentTest.getOperation().getUri());

                //Expected value
                results.WriteLine("Expected result: " + currentTest.getExpectedResult());
                //clm();
                //Actual value
                results.WriteLine("Actual result: " + currentTest.getActualResult());
                //clm();
                //Time elapsed (in seconds)
                results.WriteLine("Time elapsed: " + timeDelta + "s");
                //clm();
                //Pass/Fail
                results.WriteLine("Test result: " + currentTest.result());
                results.WriteLine();
            }
        }
示例#3
0
        public void MissingSerial()
        {
            ICmd missingICmd = new ICmd(TestGlobals.testServer, null);
            Test icmdTest = new Test(missingICmd);
            icmdTest.setTestName("EmptySerial");
            icmdTest.setExpectedResult ("400");

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

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

            results.WriteLine ("Server: " + TestGlobals.testServer);
            results.WriteLine ("Expected result: " + icmdTest.getActualResult());
            results.WriteLine ("Actual result: " + statusCode);
            results.WriteLine ("Test result: " + icmdTest.result ());
            results.WriteLine ();

            Assert.AreEqual("400", statusCode);
        }
示例#4
0
        //Do test, output results to file.
        public static async Task runTest(Test currentTest)
        {
            //Get start time
            int startTime = seconds;

            Console.WriteLine("Test starting");
            //Do tests
            await testType(currentTest);

            Console.WriteLine("Test ending");
            //Get end time
            int endTime   = seconds;
            int timeDelta = endTime - startTime;

            if (results != null)
            {
                //Output results
                //Test
                results.Write(currentTest.ToString());
                clm();
                //Expected value
                results.Write(currentTest.getExpectedResult());
                clm();
                //Actual value
                results.Write(currentTest.getActualResult());
                clm();
                //Time elapsed (in seconds)
                results.Write(timeDelta);
                clm();
                //Pass/Fail
                results.Write(currentTest.result());
                //Carriage return (set up next line)
                results.WriteLine();
            }
            else
            {
                //TODOIF: Set this to something that doesn't print out all the goddamn time
                Console.WriteLine("Results file writer not initialized, cancelling output logging...");
            }
        }
        public void NoSerial()
        {
            DeviceSetting dSetting3 = new DeviceSetting(TestGlobals.testServer, null);

            Test deviceSetting = new Test(dSetting3);
            deviceSetting.setTestName("NoSerial");
            deviceSetting.setExpectedResult ("400");

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

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

            results.WriteLine ("Server: " + TestGlobals.testServer);
            results.WriteLine ("Expected result: " + deviceSetting.getActualResult());
            results.WriteLine ("Actual result: " + statusCode);
            results.WriteLine ("Test result: " + deviceSetting.result ());
            results.WriteLine ();

            Assert.AreEqual("400", statusCode);
        }
        //[Test()]
        public void AlertDataStore()
        {
            DeviceStatusJSON status = new DeviceStatusJSON();
            status.bkupURL = "http://cozumotesttls.cloudapp.net:80/api/DeviceBackup";
            status.callHomeTimeoutData = null;
            status.callHomeTimeoutMode = "0";
            status.capture = "1";
            status.captureMode = "1";
            status.cmdChkInt = "1";
            status.cmdURL = "http://cozumotesttls.cloudapp.net:80/api/iCmd";
            string[] err = new string[1];
            err[0] = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ")+ "///900///bypassmode";
            status.Ssid = "43B81B4F768D0549AB4F178022DEB384";
            status.wpaPSK = "wifipassword";
            status.errorLog = err;
            status.dynCodeFormat = err;
            status.intSerial = TestGlobals.validSerial;
            status.reportURL = "http://cozumotesttls.cloudapp.net:80/api/DeviceStatus";
            status.requestTimeoutValue = "8000";
            status.revId = "52987";
            status.scanURL = "http://cozumotesttls.cloudapp.net:80/api/DeviceScan";
            status.seqNum = "87";
            status.startURL = "http://cozumotesttls.cloudapp.net:80/api/DeviceSetting";

            DeviceStatus operation = new DeviceStatus(TestGlobals.testServer, status);
            Test statusTest = new Test(operation);
            statusTest.setTestName("AlertDataStore");
            statusTest.setExpectedResult ("201");

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

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

            results.WriteLine("Json posted:");
            results.WriteLine(statusTest.getOperation().getJson().ToString());
            results.WriteLine("Server returned:");
            results.WriteLine(HTTPSCalls.result.Key.ToString());
            results.WriteLine(HTTPSCalls.result.Value.ToString());
            results.WriteLine ("Server: " + TestGlobals.testServer);
            results.WriteLine ("Expected result: " + statusTest.getActualResult());
            results.WriteLine ("Actual result: " + statusCode);
            results.WriteLine ("Test result: " + statusTest.result ());
            results.WriteLine ();

            Assert.AreEqual("201", statusCode);
        }
        //[Test()]
        public void NullSerial()
        {
            DeviceStatusJSON status = new DeviceStatusJSON();
            status.bkupURL = "http://cozumotesttls.cloudapp.net:80/api/DeviceBackup";
            status.callHomeTimeoutData = null;
            status.callHomeTimeoutMode = "0";
            status.capture = "1";
            status.captureMode = "1";
            status.cmdChkInt = "1";
            status.cmdURL = "http://cozumotesttls.cloudapp.net:80/api/iCmd";
            string[] err = new string[3];
            err[0] = "asdf";
            err[1] = "wasd";
            err[2] = "qwerty";
            status.errorLog = err;
            status.reportURL = "http://cozumotesttls.cloudapp.net:80/api/DeviceStatus";
            status.requestTimeoutValue = "8000";
            status.revId = "52987";
            status.scanURL = "http://cozumotesttls.cloudapp.net:80/api/DeviceScan";
            status.seqNum = "87";
            status.startURL = "http://cozumotesttls.cloudapp.net:80/api/DeviceSetting";

            DeviceStatus operation = new DeviceStatus(TestGlobals.testServer, status);
            Test statusTest = new Test(operation);
            statusTest.setTestName("NullSerial");
            statusTest.setExpectedResult ("400");

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

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

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

            Assert.AreEqual("400", statusCode);
        }
        //TODO: Identify invalid scan
        /*
        [Test()]
        // Mixed of Valid/Invalid Scans
        public void ValInvalScansDyn()
        {
            DeviceScanJSON testJson = new DeviceScanJSON ();
            testJson.i = validSerial;
            testJson.d = null;
            string[] scanData = new string[4];
            scanData [0] = "~20/0|";
            scanData [1] = "~20/noendingbar";
            scanData [2] = "~20/2|";
            scanData [3] = "~20/3|";
            testJson.b = scanData;
            testJson.s = 4;
            DeviceScan testDScan = new DeviceScan (testServer, testJson);

            Test scanTest = new Test (testDScan);
            scanTest.setTestName("ValInvalScansDyn");

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

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

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

            Assert.AreEqual("201", statusCode);

        }

        */
        // Combined
        //[Test()]
        // List of Valid Simple and Dynamic Code Scans
        public void ValidScansSimDyn()
        {
            DeviceScanJSON testJson = new DeviceScanJSON ();
            testJson.i = TestGlobals.validSerial;
            testJson.d = null;
            string[] scanData = new string[4];
            scanData [0] = "~20/0|";
            scanData [1] = "123456789";
            scanData [2] = "~20/2|";
            scanData [3] = "987654321";
            testJson.b = scanData;
            testJson.s = 4;
            DeviceScan testDScan = new DeviceScan (TestGlobals.testServer, testJson);

            Test scanTest = new Test (testDScan);
            scanTest.setTestName("ValidScansSimDyn");
            scanTest.setExpectedResult ("201");

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

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

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