public void ThenTheOutputWillMatch(string fileType, Table table)
        {
            var compareFile = table.Rows[0]["Compare File"];

            string runGUID         = Guid.NewGuid().ToString();
            string compareFileName = runGUID + "_" + compareFile;

            var    asm        = ScenarioContext.Current["AssemblyContext"] as Assembly;
            string moduleName = asm.ManifestModule.Name.Replace(".dll", "");

            ResourceHelper.CopyResource(asm, moduleName + ".TestData." + compareFile, compareFileName);

            // find output
            string outFileName  = "";
            string outDirectory = "";
            string filePrefix   = "";
            string fileSuffix   = "";

            try
            {
                Debug.WriteLine("Finding SendPorts");
                var sendPort = BizTalkBill.TestingFramework.Utilities.Configuration.TestConfiguration.Current.SendPorts.Get("BizTalk", "*" + fileType);
                if (sendPort != null)
                {
                    outDirectory = sendPort.URL;
                    filePrefix   = sendPort.FilePrefix;
                    fileSuffix   = sendPort.FileSuffix;

                    if (!string.IsNullOrWhiteSpace(outDirectory))
                    {
                        DirectoryInfo outDir     = new DirectoryInfo(outDirectory);
                        var           fileInfo   = outDir.EnumerateFiles(filePrefix + "*" + fileSuffix);
                        Int32         foundCount = 0;
                        foreach (var file in fileInfo)
                        {
                            Debug.WriteLine("Output File Found = " + file.FullName);
                            outFileName = file.FullName;
                            foundCount++;
                        }
                        if (foundCount != 1)
                        {
                            Assert.Fail(string.Format("{0} Output Files Found", foundCount));
                        }
                    }
                }
            }
            catch (Exception Ex1)
            {
                Debug.WriteLine(Ex1.ToString());
            }

            if (compareFileName.ToUpper().EndsWith("XML"))
            {
                Assert.IsTrue(BizTalkBill.TestingFramework.Helpers.XML.FileCompare.CompareXMLFiles(outFileName, compareFileName), "The File Compare Failed");
            }
            else
            {
                Assert.IsTrue(BizTalkBill.TestingFramework.Helpers.IO.FileHelper.FileCompare(outFileName, compareFileName), "The File Compare Failed");
            }
        }
        public void GivenThereIsToProcess(string fileType, Table table)
        {
            Debug.WriteLine("GivenThereIsToProcess(" + fileType + ")");

            // clean out output directory
            string outDirectory = "";
            string filePrefix   = "";
            string fileSuffix   = "";

            try
            {
                Debug.WriteLine("Finding SendPorts");
                var sendPort = BizTalkBill.TestingFramework.Utilities.Configuration.TestConfiguration.Current.SendPorts.Get("BizTalk", "*" + fileType + "*");
                if (sendPort != null)
                {
                    outDirectory = sendPort.URL;
                    filePrefix   = sendPort.FilePrefix;
                    fileSuffix   = sendPort.FileSuffix;

                    if (!string.IsNullOrWhiteSpace(outDirectory))
                    {
                        DirectoryInfo outDir   = new DirectoryInfo(outDirectory);
                        var           fileInfo = outDir.EnumerateFiles(filePrefix + "*" + fileSuffix);
                        ScenarioContext.Current.Add("ProcessOutputFileDirectory", outDirectory);
                        ScenarioContext.Current.Add("ProcessOutputFileMask", filePrefix + "*" + fileSuffix);
                        foreach (var file in fileInfo)
                        {
                            Debug.WriteLine("File to Delete = " + file.FullName);

                            File.Delete(file.FullName);
                        }
                    }
                }
            }
            catch (Exception Ex1)
            {
                Debug.WriteLine(Ex1.ToString());
            }

            // get input file
            var filePath = table.Rows[0]["Message Path"];

            ScenarioContext.Current.Add("TestDataFile", filePath);

            Debug.WriteLine(filePath);

            var    asm        = ScenarioContext.Current["AssemblyContext"] as Assembly;
            string moduleName = asm.ManifestModule.Name.Replace(".dll", "");

            Debug.WriteLine(moduleName);

            ManifestResourceInfo riTestData = asm.GetManifestResourceInfo(moduleName + ".TestData." + filePath);

            Assert.IsNotNull(riTestData, "Test File not found as a Resource");
        }
