Ejemplo n.º 1
0
        private Response CheckLatestVersion()
        {
            try
            {
                if (!IsAdmin)
                {
                    return(Response.AsJson(new JsonUpdateAvailableModel {
                        UpdateAvailable = false
                    }));
                }

                var checker = new StatusChecker();
                var release = Cache.GetOrSet(CacheKeys.LastestProductVersion, () => checker.GetStatus(), 30);

                return(Response.AsJson(release.UpdateAvailable
                    ? new JsonUpdateAvailableModel {
                    UpdateAvailable = true
                }
                    : new JsonUpdateAvailableModel {
                    UpdateAvailable = false
                }));
            }
            catch (Exception e)
            {
                Log.Warn("Exception Thrown when attempting to check the status");
                Log.Warn(e);
                return(Response.AsJson(new JsonUpdateAvailableModel {
                    UpdateAvailable = false
                }));
            }
        }
        public void CheckStatusTest()
        {
            var checker = new StatusChecker();
            var status  = checker.GetStatus();

            Assert.That(status, Is.Not.Null);
        }
        private Negotiator Status()
        {
            var checker = new StatusChecker();
            var status  = checker.GetStatus();
            var md      = new Markdown();

            status.ReleaseNotes = md.Transform(status.ReleaseNotes);
            return(View["Status", status]);
        }
Ejemplo n.º 4
0
        public void ShouldReturn_ProperStatus(double warning, double critical, string message, MessageType messageType)
        {
            // Arrange
            var fakeAPI       = new FakeDiskAPI();
            var directoryMock = new Mock <IDirectoryWrapper>();

            directoryMock.Setup(dir => dir.Exists(It.IsAny <string>())).Returns(true);
            var checker = new StatusChecker(fakeAPI, directoryMock.Object);
            var opt     = new StatusOptions(@"c:\temp", warning, critical);

            // Act
            var logs = checker.GetStatus(opt);

            // Assert
            Assert.AreEqual(1, logs.Count);
            var log = logs.First();

            Assert.AreEqual(message, log.Message);
            Assert.AreEqual(messageType, log.MessageType);
        }
Ejemplo n.º 5
0
        public void ShouldHandle_Exceptions()
        {
            // Arrange
            var fakeAPI       = new FakeDiskAPI_ThrowsExceptions();
            var directoryMock = new Mock <IDirectoryWrapper>();

            directoryMock.Setup(dir => dir.Exists(It.IsAny <string>())).Returns(true);
            var checker = new StatusChecker(fakeAPI, directoryMock.Object);
            var opt     = new StatusOptions(@"c:\temp", 50, 20);

            // Act
            var logs = checker.GetStatus(opt);

            // Assert
            Assert.AreEqual(1, logs.Count);
            var log = logs.First();

            Assert.AreEqual($"ERROR - Something went wrong!", log.Message);
            Assert.AreEqual(MessageType.Critical, log.MessageType);
        }
Ejemplo n.º 6
0
        public void ShouldHandle_InvalidPath()
        {
            // Arrange
            var fakeAPI       = new FakeDiskAPI();
            var directoryMock = new Mock <IDirectoryWrapper>();

            directoryMock.Setup(dir => dir.Exists(It.IsAny <string>())).Returns(false);
            var checker = new StatusChecker(fakeAPI, directoryMock.Object);
            var opt     = new StatusOptions(@"c:\temp", 50, 20);

            // Act
            var logs = checker.GetStatus(opt);

            // Assert
            Assert.AreEqual(1, logs.Count);
            var log = logs.First();

            Assert.AreEqual($@"ERROR - Verify that you have the correct path: c:\temp", log.Message);
            Assert.AreEqual(MessageType.Critical, log.MessageType);
        }
