예제 #1
0
        private static RunHistory ProcessTestResults(IEnumerable <ValidationResponse> valCollection,
                                                     int?groupId, int?projectId)
        {
            var runHistoryLog = new StringBuilder();
            var runHistory    = new RunHistory
            {
                GroupId           = groupId,
                ProjectId         = projectId,
                RunDateTime       = DateTime.Now,
                RunHistoryDetails = new Collection <RunHistoryDetail>()
            };

            foreach (var valResult in valCollection)
            {
                var runHistoryDetail = new RunHistoryDetail
                {
                    TestId       = valResult.TestId,
                    RunDateTime  = valResult.RunDateTime,
                    IsValid      = valResult.IsValid,
                    Duration     = valResult.Duration,
                    ResultString = valResult.ResultMessage
                };
                runHistoryLog.AppendLine(valResult.TestName);
                runHistoryLog.AppendLine(valResult.ResultMessage);
                runHistoryLog.AppendLine(valResult.RunLog);
                runHistory.RunHistoryDetails.Add(runHistoryDetail);
            }
            runHistory.RunLog = runHistoryLog.ToString();
            return(runHistory);
        }
예제 #2
0
        public void Update_Should_Update_A_RunHistory()
        {
            _repository
            .Setup(it => it.Update(It.IsAny <Int32>(), It.IsAny <DateTime>(), It.IsAny <Boolean>(), It.IsAny <String>(), It.IsAny <String>(), It.IsAny <Int64>()))
            .Callback <Int32, DateTime, Boolean, String, String, Int64>((testId, runDateTime, isPass, runLog, resultString, id) =>
            {
                var tRunHistory          = _repositoryList.Find(x => x.Id == id);
                tRunHistory.TestId       = testId;
                tRunHistory.RunDateTime  = runDateTime;
                tRunHistory.IsPass       = isPass;
                tRunHistory.RunLog       = runLog;
                tRunHistory.ResultString = resultString;
            });
            var tempRunHistory = _repositoryList.Find(x => x.Id == id);
            var testRunHistory = new RunHistory {
                Id           = tempRunHistory.Id,
                TestId       = tempRunHistory.TestId,
                RunDateTime  = tempRunHistory.RunDateTime,
                IsPass       = tempRunHistory.IsPass,
                RunLog       = tempRunHistory.RunLog,
                ResultString = tempRunHistory.ResultString
            };

            //TODO change something on testRunHistory
            //testRunHistory.oldValue = newValue;
            _target.Update(testRunHistory);
            //Assert.AreEqual(newValue, _repositoryList.Find(x => x.Id==1).oldValue);
            //TODO fail until we update the test above
            Assert.Fail();
        }
예제 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            RunHistory runHistory = db.RunHistorySet.Find(id);

            db.RunHistorySet.Remove(runHistory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #4
0
 public static RunHistory IncludeRunHistoryDetail(this RunHistory runHistory, IRunHistoryDetailRepository RunHistoryDetailRepository)
 {
     if (runHistory.RunHistoryDetails != null)
     {
         return(runHistory);
     }
     runHistory.RunHistoryDetails = (RunHistoryDetailList)RunHistoryDetailRepository.GetDataByRunHistoryId(runHistory.Id);
     return(runHistory);
 }
예제 #5
0
 public ActionResult Edit([Bind(Include = "Id,Date,Result,RulesId,RuleRevision,Message")] RunHistory runHistory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(runHistory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RulesId = new SelectList(db.RulesSet, "Id", "Title", runHistory.RulesId);
     return(View(runHistory));
 }
예제 #6
0
 public static RunHistory IncludeTest(this RunHistory runHistory, ITestRepository testRepository)
 {
     if (runHistory.Test != null)
     {
         return(runHistory);
     }
     if (runHistory.TestId != null)
     {
         runHistory.Test = testRepository.GetDataById((int)runHistory.TestId).ToList().First();
     }
     return(runHistory);
 }
예제 #7
0
 public ActionResult Create(RunHistory runHistory)
 {
     try
     {
         _dbRunHistoryRepository.Insert(runHistory);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(runHistory));
     }
 }
예제 #8
0
 public ActionResult Edit(long id, RunHistory runHistory)
 {
     try
     {
         _dbRunHistoryRepository.Update(runHistory);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(runHistory));
     }
 }
