Example #1
0
        public virtual bool Exists(string hash)
        {
            if (String.IsNullOrEmpty(hash))
            {
                throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, CommonResources.Argument_Cannot_Be_Null_Or_Empty, "hash"), "hash");
            }

            return(Index.EntryExists(BitUtils.FromHexString(hash)));
        }
Example #2
0
 public void ThrowsOnNullOrEmptyInput()
 {
     Assert.Throws <ArgumentException>(() => BitUtils.FromHexString(null))
     .WithParamName("value")
     .WithMessage(String.Format(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "value"));
     Assert.Throws <ArgumentException>(() => BitUtils.FromHexString(String.Empty))
     .WithParamName("value")
     .WithMessage(String.Format(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "value"));
 }
Example #3
0
            public void CorrectlyConvertsHexString()
            {
                // Arrange
                byte[] expected = new byte[] {
                    0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0xAB, 0xCD, 0xEF
                };

                // Act
                byte[] actual = BitUtils.FromHexString("0123456789abcdefABCDEF");

                // Assert
                Assert.Equal(expected, actual);
            }
Example #4
0
        public virtual DatabaseObject GetObject(string hash)
        {
            // Look up the object in the index
            byte[]            hashData = BitUtils.FromHexString(hash);
            GitPackIndexEntry entry    = Index.GetEntry(hashData);

            if (entry == null)
            {
                return(null);
            }

            // Open the pack file and read the object out
            Stream packFile = FileSystem.Open(PackFileName, FileAccess.Read, create: false);

            return(GetObjectCore(entry.Offset, packFile, recursing: false));
        }
Example #5
0
 public void ThrowsOnInvalidCharacter()
 {
     Assert.Throws <FormatException>(() => BitUtils.FromHexString("zzzz"))
     .WithMessage(String.Format(CoreResources.Input_Not_Valid_Hex_String, "zzzz"));
 }