public void CurrentStatus_should_reflect_the_status_of_the_latest_build(string sampleRss, BuildStatus expectedStatus)
        {
            var rssFeedMock = Substitute.For<IJenkinsRssFeed>();
            rssFeedMock.Read().Returns(sampleRss);

            var monitor = new BuildMonitor(rssFeedMock);

            monitor.GetCurrentBuildStatus().Should().Be(expectedStatus);
        }
예제 #2
0
        private ActionResult _Verify(string buildName, string motherboard_id, string gpu_id, string cpu_id, string ram_id, string psu_id, string case_id, string monitor_id, string pci_id, string hard_id, string optical_id, bool c)
        {
            bool     OVERRIDE = false;
            Entities ORM      = new Entities();
            Build    temp     = new Build();

            temp.BuildName   = buildName;
            temp.OwnerID     = User.Identity.GetUserId();
            temp.BuildID     = Guid.NewGuid().ToString("D");
            temp.Motherboard = ORM.Motherboards.Find(motherboard_id);
            temp.GPU         = ORM.GPUs.Find(gpu_id);
            temp.CPU         = ORM.CPUs.Find(cpu_id);
            BuildsRAM _ram = new BuildsRAM();

            _ram.BuildID = temp.BuildID;
            _ram.RAMID   = ram_id;
            _ram.RAM     = ORM.RAMs.Find(ram_id);
            temp.BuildsRAMs.Add(_ram);
            temp.PSU    = ORM.PSUs.Find(psu_id);
            temp.PCCase = ORM.PCCases.Find(case_id);
            BuildMonitor _monitor = new BuildMonitor();

            _monitor.BuildID   = temp.BuildID;
            _monitor.Monitor   = ORM.Monitors.Find(monitor_id);
            _monitor.MonitorID = monitor_id;
            temp.BuildMonitors.Add(_monitor);
            temp.BuildsPeripherals = null;
            BuildPCI _pci = new BuildPCI();

            _pci.BuildID = temp.BuildID;
            _pci.PCICard = ORM.PCICards.Find(pci_id);
            _pci.PCIID   = pci_id;
            temp.BuildPCIs.Add(_pci);
            BuildDisk _hd = new BuildDisk();

            _hd.BuildID   = temp.BuildID;
            _hd.HardDrive = ORM.HardDrives.Find(hard_id);
            _hd.HDID      = hard_id;
            temp.BuildDisks.Add(_hd);
            BuildOD _od = new BuildOD();

            _od.BuildID       = temp.BuildID;
            _od.ODID          = optical_id;
            _od.OpticalDriver = ORM.OpticalDrivers.Find(optical_id);
            List <string[]> flags = temp.GetCompat();

            OVERRIDE = true;    //Comment this out to re-enable validation before creation.
            if ((flags[0][0] == "End" || OVERRIDE) && c)
            {
                ORM.Builds.Add(temp);
                ORM.SaveChanges();
                return(RedirectToAction("Display", "Builds", new { id = temp.BuildID }));
            }
            ViewBag.Flags = flags;
            return(_Create(temp, User.Identity.GetUserId()));
        }
예제 #3
0
        public void Should_stop_job_scheduler_when_stopped()
        {
            var jobScheduler = new Mock<IJobScheduler>();
            var log = new Mock<ILog>();

            var buildMonitor = new BuildMonitor(jobScheduler.Object, log.Object);

            buildMonitor.Stop();

            jobScheduler.Verify(k => k.Stop());
        }
예제 #4
0
        public static void Main()
        {
            var httpChannel   = new HttpChannel();
            var configuration = new BuildMonitorConfiguration
            {
                BuildServerStatusPageUri = new Uri("http://www.google.com"),
                SuccessfulBuildString    = "I r successful",
                FailedBuildString        = "I r failed"
            };

            _monitor = new BuildMonitor(configuration, httpChannel, OnSuccessfulBuild, OnFailedBuild, OnErrorDeterminingBuildStatus);
            _monitor.StartMonitoring();

            while (true)
            {
                Thread.Sleep(500);
            }
        }
예제 #5
0
        /// <summary>
        /// Diff the 2 root files.
        /// Completely taken from https://github.com/Marlamin/CASCToolHost/blob/master/CASCToolHost/Controllers/RootController.cs#L59
        /// </summary>
        /// <param name="oldRoot"></param>
        /// <param name="newRoot"></param>
        public static IEnumerable <RootEntry> DiffRoot(string oldRootHash, string newRootHash)
        {
            try
            {
                var oldRootStream = BuildMonitor.RequestCDN($"tpr/wow/data/{oldRootHash.Substring(0, 2)}/{oldRootHash.Substring(2, 2)}/{oldRootHash}");
                var newRootStream = BuildMonitor.RequestCDN($"tpr/wow/data/{newRootHash.Substring(0, 2)}/{newRootHash.Substring(2, 2)}/{newRootHash}");

                if (oldRootStream == null || newRootStream == null)
                {
                    return(new List <RootEntry>());
                }

                var rootFromEntries = ParseRoot(oldRootStream).FileDataIds;
                var rootToEntries   = ParseRoot(newRootStream).FileDataIds;

                var fromEntries = rootFromEntries.Keys.ToHashSet();
                var toEntries   = rootToEntries.Keys.ToHashSet();

                var commonEntries  = fromEntries.Intersect(toEntries);
                var removedEntries = fromEntries.Except(commonEntries);
                var addedEntries   = toEntries.Except(commonEntries);