Exemple #3
0
        private void btn_delete_course_Click(object sender, EventArgs e)
        {
            if (cmb_courseDELETE_name.Text == "")
            {
                MessageBox.Show("Select Course");
            }
            else
            {
                try
                {
                    cmd = new SqlCommand("select c_id from course where c_name='" + cmb_courseDELETE_name.Text + "'", con);
                    SqlDataReader dr = cmd.ExecuteReader();
                    dr.Read();
                    tmp1 = Int32.Parse(dr.GetValue(0).ToString());;
                    if (MessageBox.Show("Are You Sure To Delete..!!", "Delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        cmd = new SqlCommand("delete from course where c_name='" + cmb_courseDELETE_name.Text + "'", con);
                        CO1 = cmd.ExecuteNonQuery();

                        cmd = new SqlCommand("delete from semester where C_id='" + tmp1 + "'", con);
                        SE1 = cmd.ExecuteNonQuery();

                        cmd = new SqlCommand("delete from subject where C_id='" + tmp1 + "'", con);
                        SU1 = cmd.ExecuteNonQuery();

                        cmd = new SqlCommand("delete from exam where C_id='" + tmp1 + "'", con);
                        Ex1 = cmd.ExecuteNonQuery();


                        MessageBox.Show(CO1.ToString() + " Course Deleted\n" + SE1.ToString() + " Semester Deleted\n" + SU1.ToString() + " Subject Deleted \n" + Ex1.ToString() + " Exam Deleted");
                    }
                }
                catch (Exception x)
                {
                    MessageBox.Show("Some Error Check Semester/Subject Are set.!", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }
            }
            fill_cmb();
        }
Exemple #4
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (goodInput && !loading)
            {
                loading = true;
                toolStripButton1.Enabled = false;

                if (iterations >= 100000)
                {
                    DialogResult option = MessageBox.Show("Running " + iterations + " simulations will " +
                                                          "take approximately: " + getTime() + "\nDo you wish to continue?", "Alert", MessageBoxButtons.OKCancel);

                    if (option == DialogResult.Cancel)
                    {
                        goto Done;
                    }
                }

                try
                {
                    if (pictureBox1.Image != null)
                    {
                        pictureBox1.Image.Dispose();
                    }
                }
                catch (Exception Ex0)
                {
                    var nullErrorMessageBox = MessageBox.Show
                                                  ("ERROR disposing old image file! \nOutput: "
                                                  + Ex0.ToString(), "Alert", MessageBoxButtons.OK);
                }

                RscriptWriter();

                userInputScript = rPathDest;
                Console.WriteLine("userInputScript: " + userInputScript);

                outputLocation = RpathFinder();
                Console.WriteLine("outputLocation: " + outputLocation);

                try
                {
                    RunFromCmd(userInputScript, userInputCSV, outputLocation, iterations.ToString(), distributionType);
                }
                catch (Exception Ex1)
                {
                    var nullErrorMessageBox = MessageBox.Show
                                                  ("ERROR on CMD process! \nOutput: "
                                                  + Ex1.ToString(), "Alert", MessageBoxButtons.OK);
                }

                try
                {
                    Cursor.Current             = Cursors.WaitCursor;
                    toolStripButton1.BackColor = Color.GreenYellow;

                    if (iterations >= 10000000)
                    {
                        Thread.Sleep(Convert.ToInt32(iterations * 0.10));
                    }
                    else if (iterations >= 100000 && iterations < 10000000)
                    {
                        Thread.Sleep(Convert.ToInt32(iterations * 0.30));
                    }
                    else if (iterations >= 10000 && iterations < 100000)
                    {
                        Thread.Sleep(Convert.ToInt32(iterations * 0.50));
                    }
                    else
                    {
                        Thread.Sleep(2500);
                    }
                }
                catch (Exception Ex2)
                {
                    var nullErrorMessageBox = MessageBox.Show
                                                  ("ERROR waiting for process to complete! \nOuput: "
                                                  + Ex2.ToString(), "Alert", MessageBoxButtons.OK);
                }

                try
                {
                    pictureBox1.Image = Image.FromFile(RpathFinder() + @"\output.png");
                }
                catch (Exception Ex3)
                {
                    var nullErrorMessageBox = MessageBox.Show
                                                  ("ERROR loading the image file! \nOuput: "
                                                  + Ex3.ToString(), "Alert", MessageBoxButtons.OK);
                }

Done:
                try
                {
                    if (!string.IsNullOrWhiteSpace(userInputScript))
                    {
                        DeleteTempFile(userInputScript);
                    }

                    //if (!string.IsNullOrWhiteSpace(userInputScript))
                    //DeleteTempFile(RpathFinder() + @"\output.png");

                    loading    = false;
                    maxWarning = false;
                    minWarning = false;
                }
                catch (Exception Ex4)
                {
                    var nullErrorMessageBox = MessageBox.Show
                                                  ("ERROR on cleanup process! \nOutput: "
                                                  + Ex4.ToString(), "Alert", MessageBoxButtons.OK);
                }
            }
        }
        public void ThenBizTalkWillReceiveTheMessage(string portName)
        {
            Debug.WriteLine("BizTalkBill.TestingFramework.SpecFlow:SharedSteps:ThenBizTalkWillReceiveTheMessage(" + portName + ")");

            ApplicationEventLog.CheckForDiagnosticEvent("BizTalk has received a message on port - " + portName);

            System.Threading.Thread.Sleep(100);

            Int32  ReceiveCount = 0;
            string LastMessageTrackingDateTime = (string)ScenarioContext.Current["LastMessageTrackingDateTime"];

            new Logger().Write("LastMessageTrackingDateTime = " + LastMessageTrackingDateTime);

            string dbServerName = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\BizTalk Server\3.0\Administration", "MgmtDBServer", "localhost");

            using (SqlConnection connection2 = new SqlConnection("Data Source=" + dbServerName + ";Initial Catalog=BizTalkDTADb;Integrated Security=True"))
            {
                string sCommand2 = string.Format("SELECT TOP 1 convert(varchar(50),[Event/Timestamp],126)  FROM [BizTalkDTADb].[dbo].[dtav_MessageFacts] where [Event/Port] = '{0}' order by [Event/Timestamp] desc", portName);
                new Logger().Write("SQL Command = " + sCommand2);

                using (SqlCommand command2 = new SqlCommand(sCommand2, connection2))
                {
                    try
                    {
                        connection2.Open();

                        var lastfound = (string)command2.ExecuteScalar();

                        if (lastfound != null)
                        {
                            new Logger().Write("LastMessageFoundTrackingDateTime = " + lastfound);
                        }
                        else
                        {
                            new Logger().Write("returned null");
                        }
                    }
                    catch (Exception Ex1)
                    {
                        new Logger().Write("Error in LastMessageFoundTrackingDateTime - " + Ex1.ToString());
                        //throw;
                    }
                }
            }
            using (SqlConnection connection = new SqlConnection("Data Source=" + dbServerName + ";Initial Catalog=BizTalkDTADb;Integrated Security=True"))
            {
                string sCommand = string.Format("select count(*) FROM [BizTalkDTADb].[dbo].[dtav_MessageFacts] where [Event/Timestamp] > '{0}' and [Event/Port] = '{1}'", LastMessageTrackingDateTime, portName);
                new Logger().Write("SQL Command = " + sCommand);

                new Logger().Write("Starting Receive Check = " + DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fff"));
                for (int i = 1; i <= 20; i++)
                {
                    using (SqlCommand command = new SqlCommand(sCommand, connection))
                    {
                        try
                        {
                            connection.Open();
                            ReceiveCount = (Int32)command.ExecuteScalar();
                            connection.Close();

                            new Logger().Write("ReceiveCount = " + ReceiveCount.ToString());
                        }
                        catch (Exception Ex1)
                        {
                            new Logger().Write("Exception = " + Ex1.Message);
                            //throw;
                        }
                    }
                    new Logger().Write("Ending Receive Check = " + DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fff"));

                    if (ReceiveCount > 0)
                    {
                        Debug.WriteLine("Break");
                        break;
                    }
                    Debug.WriteLine("Looping");
                    if (i <= 5)
                    {
                        System.Threading.Thread.Sleep(500);
                    }
                    else
                    {
                        Int32 sleepTime = 3000 * (i - 5);
                        System.Threading.Thread.Sleep(sleepTime);
                    }
                }
            }

            Assert.IsFalse(ReceiveCount < 1, "Message Not Received on Port - " + portName);
        }
Exemple #6
0
        public static void ExecuteMapTest(AssemblyName[] refList, string dllName, string mapName, string sourceFileName, string sourceFileType, string destFileName, string destFileType, bool validateInput, bool validateOutput)
        {
            //var refList = typeof(Program).Assembly.GetReferencedAssemblies();

            Debug.WriteLine("dllName = " + dllName);
            Debug.WriteLine("mapName = " + mapName);
            Debug.WriteLine("sourceFileName = " + sourceFileName);
            Debug.WriteLine("sourceFileType = " + sourceFileType);
            Debug.WriteLine("destFileName = " + destFileName);
            Debug.WriteLine("destFileType = " + destFileType);
            Debug.WriteLine("validateInput = " + validateInput);
            Debug.WriteLine("validateOutput = " + validateOutput);


            Assembly mapASM = null;

            //try loading locally (failed always loads from GAC)
            //try
            //{
            //    string asmPath = Assembly.GetExecutingAssembly().Location;
            //    Debug.WriteLine(asmPath);
            //    FileInfo asmInfo = new FileInfo(asmPath);
            //    Debug.WriteLine(asmInfo.DirectoryName);
            //    //mapASM = Assembly.LoadFile(asmInfo.DirectoryName + "\\" + dllName + ".dll");
            //    mapASM = Assembly.LoadFrom(asmInfo.DirectoryName + "\\" + dllName + ".dll");
            //    Debug.WriteLine("mapASM loaded from local file");
            //    Debug.WriteLine("From GAC = " + mapASM.GlobalAssemblyCache.ToString());
            //}
            //catch (Exception ex1)
            //{
            //    Debug.WriteLine(ex1.ToString());
            //}

            // otherwise from gac
            if (mapASM == null)
            {
                foreach (var refASM in refList)
                {
                    if (refASM.Name == dllName)
                    {
                        mapASM = Assembly.Load(refASM);
                        Debug.WriteLine("Found DLL - " + dllName);
                    }
                }
            }

            //AssemblyName myAssemblyName = AssemblyName.GetAssemblyName(dllName);
            //var mapASM = Assembly.Load(myAssemblyName);

            //FileInfo fiDLL = new FileInfo(dllName);
            //string baseDLLNamee = fiDLL.Name.Replace(fiDLL.Extension, "");

            Debug.WriteLine("Finding MAP - " + dllName + "." + mapName);

            var mapObject = mapASM.GetType(dllName + "." + mapName);

            if (mapObject != null)
            {
                Debug.WriteLine("MAP Found - " + dllName + "." + mapName);

                TestableMapBase map = (TestableMapBase)Activator.CreateInstance(mapObject);

                map.ValidateInput  = validateInput;
                map.ValidateOutput = validateOutput;

                Debug.WriteLine("Validation Set");

                CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
                TextInfo    textInfo    = cultureInfo.TextInfo;

                Microsoft.BizTalk.TestTools.Schema.InputInstanceType  inType  = (Microsoft.BizTalk.TestTools.Schema.InputInstanceType)Enum.Parse(typeof(Microsoft.BizTalk.TestTools.Schema.InputInstanceType), textInfo.ToTitleCase(sourceFileType));
                Microsoft.BizTalk.TestTools.Schema.OutputInstanceType outType = (Microsoft.BizTalk.TestTools.Schema.OutputInstanceType)Enum.Parse(typeof(Microsoft.BizTalk.TestTools.Schema.OutputInstanceType), (destFileType.ToUpper() == "XML") ? "XML" : destFileType);

                Debug.WriteLine("Enums Processed");

                try
                {
                    Debug.WriteLine("Testing Map - " + sourceFileName + ", " + inType.ToString() + ", " + destFileName + ", " + outType.ToString());
                    map.TestMap(sourceFileName, inType, destFileName, outType);
                }
                catch (Exception Ex1)
                {
                    throw new ApplicationException("Map Execution Failed - " + Ex1.ToString());
                }
            }
        }