Exemplo n.º 1
0
        public void HttpDataAccessTest_Add_AndRemove_Fill_Rectangle()
        {
            string server = testContextInstance.DataRow["Server"].ToString();
            string login = testContextInstance.DataRow["Login"].ToString();
            string password = testContextInstance.DataRow["Password"].ToString();
            int operatorId = int.Parse(testContextInstance.DataRow["OperatorId"].ToString());
            int rectangleId = int.Parse(testContextInstance.DataRow["RectangleId"].ToString());
            bool shouldPass = bool.Parse(testContextInstance.DataRow["ShouldPass"].ToString());
            bool addFillRectanglePassed = false;
            string exception = string.Empty;
            HttpDataClient test = new HttpDataClient();

            bool passed = false;
            try
            {
                test.Login(server, login, password);
                test.AddFillRectangle(new ExelConverter.Core.DataObjects.FillArea() { FKOperatorID = operatorId, Height = 100, ID = rectangleId, Type = "test_type", Width = 100, X1 = 0, X2 = 100, Y1 = 0, Y2 = 100 });

                addFillRectanglePassed = true;

                test.RemoveFillRectangle(rectangleId);
                passed = true;
            }
            catch (Exception ex) { exception = ex.Message; }

            Assert.AreEqual(passed, shouldPass, string.Format("server:{1}{0}login:{2}{0}password:{3}{0}operatorid:{4}{0}rectangleid:{5}{0}shouldpass:{6}{0}passed:{7}{0}addrectanglepassed:{8}{0}exception:{9}", Environment.NewLine, server, login, password, operatorId, rectangleId, shouldPass, passed, addFillRectanglePassed, exception));
        }
Exemplo n.º 2
0
        public void HttpDataAccessTest_Get_Sources_List()
        {
            string server = testContextInstance.DataRow["Server"].ToString();
            string login = testContextInstance.DataRow["Login"].ToString();
            string password = testContextInstance.DataRow["Password"].ToString();
            int operatorId = int.Parse(testContextInstance.DataRow["OperatorId"].ToString());
            bool shouldPass = bool.Parse(testContextInstance.DataRow["ShouldPass"].ToString());
            string code = testContextInstance.DataRow["Code"].ToString();
            string exception = string.Empty;
            HttpDataClient test = new HttpDataClient();

            bool passed = false;
            try
            {
                test.Login(server, login, password);
                string map, pdf;

                test.GetResourcesList(
                    operatorId,
                    new System.Collections.Generic.List<ExelConverter.Core.DataWriter.ReExportData>(
                        new ExelConverter.Core.DataWriter.ReExportData[] { new ExelConverter.Core.DataWriter.ReExportData(code, 1, "test") }
                        )
                    , out map
                    , out pdf);

                Assert.IsNotNull(map, "map should not be empty");
                Assert.IsNotNull(pdf, "pdf should not be empty");

                passed = true;
            }
            catch (Exception ex) { exception = ex.Message; }

            Assert.AreEqual(passed, shouldPass, string.Format("server:{1}{0}login:{2}{0}password:{3}{0}operatorid:{4}{0}code:{5}{0}shouldpass:{6}{0}passed:{7}{0}exception:{8}", Environment.NewLine, server, login, password, operatorId, code, shouldPass, passed, exception));
        }
