Exemple #1
0
        /// <summary>
        /// Asserts two file have the same contents (does not check the file
        /// names are the same).
        /// </summary>
        /// <param name="actualFilePath">Path to actual file in the comparison.</param>
        /// <param name="expectedFilePath">Path to expected file in the comparison.</param>
        public static void AreSame(string actualFilePath, string expectedFilePath)
        {
            var service = new FileChecksumService(new Md5Algorithm(), EncodingType.Base64);

            var actualHash   = service.Calculate(actualFilePath);
            var expectedHash = service.Calculate(expectedFilePath);

            Assert.That(actualHash, Is.EqualTo(expectedHash));
        }
Exemple #2
0
 public void WhenEncodingTypeInvalid_ThenThrowException()
 {
     Assert.Throws <InvalidOperationException>(() => _ = new FileChecksumService(new Md5Algorithm(), (EncodingType)99));
 }
Exemple #3
0
 public void WhenHashAlgorithmIsNull_ThenThrowException()
 {
     Assert.Throws <ArgumentNullException>(() => _ = new FileChecksumService(null));
 }
 public void SetUp()
 {
     _sutBase64 = new FileChecksumService(new Md5Algorithm(), EncodingType.Base64);
     _sutHex    = new FileChecksumService(new Md5Algorithm(), EncodingType.Hex);
 }