public void ValidationUnitTests() { string url = "http://c.tadst.com/gfx/600w/doomsday-rule.jpg?1"; string destination = "C:/Program Files"; Assert.AreEqual(ValidationTests.IsUrlValid(url), true); Assert.AreEqual(ValidationTests.IsUrlValid("www.google.com"), false); Assert.AreEqual(ValidationTests.IsDestinationValid(destination), true); Assert.AreEqual(ValidationTests.IsDestinationValid("/Program Files"), false); }
internal virtual void AddDownloadToList(Download download) { if (!ValidationTests.IsUrlValid(download.RemoteFileInfo.Url)) { throw new DownloaderUCException(ErrorType.InvalidField, "Url"); } if (string.IsNullOrEmpty(download.Destination.FullPath)) { throw new DownloaderUCException(ErrorType.EmptyField, "Destination"); } if (!ValidationTests.IsDestinationValid(download.Destination.FullPath)) { throw new DownloaderUCException(ErrorType.InvalidField, "Destination"); } if (download.RemoteFileInfo.SizeBytes == -1) { throw new DownloaderUCException(ErrorType.InvalidField, "Url"); } CheckSpaceToAddDownload(download); }