Exemplo n.º 1
0
        public void TestHashEquals(bool expected, string left, string right)
        {
            var leftPath  = Path.Combine(WorkDirecoryPath, "Images", $"{left}.jpg");
            var rightPath = Path.Combine(WorkDirecoryPath, "Images", $"{right}.jpg");

            Assert.True(File.Exists(leftPath));
            Assert.True(File.Exists(rightPath));

            var leftBytes  = File.ReadAllBytes(leftPath);
            var rightBytes = File.ReadAllBytes(rightPath);

            Assert.NotEmpty(leftBytes);
            Assert.NotEmpty(rightBytes);

            var leftHash  = imageHasher.GetHash(leftBytes);
            var rightHash = imageHasher.GetHash(rightBytes);

            Assert.Equal(expected, leftHash.HashEquals(rightHash));
        }
Exemplo n.º 2
0
        public void TestGetHash()
        {
            var inputFilePath = Path.Combine(WorkDirecoryPath, "Images", "test.jpg");

            Assert.True(File.Exists(inputFilePath));

            var bytes = File.ReadAllBytes(inputFilePath);

            Assert.NotEmpty(bytes);

            var hash = imageHasher.GetHash(bytes);

            Assert.NotEmpty(hash);
        }
Exemplo n.º 3
0
        private MessageDbo Convert([NotNull] MessageDto from, [CanBeNull] MessageDbo to = null)
        {
            var result = to ?? new MessageDbo();

            result.StrId = from.StrId;
            result.Text  = from.Text;
            result.ForwardFromChatName  = from.ForwardFromChatName;
            result.EditDate             = from.EditDate;
            result.ForwardFromMessageId = from.ForwardFromMessageId;
            result.ChatId              = from.ChatId;
            result.FromUserId          = from.FromUserId;
            result.ForwardFromUserId   = from.ForwardFromUserId;
            result.CreateDate          = from.CreateDate;
            result.ForwardFromUserName = from.ForwardFromUserName;
            result.ForwardFromChatId   = from.ForwardFromChatId;
            result.FromUserName        = from.FromUserName;
            result.IntId       = from.IntId;
            result.MessageDate = from.MessageDate;
            result.Timestamp   = from.Timestamp;
            result.Hash        = to?.Hash ?? imageHasher.GetHash(from.ImageBytes);
            result.BayanCount  = to?.BayanCount ?? 0;

            return(result);
        }