public void ApplicationUpdateFile_Verify_ThrowsWhenFileSizeDoesNotMatch() { // Arrange using (var artifacts = new ArtifactFolder()) { string path = artifacts.GetRandomFilePath(); File.WriteAllText(path, "FoobarFizzbizz"); var updateFile = new ApplicationUpdateFile { Size = 0 }; // Act Assert.Throws <IOException>(() => updateFile.Verify(path)); } }
public void ApplicationUpdateFile_Verify_ThrowsWhenMD5DoesNotMatch() { // Arrange using (var artifacts = new ArtifactFolder()) { string path = artifacts.GetRandomFilePath(); File.WriteAllText(path, "FoobarFizzbizz"); var fileInfo = new FileInfo(path); var hash = new Hash(HashProvider.SHA1); var sha1 = hash.Calculate(File.OpenRead(path)); var updateFile = new ApplicationUpdateFile { Size = (int)fileInfo.Length, SHA1 = sha1.ToHex(), MD5 = "DoesNotMatch" }; // Act Assert.Throws <IOException>(() => updateFile.Verify(path)); } }