Exemplo n.º 3
0
        public void DataAccessTest_APP_AddAndRemoveOperatorRules()
        {
            string server = testContextInstance.DataRow["Server"].ToString();
            string login = testContextInstance.DataRow["Login"].ToString();
            string password = testContextInstance.DataRow["Password"].ToString();
            bool shouldPass = bool.Parse(testContextInstance.DataRow["ShouldPass"].ToString());
            string exception = string.Empty;
            string connectionMain = string.Empty;
            string connectionApp = string.Empty;
            HttpDataClient test = new HttpDataClient();

            var result = new ExelConverter.Core.Converter.ExelConvertionRule[] { };

            bool passed = false;
            try
            {
                test.Login(server, login, password);

                connectionMain = test.ConnectionStringMain;
                connectionApp = test.ConnectionStringApp;

                alphaEntities.ProviderConnectionString = connectionMain;
                exelconverterEntities2.ProviderConnectionString = connectionApp;

                DataAccess da = new DataAccess();
                ExelConverter.Core.Settings.SettingsProvider.Initialize(da);

                var ops = da.GetOperators();
                int cnt = ops.Length > 2 ? 2 : ops.Length;

                for (int i = 0; i < ops.Length; i += (int)((float)ops.Length / (float)cnt))
                {
                    ExelConverter.Core.Converter.ExelConvertionRule r =
                        new ExelConverter.Core.Converter.ExelConvertionRule()
                        {
                            Name = "test_rule",
                            FkOperatorId = (int)ops[i].Id
                        };
                    da.AddOperatorRule(r);
                    da.RemoveOperatorRule(r);
                }

                passed = true;
            }
            catch (Exception ex) { exception = ex.GetExceptionText(); }

            string errMsg = string.Format("server:{1}{0}login:{2}{0}password:{3}{0}connectionMain:{4}{0}connectionApp:{5}{0}shouldpass:{6}{0}passed:{7}{0}exception:{8}", Environment.NewLine, server, login, password, connectionMain, connectionApp, shouldPass, passed, exception);

            Assert.AreEqual(passed, shouldPass, errMsg);

            //Assert.IsNotNull(result, errMsg + string.Format("{0}result is NULL", Environment.NewLine));
            //Assert.AreNotEqual(result.Length, 0, errMsg + string.Format("{0}result is EMPTY", Environment.NewLine));
        }
Exemplo n.º 4
0
 public void SetAsDefault()
 {
     _default = this;
 }
Exemplo n.º 5
0
        public void HttpDataAccessTest_WebLogin_And_WebLogout()
        {
            string server = testContextInstance.DataRow["Server"].ToString();
            string login = testContextInstance.DataRow["Login"].ToString();
            string password = testContextInstance.DataRow["Password"].ToString();
            string exception = string.Empty;
            bool shouldPass = bool.Parse(testContextInstance.DataRow["ShouldPass"].ToString());
            HttpDataClient test = new HttpDataClient();

            bool passed = false;
            try
            {
                test.Login(server, login, password);

                test.WebLogin();
                test.WebLogout();

                passed = true;
            }
            catch (Exception ex) { exception = ex.Message; }

            Assert.AreEqual(passed, shouldPass, string.Format("server:{1}{0}login:{2}{0}password:{3}{0}shouldpass:{4}{0}passed:{5}{0}exception:{6}", Environment.NewLine, server, login, password, shouldPass, passed, exception));
        }
Exemplo n.º 6
0
        public void HttpDataAccessTest_Upload_File_To_Queue()
        {
            string server = testContextInstance.DataRow["Server"].ToString();
            string login = testContextInstance.DataRow["Login"].ToString();
            string password = testContextInstance.DataRow["Password"].ToString();
            string filePath = testContextInstance.DataRow["FilePath"].ToString();
            int operatorId = int.Parse(testContextInstance.DataRow["OperatorId"].ToString());
            bool shouldPass = bool.Parse(testContextInstance.DataRow["ShouldPass"].ToString());
            string exception = string.Empty;
            HttpDataClient test = new HttpDataClient();

            bool passed = false;
            try
            {
                test.Login(server, login, password);
                test.WebLogin();
                try
                {
                    test.UploadFileToQueue(new HttpDataAccessQueueParameters()
                    {
                        FilePath = filePath,
                        Activate = false,
                        CoordinatesApproved = false,
                        OperatorID = operatorId,
                        Timeout = 100,
                        UseQueue = true
                    });
                }
                finally
                {
                    test.WebLogout();
                }

                passed = true;
            }
            catch (Exception ex) { exception = ex.Message; }

            Assert.AreEqual(passed, shouldPass, string.Format("server:{1}{0}login:{2}{0}password:{3}{0}operatorid:{4}{0}filepath:{5}{0}shouldpass:{6}{0}passed:{7}{0}exception:{8}", Environment.NewLine, server, login, password, operatorId, filePath, shouldPass, passed, exception));
        }
