public async Task <ApplicationVersionResult> GetLatestApplicationVersion(Version currentVersion) { _logger.LogInfo("Retrieving Application versions from SLD API."); var result = new ApplicationVersionResult(); try { var applicationVersions = await _versionClient.GetAsync(); var newerVersion = GetNewerApplicationVersion(currentVersion, applicationVersions.Versions); _logger.LogInfo("Finished retrieving Application versions from SLD API."); result = newerVersion == null ? null : _applicationVersionResultFactory.GetResult( newerVersion.VersionName, newerVersion.ReleaseDateTime, applicationVersions.Url, newerVersion.ReferenceDataVersion?.VersionName, newerVersion.ReferenceDataVersion?.FileName); } catch (Exception e) { _logger.LogError("Error retrieving Application versions from SLD API.", e); } return(result); }
public VersionMessage GetVersionMessage(ApplicationVersionResult applicationVersionResult) { return(new VersionMessage { ApplicationVersion = applicationVersionResult }); }
public async Task CheckForUpdateMenuCommand_New_Version_Available() { const string version = "2.0.0.0"; const string url = "foo"; var releaseDate = new DateTime(2020, 11, 10, 8, 0, 0); var applicationVersionResult = new ApplicationVersionResult { ApplicationVersion = version, ReleaseDateTime = releaseDate, Url = url }; var versionMediatorServiceMock = new Mock <IVersionMediatorService>(); versionMediatorServiceMock .Setup(m => m.GetNewVersion()) .ReturnsAsync(applicationVersionResult); var featureSwitchService = new Mock <IFeatureSwitchService>(); featureSwitchService.Setup(m => m.VersionUpdate).Returns(true); var versionInformationServiceMock = new Mock <IReleaseVersionInformationService>(); versionInformationServiceMock.Setup(vm => vm.VersionNumber).Returns("3.0"); var refDataVersionInformationServiceMock = new Mock <IReferenceDataVersionInformationService>(); refDataVersionInformationServiceMock.Setup(vm => vm.VersionNumber).Returns("1.0"); var viewModel = NewViewModel( versionMediatorService: versionMediatorServiceMock.Object, featureSwitchService: featureSwitchService.Object, versionInformationService: versionInformationServiceMock.Object, referenceDataVersionInformationService: refDataVersionInformationServiceMock.Object); await viewModel.CheckForUpdateMenuCommand.ExecuteAsync(); viewModel.NewVersion.ApplicationVersion.Should().Be(version); viewModel.NewVersion.ReleaseDateTime.Should().Be(releaseDate); viewModel.NewVersion.Url.Should().Be(url); viewModel.CurrentBannerVisibility.Should().Be(ApiBannerKeys.NewApplication); }
public void VersionMessageFactory_GetVersionMessage() { var url = "test"; var versionNumber = "1.0.0.0"; var date = new DateTime(2020, 11, 10, 8, 0, 0); var applicationVersionResult = new ApplicationVersionResult { ApplicationVersion = versionNumber, Url = url, ReleaseDateTime = date }; var factory = new VersionMessageFactory(); var result = factory.GetVersionMessage(applicationVersionResult); result.ApplicationVersion.ApplicationVersion.Should().Be(versionNumber); result.ApplicationVersion.ReleaseDateTime.Should().Be(date); result.ApplicationVersion.Url.Should().Be(url); }
public async Task CheckForUpdates_Returns_Fasle_And_Does_Not_Send_Message() { var url = "test"; var versionNumber = "1.0.0.0"; var releaseDate = new DateTime(2020, 11, 10, 8, 0, 0); var versionSplit = versionNumber.Split('.'); var major = Convert.ToInt32(versionSplit[0]); var minor = Convert.ToInt32(versionSplit[1]); var increment = Convert.ToInt32(versionSplit[2]); var version = new Version { VersionName = versionNumber, Major = major, Minor = minor, Increment = increment }; var applicationVersionResult = new ApplicationVersionResult { ApplicationVersion = versionNumber, Url = url, ReleaseDateTime = releaseDate }; var versionMessage = new VersionMessage { ApplicationVersion = applicationVersionResult }; var versionMessageFactoryMock = new Mock <IVersionMessageFactory>(); versionMessageFactoryMock .Setup(m => m.GetVersionMessage(applicationVersionResult)) .Returns(versionMessage); var versionFactoryMock = new Mock <IVersionFactory>(); versionFactoryMock .Setup(m => m.GetVersion(versionNumber, It.IsAny <string>())) .Returns(version); var versionInformationService = new Mock <IReleaseVersionInformationService>(); versionInformationService .Setup(m => m.VersionNumber) .Returns(versionNumber); var versionService = new Mock <IVersionService>(); versionService .Setup(m => m.GetLatestApplicationVersion(version)) .ReturnsAsync(default(ApplicationVersionResult)); var service = GetVersionMediatorService( versionFactoryMock.Object, versionInformationService.Object, versionService.Object); var found = service.GetCurrentApplicationVersion(); found.VersionName.Should().Be(version.VersionName); found.ReleaseDateTime.Should().Be(version.ReleaseDateTime); found.Major.Should().Be(version.Major); found.Minor.Should().Be(version.Minor); found.Increment.Should().Be(version.Increment); }
public async Task GetLatestApplicationVersion_Correctly_Returns_Null_When_No_Newer_Version( int currentMajor, int currentMinor, int currentIncrement) { var versionNumber = "1.1.1.1"; var releaseDateTime = new DateTime(2020, 11, 19, 8, 0, 0); var url = "foo.com"; var major = 1; var minor = 1; var increment = 1; var refDataVersionNumber = "1.1.1.1"; var refDataFileName = "FISReferenceData.1.1.1.1"; var currentVersion = new Version { VersionName = "1.0.0.0", ReleaseDateTime = releaseDateTime, Major = currentMajor, Minor = currentMinor, Increment = currentIncrement, ReferenceDataVersion = new Models.ReferenceData { FileName = "FISReferenceData.1.1.1.1", Major = currentMajor, Minor = currentMinor, Increment = currentIncrement, VersionName = refDataVersionNumber } }; var applicationVersion = GetApplicationVersion( versionNumber, url, releaseDateTime, releaseDateTime, major, minor, increment, refDataVersionNumber); var applicationVersionResult = new ApplicationVersionResult { ApplicationVersion = versionNumber, Url = url, ReleaseDateTime = releaseDateTime, LatestReferenceDataVersion = refDataVersionNumber, LatestReferenceDataFileName = refDataFileName }; var versionClientMock = new Mock <IApplicationVersionResultClient>(); versionClientMock .Setup(m => m.GetAsync()) .ReturnsAsync(applicationVersion); var versionResultFactory = new Mock <IAPIResultFactory <ApplicationVersionResult> >(); versionResultFactory .Setup(m => m.GetResult(versionNumber, releaseDateTime, url, refDataVersionNumber, refDataFileName)) .Returns(applicationVersionResult); var service = NewService(versionClientMock.Object, versionResultFactory.Object); var result = await service.GetLatestApplicationVersion(currentVersion); result.Should().BeNull(); }