예제 #9
0
 public ActionResult Create(RunHistory runHistory)
 {
     try
     {
         _dbRunHistoryRepository.Insert(runHistory);
         return RedirectToAction("Index");
     }
     catch
     {
         return View(runHistory);
     }
 }
예제 #10
0
 public ActionResult Edit(long id, RunHistory runHistory)
 {
     try
     {
         _dbRunHistoryRepository.Update(runHistory);
         return RedirectToAction("Index");
     }
     catch
     {
         return View(runHistory);
     }
 }
예제 #11
0
        public JobDataSource(SyncSide syncSide, DataSource dataSource, RunHistory history)
        {
            if (dataSource == null)
            {
                throw new Exception("Data source can not be null.");
            }

            DataSource = dataSource;

            SyncSide = syncSide;

            History = history;
        }
 public void Update(int? testId, int? projectId, int? groupId, int? connectionId, DateTime runDateTime,
     decimal? totalDuration, bool isValid, string runLog, long id)
 {
     using (var client = new HttpClient(_messageHandler))
     {
         client.BaseAddress = new Uri(_baseAddress);
         client.DefaultRequestHeaders.Accept.Clear();
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         var runHistory = new RunHistory(id, testId, projectId, groupId, connectionId, runDateTime, totalDuration,
             isValid, runLog);
         var response = client.PutAsync(UrlBase, runHistory, new JsonMediaTypeFormatter()).Result;
         response.EnsureSuccessStatusCode();
     }
 }
예제 #13
0
        // GET: RunHistories/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RunHistory runHistory = db.RunHistorySet.Find(id);

            if (runHistory == null)
            {
                return(HttpNotFound());
            }
            return(View(runHistory));
        }
예제 #14
0
 public void Update(int?testId, int?projectId, int?groupId, int?connectionId, DateTime runDateTime,
                    decimal?totalDuration, bool isValid, string runLog, long id)
 {
     using (var client = new HttpClient(_messageHandler))
     {
         client.BaseAddress = new Uri(_baseAddress);
         client.DefaultRequestHeaders.Accept.Clear();
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         var runHistory = new RunHistory(id, testId, projectId, groupId, connectionId, runDateTime, totalDuration,
                                         isValid, runLog);
         var response = client.PutAsync(UrlBase, runHistory, new JsonMediaTypeFormatter()).Result;
         response.EnsureSuccessStatusCode();
     }
 }
예제 #15
0
        // GET: RunHistories/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RunHistory runHistory = db.RunHistorySet.Find(id);

            if (runHistory == null)
            {
                return(HttpNotFound());
            }
            ViewBag.RulesId = new SelectList(db.RulesSet, "Id", "Title", runHistory.RulesId);
            return(View(runHistory));
        }
예제 #16
0
        public void Test_RunHistory_Constructor_PostedTweetsShouldContain3Items()
        {
            DateTime dt   = DateTime.UtcNow;
            XElement root = new XElement("PullRequests");

            root.SetAttributeValue("lastrun", dt);
            root.Add(new XElement("PullRequest", "1"));
            root.Add(new XElement("PullRequest", "2"));
            root.Add(new XElement("PullRequest", "3"));

            XDocument doc = new XDocument();

            doc.Add(root);

            var runHistory = new RunHistory(doc);

            Assert.AreEqual(3, runHistory.PostedTweets.Count);
            Assert.AreEqual(dt, runHistory.LastRun);
        }
 public void Delete(RunHistory runHistory)
 {
     Delete(runHistory.Id);
 }
 public long Insert(RunHistory runHistory)
 {
     return Insert(runHistory.TestId, runHistory.ProjectId, runHistory.GroupId, runHistory.ConnectionId,
         runHistory.RunDateTime, runHistory.TotalDuration, runHistory.IsValid, runHistory.RunLog);
 }
예제 #19
0
        private void tsmStatistic_Click(object sender, EventArgs e)
        {
            RunHistory runHistory = new RunHistory();

            runHistory.ShowDialog();
        }