Exemplo n.º 7
0
        public void HttpDataAccessTest_Login()
        {
            string server = testContextInstance.DataRow["Server"].ToString();
            string login = testContextInstance.DataRow["Login"].ToString();
            string password = testContextInstance.DataRow["Password"].ToString();
            bool shouldPass = bool.Parse(testContextInstance.DataRow["ShouldPass"].ToString());
            HttpDataClient test = new HttpDataClient();

            bool passed = false;
            try
            {
                test.Login(server, login, password);
                passed = true;
            }
            catch { }

            Assert.AreEqual(passed, shouldPass, string.Format("server:{1}{0}login:{2}{0}password:{3}{0}shouldpass:{4}{0}passed:{5}", Environment.NewLine, server, login, password, shouldPass, passed));
        }
Exemplo n.º 8
0
        public void DataAccessTest_Test_Connection_To_DB()
        {
            string server = testContextInstance.DataRow["Server"].ToString();
            string login = testContextInstance.DataRow["Login"].ToString();
            string password = testContextInstance.DataRow["Password"].ToString();
            bool shouldPass = bool.Parse(testContextInstance.DataRow["ShouldPass"].ToString());
            string exception = string.Empty;
            string connectionMain = string.Empty;
            string connectionApp = string.Empty;
            HttpDataClient test = new HttpDataClient();

            bool passed = false;
            try
            {
                test.Login(server, login, password);

                connectionMain = test.ConnectionStringMain;
                connectionApp = test.ConnectionStringApp;

                using (MySqlConnection conMain = new MySqlConnection() { ConnectionString = connectionMain })
                {
                    conMain.Open();
                }

                using (MySqlConnection conApp = new MySqlConnection() { ConnectionString = connectionApp })
                {
                    conApp.Open();
                }

                passed = true;
            }
            catch (Exception ex) { exception = ex.Message; }

            Assert.AreEqual(passed, shouldPass, string.Format("server:{1}{0}login:{2}{0}password:{3}{0}connectionMain:{4}{0}connectionApp:{5}{0}shouldpass:{6}{0}passed:{7}{0}exception:{8}", Environment.NewLine, server, login, password, connectionMain, connectionApp, shouldPass, passed, exception));
        }