Ejemplo n.º 7
0
        public void ShouldReturn_ProperStatusWithVerbose()
        {
            // Arrange
            var fakeAPI       = new FakeDiskAPI();
            var directoryMock = new Mock <IDirectoryWrapper>();

            directoryMock.Setup(dir => dir.Exists(It.IsAny <string>())).Returns(true);
            var checker = new StatusChecker(fakeAPI, directoryMock.Object);
            var opt     = new StatusOptions(@"c:\temp", 50, 20, true);

            // Act
            var logs = checker.GetStatus(opt);

            // Assert
            Assert.AreEqual(6, logs.Count);
            Assert.AreEqual(@"Disk at path: c:\temp", logs[2].Message);
            Assert.AreEqual(MessageType.Info, logs[2].MessageType);
            Assert.AreEqual("Total space: 111.79 GB", logs[3].Message);
            Assert.AreEqual(MessageType.Info, logs[3].MessageType);
            Assert.AreEqual("Used space: 67.59 GB", logs[4].Message);
            Assert.AreEqual(MessageType.Info, logs[4].MessageType);
            Assert.AreEqual("Available space: 44.2 GB", logs[5].Message);
            Assert.AreEqual(MessageType.Info, logs[5].MessageType);
        }
Ejemplo n.º 8
0
        private async Task <Negotiator> Status()
        {
            var checker = new StatusChecker();
            var status  = await Cache.GetOrSetAsync(CacheKeys.LastestProductVersion, async() => await checker.GetStatus(), 30);

            var md = new Markdown(new MarkdownOptions {
                AutoNewLines = true, AutoHyperlink = true
            });

            status.ReleaseNotes = md.Transform(status.ReleaseNotes);
            return(View["Status", status]);
        }
Ejemplo n.º 9
0
        private async Task <Response> CheckLatestVersion()
        {
            try
            {
                if (!IsAdmin)
                {
                    return(Response.AsJson(new JsonUpdateAvailableModel {
                        UpdateAvailable = false
                    }));
                }
//#if DEBUG
                //return Response.AsJson(new JsonUpdateAvailableModel {UpdateAvailable = false});
//#endif
                var checker = new StatusChecker(SystemSettings);
                var release = await Cache.GetOrSetAsync(CacheKeys.LastestProductVersion, async() => await checker.GetStatus(), 30);

                return(Response.AsJson(release.UpdateAvailable
                    ? new JsonUpdateAvailableModel {
                    UpdateAvailable = true
                }
                    : new JsonUpdateAvailableModel {
                    UpdateAvailable = false
                }));
            }
            catch (Exception e)
            {
                Log.Warn("Exception Thrown when attempting to check the status");
                Log.Warn(e);
                return(Response.AsJson(new JsonUpdateAvailableModel {
                    UpdateAvailable = false
                }));
            }
        }
Ejemplo n.º 10
0
        private async Task <Negotiator> Status()
        {
            var settings = await SystemSettings.GetSettingsAsync();

            var checker = new StatusChecker(SystemSettings);
            var status  = await Cache.GetOrSetAsync(CacheKeys.LastestProductVersion, async() => await checker.GetStatus(), 30);

            var md = new Markdown(new MarkdownOptions {
                AutoNewLines = true, AutoHyperlink = true
            });

            status.ReleaseNotes = md.Transform(status.ReleaseNotes);

            settings.Status = status;

            settings.BranchDropdown = new List <BranchDropdown>
            {
                new BranchDropdown
                {
                    Name     = EnumHelper <Branches> .GetBranchValue <BranchAttribute>(Branches.Stable).DisplayName,
                    Value    = Branches.Stable,
                    Selected = settings.Branch == Branches.Stable
                },
                new BranchDropdown
                {
                    Name     = EnumHelper <Branches> .GetBranchValue <BranchAttribute>(Branches.EarlyAccessPreview).DisplayName,
                    Value    = Branches.EarlyAccessPreview,
                    Selected = settings.Branch == Branches.EarlyAccessPreview
                },
                new BranchDropdown
                {
                    Name     = EnumHelper <Branches> .GetBranchValue <BranchAttribute>(Branches.Dev).DisplayName,
                    Value    = Branches.Dev,
                    Selected = settings.Branch == Branches.Dev
                },
            };

            return(View["Status", settings]);
        }
Ejemplo n.º 11
0
 public StatusInfo GetStatus(string trackingGuid)
 {
     return(_statusChecker.GetStatus(trackingGuid));
 }