Ejemplo n.º 1
0
        public void LicenseHasNoDate()
        {
            var anyHash          = "test";
            var licenseHasNoDate = "test\r\ntest\r\n\r\n";

            byte[] licenseBytes = Encoding.ASCII.GetBytes(licenseHasNoDate);
            Assert.That(() => _licenseChecker.IsLicenseValid(licenseBytes, anyHash), Throws.TypeOf <CanNotReadDateFromLicenseFileException>());
        }
Ejemplo n.º 2
0
        public bool IsLicenseValid(string license)
        {
            string filePath = Path.Combine(ConfigurationManager.AppSettings["OutputDirectory"], ConfigurationManager.AppSettings["RelativeLicenseFilePath"]);
            bool   licenseIsValid;

            try
            {
                licenseIsValid = _licenseChecker.IsLicenseValid(File.ReadAllBytes(filePath), license);
            }
            catch (DirectoryNotFoundException ex)
            {
                var physicalPath = GetPhysicalPathFromExceptionMessage(ex.Message) ?? filePath;
                throw new DirectoryNotFoundException(string.Format(ToolUI.LicenseIsNotFoundAt, physicalPath));
            }
            catch (FileNotFoundException ex)
            {
                var physicalPath = GetPhysicalPathFromExceptionMessage(ex.Message) ?? filePath;
                throw new DirectoryNotFoundException(string.Format(ToolUI.LicenseIsNotFoundAt, physicalPath));
            }

            return(licenseIsValid);
        }