Exemplo n.º 9
0
        public void DataAccessTest_Get_FULL_Rules()
        {
            string server = testContextInstance.DataRow["Server"].ToString();
            string login = testContextInstance.DataRow["Login"].ToString();
            string password = testContextInstance.DataRow["Password"].ToString();
            bool shouldPass = bool.Parse(testContextInstance.DataRow["ShouldPass"].ToString());
            string exception = string.Empty;
            string connectionMain = string.Empty;
            string connectionApp = string.Empty;

            //if (!server.Contains("alpha"))
            //    return;

            HttpDataClient test = new HttpDataClient();

            var result = new ExelConverter.Core.Converter.ExelConvertionRule[] { };

            bool passed = false;
            try
            {
                test.Login(server, login, password);

                connectionMain = test.ConnectionStringMain;
                connectionApp = test.ConnectionStringApp;

                alphaEntities.ProviderConnectionString = connectionMain;
                exelconverterEntities2.ProviderConnectionString = connectionApp;

                DataAccess da = new DataAccess();
                ExelConverter.Core.Settings.SettingsProvider.Initialize(da);

                var operators = da.GetOperators();
                for (int i = 0; i < operators.Length; i++)
                {
                    List<ExelConvertionRule> rules = new List<ExelConvertionRule>(da.GetRulesByOperator(new int[] { (int)operators[i].Id }));
                    da.UpdateOperatorRules(rules.ToArray());

                    //string text = rules.SerializeToXML(false);

                    //Uri uri = new Uri(server);

                    //string fileName = string.Format("{0}.{1}.{2}.xml", uri.Host, operators[i].Id, operators[i].Name);

                    //foreach (var c in System.IO.Path.GetInvalidFileNameChars())
                    //    fileName = fileName.Replace(c.ToString(), "");

                    //fileName = System.IO.Path.Combine(Helpers.Log.CurrentPath, fileName);

                    //using (StreamWriter w = File.AppendText(fileName))
                    //    w.Write(text);

                    Console.WriteLine("({0}) operator: ({1}){2}, progress: {3}/{4}", server, operators[i].Id, operators[i].Name, i + 1, operators.Length);
                    Trace.WriteLine(string.Format("({0}) operator: ({1}){2}, progress: {3}/{4}", server, operators[i].Id, operators[i].Name, i + 1, operators.Length));
                }

                ////delete old data
                //using (var conn = new MySql.Data.MySqlClient.MySqlConnection(exelconverterEntities2.ProviderConnectionString))
                //using (MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(@"UPDATE convertion_rules SET convertion_rule = '', convertion_rule_image = NULL;", conn))
                //{
                //    conn.Open();
                //    cmd.ExecuteNonQuery();
                //}

                passed = true;
            }
            catch (Exception ex)
            {
                exception = ex.GetExceptionText();
            }

            string errMsg = string.Format("server:{1}{0}login:{2}{0}password:{3}{0}connectionMain:{4}{0}connectionApp:{5}{0}shouldpass:{6}{0}passed:{7}{0}exception:{8}", Environment.NewLine, server, login, password, connectionMain, connectionApp, shouldPass, passed, exception);

            Assert.AreEqual(passed, shouldPass, errMsg);
        }
Exemplo n.º 10
0
        public void DataAccessTest_GetUsers()
        {
            string server = testContextInstance.DataRow["Server"].ToString();
            string login = testContextInstance.DataRow["Login"].ToString();
            string password = testContextInstance.DataRow["Password"].ToString();
            bool shouldPass = bool.Parse(testContextInstance.DataRow["ShouldPass"].ToString());
            string exception = string.Empty;
            string connectionMain = string.Empty;
            string connectionApp = string.Empty;
            HttpDataClient test = new HttpDataClient();

            var result = new ExelConverter.Core.DataObjects.User[] { };

            bool passed = false;
            try
            {
                test.Login(server, login, password);

                connectionMain = test.ConnectionStringMain;
                connectionApp = test.ConnectionStringApp;

                alphaEntities.ProviderConnectionString = connectionMain;
                //exelconverterEntities2.ProviderConnectionString = connectionApp;

                DataAccess da = new DataAccess();
                result = da.GetUsers(new[] { login });

                passed = true;

            }
            catch (Exception ex) { exception = ex.Message; }

            string errMsg = string.Format("server:{1}{0}login:{2}{0}password:{3}{0}connectionMain:{4}{0}connectionApp:{5}{0}shouldpass:{6}{0}passed:{7}{0}exception:{8}", Environment.NewLine, server, login, password, connectionMain, connectionApp, shouldPass, passed, exception);

            Assert.AreEqual(passed, shouldPass, errMsg);
            Assert.IsNotNull(result, errMsg + string.Format("{0}result is NULL", Environment.NewLine));
            Assert.AreNotEqual(result.Length, 0, errMsg + string.Format("{0}result is EMPTY", Environment.NewLine));
        }
