public void TestGetAcceptedFileCount()
        {
            foreach (DbConnection connection in emptyConnections)
            {
                Assert.Throws <Exception>(() => DBFunctions.GetAcceptedFileCount(connection));
            }

            foreach (DbConnection connection in populousConnections)
            {
                Assert.Throws <Exception>(() => DBFunctions.GetAcceptedFileCount(connection));

                DataTable acceptStatsLogs = TableFactory.CreateEmptyAcceptStatsLogsTable();
                acceptStatsLogs.Rows.Add(1, "foo", new DateTime(2020, 1, 2), "bar", "why not", 1, new DateTime(2020, 1, 2), 1, 3);
                acceptStatsLogs.Rows.Add(1, "foo", new DateTime(2020, 1, 2), "baz", "reasons", 1, new DateTime(2020, 1, 2), 0, 4);
                Utility.InsertDataIntoDatabase(connection, acceptStatsLogs);

                Assert.AreEqual(4, DBFunctions.GetAcceptedFileCount(connection));
            }
        }
示例#2
0
        public IHttpActionResult GetAcceptedStatsStatusAndUpdateGithub(int id)
        {
            Utilities.WriteToLogFile("-----------------------------------");
            bool passed = false;

            using (SqlConnection sqlCon = new SqlConnection(Utilities.GetConnectionString()))
            {
                sqlCon.Open();
                try
                {
                    double percentPassed     = DBFunctions.GetPercentPassed(sqlCon, id);
                    int    acceptedFileCount = DBFunctions.GetAcceptedFileCount(sqlCon);
                    int    currentFileCount  = DBFunctions.GetFileCount(sqlCon, id);
                    passed = percentPassed == 100 && currentFileCount == acceptedFileCount;
                }
                catch (Exception ex)
                {
                    Utilities.WriteToLogFile(string.Format("ERROR:  Pull Request Id {0}, Unable to determine Passed/Failed status: {1}", id.ToString(), ex.Message.ToString()));;
                }
                CallGitHubWithPassFail(id, passed);
                Utilities.WriteToLogFile(string.Format("   Pull Request Id {0}, PassedTestsStatus verified and Github updated.", id.ToString()));;
            }
            return(Ok());
        }