예제 #20
0
 public long Insert(RunHistory runHistory)
 {
     return(Insert(runHistory.TestId, runHistory.ProjectId, runHistory.GroupId, runHistory.ConnectionId,
                   runHistory.RunDateTime, runHistory.TotalDuration, runHistory.IsValid, runHistory.RunLog));
 }
예제 #21
0
 public void Update(RunHistory runHistory)
 {
     _dbRepository.Update(runHistory.TestId, runHistory.ProjectId, runHistory.GroupId, runHistory.ConnectionId, (DateTime)runHistory.RunDateTime, runHistory.TotalDuration, (bool)runHistory.IsValid, runHistory.RunLog, runHistory.Id);
 }
예제 #22
0
 public void Update(RunHistory runHistory)
 {
     _dbRepository.Update(runHistory.TestId, runHistory.ProjectId, runHistory.GroupId, runHistory.ConnectionId, (DateTime)runHistory.RunDateTime, runHistory.TotalDuration, (bool)runHistory.IsValid, runHistory.RunLog, runHistory.Id);
 }
예제 #23
0
 public void Delete(RunHistory runHistory)
 {
     Delete(runHistory.Id);
 }
예제 #24
0
 public void Update_Should_Update_A_RunHistory() 
 {
     _repository
          .Setup(it => it.Update(It.IsAny<Int32>(), It.IsAny<DateTime>(), It.IsAny<Boolean>(), It.IsAny<String>(), It.IsAny<String>(), It.IsAny<Int64>()))
          .Callback<Int32, DateTime, Boolean, String, String, Int64>((testId, runDateTime, isPass, runLog, resultString, id) => 
     { 
          var tRunHistory = _repositoryList.Find(x => x.Id==id);
          tRunHistory.TestId = testId; 
          tRunHistory.RunDateTime = runDateTime; 
          tRunHistory.IsPass = isPass; 
          tRunHistory.RunLog = runLog; 
          tRunHistory.ResultString = resultString; 
     });
     var tempRunHistory = _repositoryList.Find(x => x.Id==id);
     var testRunHistory = new RunHistory {
          Id = tempRunHistory.Id, 
          TestId = tempRunHistory.TestId, 
          RunDateTime = tempRunHistory.RunDateTime, 
          IsPass = tempRunHistory.IsPass, 
          RunLog = tempRunHistory.RunLog, 
          ResultString = tempRunHistory.ResultString};
     
     //TODO change something on testRunHistory
     //testRunHistory.oldValue = newValue; 
     _target.Update(testRunHistory);
     //Assert.AreEqual(newValue, _repositoryList.Find(x => x.Id==1).oldValue);
     //TODO fail until we update the test above
     Assert.Fail();
 }
예제 #25
0
 private static RunHistory ProcessTestResults(IEnumerable<ValidationResponse> valCollection,
     int? groupId, int? projectId)
 {
     var runHistoryLog = new StringBuilder();
     var runHistory = new RunHistory
     {
         GroupId = groupId,
         ProjectId = projectId,
         RunDateTime = DateTime.Now,
         RunHistoryDetails = new Collection<RunHistoryDetail>()
     };
     foreach (var valResult in valCollection)
     {
         var runHistoryDetail = new RunHistoryDetail
         {
             TestId = valResult.TestId,
             RunDateTime = valResult.RunDateTime,
             IsValid = valResult.IsValid,
             Duration = valResult.Duration,
             ResultString = valResult.ResultMessage
         };
         runHistoryLog.AppendLine(valResult.TestName);
         runHistoryLog.AppendLine(valResult.ResultMessage);
         runHistoryLog.AppendLine(valResult.RunLog);
         runHistory.RunHistoryDetails.Add(runHistoryDetail);
     }
     runHistory.RunLog = runHistoryLog.ToString();
     return runHistory;
 }