Exemplo n.º 11
0
        public void DataAccessTest_GetRegionsByCity()
        {
            string server = testContextInstance.DataRow["Server"].ToString();
            string login = testContextInstance.DataRow["Login"].ToString();
            string password = testContextInstance.DataRow["Password"].ToString();
            bool shouldPass = bool.Parse(testContextInstance.DataRow["ShouldPass"].ToString());
            string exception = string.Empty;
            string connectionMain = string.Empty;
            string connectionApp = string.Empty;
            HttpDataClient test = new HttpDataClient();

            //var result = new ExelConverter.Core.DataObjects.Size[] { };
            bool passed = false;
            string errMsg = string.Format("server:{1}{0}login:{2}{0}password:{3}{0}connectionMain:{4}{0}connectionApp:{5}{0}shouldpass:{6}{0}passed:{7}{0}exception:{8}", Environment.NewLine, server, login, password, connectionMain, connectionApp, shouldPass, passed, exception);

            try
            {
                test.Login(server, login, password);

                connectionMain = test.ConnectionStringMain;
                connectionApp = test.ConnectionStringApp;

                alphaEntities.ProviderConnectionString = connectionMain;
                //exelconverterEntities2.ProviderConnectionString = connectionApp;

                DataAccess da = new DataAccess();

                ExelConverter.Core.DataObjects.City[] tps = da.GetCities();
                int cnt = tps.Length > 5 ? 5 : tps.Length;
                for (int i = 0; i < tps.Length; i+= (int)((float)tps.Length / (float)cnt))
                {
                    var result = da.GetRegionsByCity(tps[i]);
                    //Assert.IsNotNull(result, errMsg + string.Format("{0}result is NULL for type:{1}", Environment.NewLine, tp.Name));
                    //Assert.AreNotEqual(result.Length, 0, errMsg + string.Format("{0}result is EMPTY for type:{1}", Environment.NewLine, tp.Name));
                }

                passed = true;
            }
            catch (Exception ex) { exception = ex.Message; }

            errMsg = string.Format("server:{1}{0}login:{2}{0}password:{3}{0}connectionMain:{4}{0}connectionApp:{5}{0}shouldpass:{6}{0}passed:{7}{0}exception:{8}", Environment.NewLine, server, login, password, connectionMain, connectionApp, shouldPass, passed, exception);
            Assert.AreEqual(passed, shouldPass, errMsg);
        }
Exemplo n.º 12
0
        public void DataAccessTest_APP_GetRules()
        {
            string server = testContextInstance.DataRow["Server"].ToString();
            string login = testContextInstance.DataRow["Login"].ToString();
            string password = testContextInstance.DataRow["Password"].ToString();
            bool shouldPass = bool.Parse(testContextInstance.DataRow["ShouldPass"].ToString());
            string exception = string.Empty;
            string connectionMain = string.Empty;
            string connectionApp = string.Empty;
            HttpDataClient test = new HttpDataClient();

            var result = new ExelConverter.Core.Converter.ExelConvertionRule[] { };

            bool passed = false;
            try
            {
                test.Login(server, login, password);

                connectionMain = test.ConnectionStringMain;
                connectionApp = test.ConnectionStringApp;

                alphaEntities.ProviderConnectionString = connectionMain;
                exelconverterEntities2.ProviderConnectionString = connectionApp;

                DataAccess da = new DataAccess();
                ExelConverter.Core.Settings.SettingsProvider.Initialize(da);

                var operators = da.GetOperators();

                for (int i = 0; i < Math.Min(3, operators.Length); i++)
                {
                    var id = new Random().Next(operators.Length - 1);
                    result = da.GetRules(new int[] { (int)operators[id].Id });
                }
                passed = true;
            }
            catch (Exception ex) { exception = ex.GetExceptionText(); }

            string errMsg = string.Format("server:{1}{0}login:{2}{0}password:{3}{0}connectionMain:{4}{0}connectionApp:{5}{0}shouldpass:{6}{0}passed:{7}{0}exception:{8}", Environment.NewLine, server, login, password, connectionMain, connectionApp, shouldPass, passed, exception);

            Assert.AreEqual(passed, shouldPass, errMsg);

            Assert.IsNotNull(result, errMsg + string.Format("{0}result is NULL", Environment.NewLine));
            Assert.AreNotEqual(result.Length, 0, errMsg + string.Format("{0}result is EMPTY", Environment.NewLine));
        }