コード例 #1
0
        private void GetFileDetailsInDB(string fileName, int rowsReturned, string upload)
        {
            Logger.Info("Verifying database for file deatils");
            int numOfRows = DBConnectHelper.RowReturnedQuery("Select * from dbo.documents where filename = '" + fileName + "'; ", DatabaseName.Documents);

            Assert.AreEqual(rowsReturned, numOfRows);
            List <DatabaseResult> output = DBConnectHelper.GetQueryResult(
                "SELECT FileName,Created_at,Updated_by,Version FROM dbo.Documents where filename = '" + fileName + "' order by Created_at desc", DatabaseName.Documents);

            Logger.Info("Checking " + upload + " file name and versions in database");
            if (upload == "Initial Upload")
            {
                Assert.AreEqual(output[0].firstColumn, fileName);
                Assert.AreEqual(Convert.ToInt16(output[0].forthColumn), 1);
                Assert.AreEqual(output[0].thirdColumn, "ECO Operations");
            }
            else if (upload == "Duplicate Upload")
            {
                Assert.AreEqual(output[0].firstColumn, fileName);
                Assert.AreEqual(output[1].firstColumn, fileName);
                Assert.AreEqual(Convert.ToInt16(output[0].forthColumn), 2);
                Assert.AreEqual(Convert.ToInt16(output[1].forthColumn), 1);
                Assert.AreEqual(output[0].thirdColumn, "ECO Operations");
                Assert.AreEqual(output[1].thirdColumn, "ECO Operations");
            }
            string todaysDate          = DateTime.Now.ToString("M/d/yyyy");
            string dateRetrievedFromDB = output[0].secondColumn;

            Assert.AreEqual(todaysDate, dateRetrievedFromDB.Split(' ')[0]);
        }
コード例 #2
0
        public void ThenUploadWillNotBeDoneAndFileRecordWillNotBeCreatedAgain()
        {
            string fileName  = Path.GetFileName(validFile);
            int    numOfRows = DBConnectHelper.RowReturnedQuery("Select * from dbo.documents where filename = '" + fileName + "'; ", DatabaseName.Documents);

            Assert.AreEqual(1, numOfRows);
            List <DatabaseResult> output = DBConnectHelper.GetQueryResult(
                "SELECT Version FROM dbo.Documents where filename = '" + fileName + "' order by Created_at desc", DatabaseName.Documents);

            Assert.AreEqual(1, output.Count);
            Assert.AreEqual(1, Convert.ToInt16(output[0].firstColumn));
        }
コード例 #3
0
ファイル: FileFormatSteps.cs プロジェクト: mrmervin/Ecotest
        public void ThenFileWillBeProcessedWithRecordCreatedInDatabase(string p0)
        {
            Logger.Info("Verifying database for file deatils");
            string fileName  = WhichFile(p0);
            int    numOfRows = DBConnectHelper.RowReturnedQuery("Select * from dbo.documents where filename = '" + fileName + "'; ", DatabaseName.Documents);

            Assert.AreEqual(1, numOfRows);
            List <DatabaseResult> output = DBConnectHelper.GetQueryResult(
                "SELECT Version,DocId,Created_at FROM dbo.Documents where filename = '" + fileName + "' order by Created_at desc", DatabaseName.Documents);
            string todaysDate          = DateTime.Now.ToString("M/d/yyyy");
            string dateRetrievedFromDB = output[0].thirdColumn.Split(' ')[0];

            Assert.AreEqual(todaysDate, dateRetrievedFromDB);
            bool deleteFile = DBConnectHelper.DeleteRow("dbo.documents", "fileName", fileName, DatabaseName.Documents);

            Assert.IsTrue(deleteFile);
        }