예제 #26
0
        // Calculates and returns the penalty score based on state of this QR code's current modules.
        // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
        private int GetPenaltyScore()
        {
            int        result     = 0;
            RunHistory runHistory = new RunHistory();

            // Adjacent modules in row having same color, and finder-like patterns
            int index = 0;

            for (int y = 0; y < Size; y++)
            {
                runHistory.Reset();
                bool color = false;
                int  runX  = 0;
                for (int x = 0; x < Size; x++)
                {
                    if (_modules[index] == color)
                    {
                        runX++;
                        if (runX == 5)
                        {
                            result += PenaltyN1;
                        }
                        else if (runX > 5)
                        {
                            result++;
                        }
                    }
                    else
                    {
                        runHistory.Add(runX);
                        if (!color && runHistory.HasFinderLikePattern())
                        {
                            result += PenaltyN3;
                        }

                        color = _modules[index];
                        runX  = 1;
                    }

                    index++;
                }
                runHistory.Add(runX);
                if (color)
                {
                    runHistory.Add(0);  // Dummy run of white
                }

                if (runHistory.HasFinderLikePattern())
                {
                    result += PenaltyN3;
                }
            }

            // Adjacent modules in column having same color, and finder-like patterns
            for (int x = 0; x < Size; x++)
            {
                index = x;
                runHistory.Reset();
                bool color = false;
                int  runY  = 0;
                for (int y = 0; y < Size; y++)
                {
                    if (_modules[index] == color)
                    {
                        runY++;
                        if (runY == 5)
                        {
                            result += PenaltyN1;
                        }
                        else if (runY > 5)
                        {
                            result++;
                        }
                    }
                    else
                    {
                        runHistory.Add(runY);
                        if (!color && runHistory.HasFinderLikePattern())
                        {
                            result += PenaltyN3;
                        }

                        color = _modules[index];
                        runY  = 1;
                    }

                    index += Size;
                }
                runHistory.Add(runY);
                if (color)
                {
                    runHistory.Add(0);  // Dummy run of white
                }

                if (runHistory.HasFinderLikePattern())
                {
                    result += PenaltyN3;
                }
            }

            // 2*2 blocks of modules having same color
            index = 0;
            for (int y = 0; y < Size - 1; y++)
            {
                for (int x = 0; x < Size - 1; x++)
                {
                    bool color = _modules[index];
                    if (color == _modules[index + 1] &&
                        color == _modules[index + Size] &&
                        color == _modules[index + Size + 1])
                    {
                        result += PenaltyN2;
                    }

                    index++;
                }

                index++;
            }

            // Balance of black and white modules
            int black = 0;

            index = 0;
            for (int y = 0; y < Size; y++)
            {
                for (int x = 0; x < Size; x++)

                {
                    if (_modules[index])
                    {
                        black++;
                    }

                    index++;
                }
            }
            int total = Size * Size;  // Note that size is odd, so black/total != 1/2
                                      // Compute the smallest integer k >= 0 such that (45-5k)% <= black/total <= (55+5k)%
            int k = (Math.Abs(black * 20 - total * 10) + total - 1) / total - 1;

            result += k * PenaltyN4;
            return(result);
        }
 public void Update(RunHistory runHistory)
 {
     Update(runHistory.TestId, runHistory.ProjectId, runHistory.GroupId, runHistory.ConnectionId,
         runHistory.RunDateTime, runHistory.TotalDuration, runHistory.IsValid, runHistory.RunLog, runHistory.Id);
 }
예제 #28
0
 public void Update(RunHistory runHistory)
 {
     Update(runHistory.TestId, runHistory.ProjectId, runHistory.GroupId, runHistory.ConnectionId,
            runHistory.RunDateTime, runHistory.TotalDuration, runHistory.IsValid, runHistory.RunLog, runHistory.Id);
 }
예제 #29
0
 public Int64 Insert(RunHistory runHistory)
 {
     return(_dbRepository.Insert(runHistory.TestId, runHistory.ProjectId, runHistory.GroupId, runHistory.ConnectionId, (DateTime)runHistory.RunDateTime, runHistory.TotalDuration, (bool)runHistory.IsValid, runHistory.RunLog));
 }
예제 #30
0
 public Int64 Insert(RunHistory runHistory)
 {
     return _dbRepository.Insert(runHistory.TestId, runHistory.ProjectId, runHistory.GroupId, runHistory.ConnectionId, (DateTime)runHistory.RunDateTime, runHistory.TotalDuration, (bool)runHistory.IsValid, runHistory.RunLog);
 }