Exemplo n.º 1
0
        static void Main()
        {
            var stopwatch = new Stopwatch();


            byte[] data = { 0, 0, 5, 1, 1, 2 };
            string word = "abc";


            Sha1 hash = new Sha1();

            stopwatch.Start();
            Console.WriteLine("Proper HASH SHA1(data): " + UintArrayToString(hash.Hash(data)));
            stopwatch.Stop();
            Console.WriteLine($"Data hashed in: {stopwatch.Elapsed} s");
            stopwatch.Reset();
            stopwatch.Start();
            Console.WriteLine("Proper HASH SHA1 (word): " + UintArrayToString(hash.Hash(Encoding.ASCII.GetBytes(word))));
            stopwatch.Stop();
            Console.WriteLine($"Data hashed in: {stopwatch.Elapsed} s");
            Console.WriteLine($"Data hashed in: {stopwatch.ElapsedTicks} ticks");
            Console.WriteLine($"Speed of hashing: {Encoding.ASCII.GetBytes(word).Length * 1000000 / stopwatch.Elapsed.Ticks} bps");


            SHA3Managed hash5 = new SHA3Managed(512);

            //stopwatch.Start();
            //Console.WriteLine("Proper HASH SHA3-512(data): " + ToHexString(hash5.ComputeHash(data)));
            //stopwatch.Stop();
            //Console.WriteLine($"Data hashed in: {stopwatch.Elapsed} s");
            stopwatch.Reset();
            stopwatch.Start();
            Console.WriteLine("Proper HASH SHA3-512 (word): " + ByteArrayToString(hash5.ComputeHash(Encoding.UTF8.GetBytes(word))));
            stopwatch.Stop();
            Console.WriteLine($"Data hashed in: {stopwatch.Elapsed} s");
            Console.WriteLine($"Data hashed in: {stopwatch.ElapsedTicks} ticks");
            Console.WriteLine("Speed of hashing: {0:f2} bps", (double)(Encoding.ASCII.GetBytes(word).Length / 1024) * 1000L * 1000L * 10L / (stopwatch.ElapsedTicks));

            SHA2Managed hash6 = new SHA2Managed(512);

            stopwatch.Reset();
            Console.WriteLine("Proper HASH SHA-512(word): " + ByteArrayToString(hash6.ComputeHash(Encoding.UTF8.GetBytes(word))));

            SHA2Managed hash7 = new SHA2Managed(224);

            stopwatch.Reset();
            Console.WriteLine("Proper HASH SHA-224(word): " + ByteArrayToString(hash7.ComputeHash(Encoding.UTF8.GetBytes(word))));

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new HashFunctionAnalizerForm());
        }
Exemplo n.º 2
0
        public static void TreeId_equality()
        {
            var treeId1 = new TreeId(Sha1.Hash("abc"));
            var treeId2 = new TreeId(Sha1.Hash("abc"));
            var treeId3 = new TreeId(Sha1.Hash("def"));

            Assert.True(treeId1 == treeId2);
            Assert.False(treeId1 != treeId2);
            Assert.True(treeId1.Equals((object)treeId2));

            Assert.Equal(treeId1.Sha1.ToString(), treeId1.ToString());
            Assert.Equal(treeId2.Sha1.ToString(), treeId2.ToString());
            Assert.Equal(treeId3.Sha1.ToString(), treeId3.ToString());

            Assert.Equal(treeId1, treeId2);
            Assert.Equal(treeId1.GetHashCode(), treeId2.GetHashCode());
            Assert.Equal(treeId1.ToString(), treeId2.ToString());

            Assert.NotEqual(TreeId.Empty, treeId1);
            Assert.NotEqual(TreeId.Empty.GetHashCode(), treeId1.GetHashCode());
            Assert.NotEqual(TreeId.Empty.ToString(), treeId1.ToString());

            Assert.NotEqual(treeId3, treeId1);
            Assert.NotEqual(treeId3.GetHashCode(), treeId1.GetHashCode());
            Assert.NotEqual(treeId3.ToString(), treeId1.ToString());
        }
Exemplo n.º 3
0
        public static void BlobId_equality()
        {
            var blobId1 = new BlobId(Sha1.Hash("abc"));
            var blobId2 = new BlobId(Sha1.Hash("abc"));
            var blobId3 = new BlobId(Sha1.Hash("def"));

            Assert.True(blobId1 == blobId2);
            Assert.False(blobId1 != blobId2);
            Assert.True(blobId1.Equals((object)blobId2));
            Assert.False(blobId1.Equals(new object()));

            Assert.Equal(blobId1.Sha1.ToString(), blobId1.ToString());
            Assert.Equal(blobId2.Sha1.ToString(), blobId2.ToString());
            Assert.Equal(blobId3.Sha1.ToString(), blobId3.ToString());

            Assert.Equal(blobId1, blobId2);
            Assert.Equal(blobId1.GetHashCode(), blobId2.GetHashCode());
            Assert.Equal(blobId1.ToString(), blobId2.ToString());

            Assert.NotEqual(BlobId.Empty, blobId1);
            Assert.NotEqual(BlobId.Empty.GetHashCode(), blobId1.GetHashCode());
            Assert.NotEqual(BlobId.Empty.ToString(), blobId1.ToString());

            Assert.NotEqual(blobId3, blobId1);
            Assert.NotEqual(blobId3.GetHashCode(), blobId1.GetHashCode());
            Assert.NotEqual(blobId3.ToString(), blobId1.ToString());
        }
Exemplo n.º 4
0
        public static void CommitId_equality()
        {
            var commitId1 = new CommitId(Sha1.Hash("abc"));
            var commitId2 = new CommitId(Sha1.Hash("abc"));
            var commitId3 = new CommitId(Sha1.Hash("def"));

            Assert.True(commitId1 == commitId2);
            Assert.False(commitId1 != commitId2);
            Assert.True(commitId1.Equals((object)commitId2));

            Assert.Equal(commitId1.Sha1.ToString(), commitId1.ToString());
            Assert.Equal(commitId2.Sha1.ToString(), commitId2.ToString());
            Assert.Equal(commitId3.Sha1.ToString(), commitId3.ToString());

            Assert.Equal(commitId1, commitId2);
            Assert.Equal(commitId1.GetHashCode(), commitId2.GetHashCode());
            Assert.Equal(commitId1.ToString(), commitId2.ToString());

            Assert.NotEqual(CommitId.Empty, commitId1);
            Assert.NotEqual(CommitId.Empty.GetHashCode(), commitId1.GetHashCode());
            Assert.NotEqual(CommitId.Empty.ToString(), commitId1.ToString());

            Assert.NotEqual(commitId3, commitId1);
            Assert.NotEqual(commitId3.GetHashCode(), commitId1.GetHashCode());
            Assert.NotEqual(commitId3.ToString(), commitId1.ToString());
        }
Exemplo n.º 5
0
        public static void ChasmSerializer_Roundtrip_CommitId(IChasmSerializer ser)
        {
            var expected = new CommitId(Sha1.Hash("abc"));

            using (var buf = ser.Serialize(expected))
            {
                var actual = ser.DeserializeCommitId(buf.Result);
                Assert.Equal(expected, actual);
            }
        }
Exemplo n.º 6
0
        public static string GetHashSha1(string inputString)
        {
            var sb        = new StringBuilder();
            var alghoritm = new Sha1();

            foreach (var b in alghoritm.Hash(Encoding.UTF8.GetBytes(inputString)))
            {
                sb.Append(b.ToString("X2"));
            }
            return(sb.ToString());
        }
Exemplo n.º 7
0
        public static void ChasmSerializer_WriteRead_TreeNodeList(IChasmSerializer ser)
        {
            var node0    = new TreeNode("a", NodeKind.Blob, Sha1.Hash("abc"));
            var node1    = new TreeNode("b", NodeKind.Tree, Sha1.Hash("def"));
            var node2    = new TreeNode("c", NodeKind.Tree, Sha1.Hash("hij"));
            var expected = new TreeNodeList(node0, node1, node2);

            using (var seg = ser.Serialize(expected))
            {
                var actual = ser.DeserializeTree(seg.Result);

                Assert.Equal(expected, actual);
            }
        }
Exemplo n.º 8
0
        public static void TreeId_Compare()
        {
            var comparer = TreeIdComparer.Default;

            var treeId1 = new TreeId(Sha1.Hash("abc"));
            var treeId2 = new TreeId(Sha1.Hash("abc"));
            var treeId3 = new TreeId(Sha1.Hash("def"));
            var list    = new[] { treeId1, treeId2, treeId3 };

            Assert.True(treeId1.CompareTo(treeId2) == 0);
            Assert.True(treeId1.CompareTo(treeId3) != 0);

            Array.Sort(list, comparer.Compare);

            Assert.True(list[0] <= list[1]);
            Assert.True(list[2] >= list[1]);
        }
Exemplo n.º 9
0
        public static void BlobId_Compare()
        {
            var comparer = BlobIdComparer.Default;

            var blobId1 = new BlobId(Sha1.Hash("abc"));
            var blobId2 = new BlobId(Sha1.Hash("abc"));
            var blobId3 = new BlobId(Sha1.Hash("def"));
            var list    = new[] { blobId1, blobId2, blobId3 };

            Assert.True(blobId1.CompareTo(blobId2) == 0);
            Assert.True(blobId1.CompareTo(blobId3) != 0);

            Array.Sort(list, comparer.Compare);

            Assert.True(list[0] <= list[1]);
            Assert.True(list[2] >= list[1]);
        }
Exemplo n.º 10
0
        public static void CommitId_Compare()
        {
            var comparer = CommitIdComparer.Default;

            var commitId1 = new CommitId(Sha1.Hash("abc"));
            var commitId2 = new CommitId(Sha1.Hash("abc"));
            var commitId3 = new CommitId(Sha1.Hash("def"));
            var list      = new[] { commitId1, commitId2, commitId3 };

            Assert.True(CommitId.Empty < commitId1);
            Assert.True(commitId1 > CommitId.Empty);

            Assert.True(commitId1.CompareTo(commitId2) == 0);
            Assert.True(commitId1.CompareTo(commitId3) != 0);

            Array.Sort(list, comparer.Compare);

            Assert.True(list[0] <= list[1]);
            Assert.True(list[2] >= list[1]);
        }
Exemplo n.º 11
0
        public static void CommitRef_equality()
        {
            var commitRef1 = new CommitRef("abc", new CommitId(Sha1.Hash("abc")));
            var commitRef2 = new CommitRef("abc", new CommitId(Sha1.Hash("abc")));
            var commitRef3 = new CommitRef("def", new CommitId(Sha1.Hash("def")));

            Assert.True(commitRef1 == commitRef2);
            Assert.False(commitRef1 != commitRef2);
            Assert.True(commitRef1.Equals((object)commitRef2));

            Assert.Equal(commitRef1, commitRef2);
            Assert.Equal(commitRef1.GetHashCode(), commitRef2.GetHashCode());
            Assert.Equal(commitRef1.ToString(), commitRef2.ToString());

            Assert.NotEqual(CommitRef.Empty, commitRef1);
            Assert.NotEqual(CommitRef.Empty.GetHashCode(), commitRef1.GetHashCode());

            Assert.NotEqual(commitRef3, commitRef1);
            Assert.NotEqual(commitRef3.GetHashCode(), commitRef1.GetHashCode());
            Assert.NotEqual(commitRef3.ToString(), commitRef1.ToString());
        }
Exemplo n.º 12
0
        private double speedTestOfHashFunctions(string hashName)
        {
            var someData = new byte[1000000];


            //randomize data
            for (int i = 0; i < someData.Length; i++)
            {
                someData[i] = Convert.ToByte(randomizeValue());
            }

            var    times     = 100;
            var    stopWatch = new Stopwatch();
            double result;
            int    collumnCounter;


            for (int i = 0; i < times; i++)
            {
                if (i % 5 == 0)
                {
                    dataGridView1.Columns.Add($"{i} Mb", $"{i} Mb");
                }
            }


            switch (hashName)
            {
            case "SHA1":
                var alghorithmSha1 = new Sha1();
                dataGridView1.Rows.Add();
                collumnCounter = 2;
                stopWatch.Reset();
                stopWatch.Start();
                for (int i = 0; i < times; i++)
                {
                    alghorithmSha1.Hash(someData);

                    if (i % 5 == 0)
                    {
                        double secondsy = (double)stopWatch.ElapsedMilliseconds / 1000;
                        result = (double)(i / secondsy);
                        dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex + (dataGridView1.RowCount - 1)].Cells[collumnCounter++].Value = $"{result:f2}";
                    }
                }
                stopWatch.Stop();
                break;

            case "SHA224":
                var alghorithmSha224 = new SHA2Managed(224);
                stopWatch.Reset();
                stopWatch.Start();
                for (int i = 0; i < times; i++)
                {
                    alghorithmSha224.ComputeHash(someData);
                }
                stopWatch.Stop();
                break;

            case "SHA256":
                var alghorithmSha256 = new SHA2Managed(256);
                stopWatch.Reset();
                stopWatch.Start();
                for (int i = 0; i < times; i++)
                {
                    alghorithmSha256.ComputeHash(someData);
                }
                stopWatch.Stop();
                break;

            case "SHA384":
                var alghorithmSha384 = new SHA2Managed(384);
                stopWatch.Reset();
                stopWatch.Start();
                for (int i = 0; i < times; i++)
                {
                    alghorithmSha384.ComputeHash(someData);
                }
                stopWatch.Stop();
                break;

            case "SHA512":
                var alghorithmSha512 = new SHA2Managed(512);
                dataGridView1.Rows.Add();
                collumnCounter = 2;
                stopWatch.Reset();
                stopWatch.Start();
                for (int i = 0; i < times; i++)
                {
                    alghorithmSha512.ComputeHash(someData);

                    if (i % 5 == 0)
                    {
                        double secondsy = (double)stopWatch.ElapsedMilliseconds / 1000;
                        result = (double)(i / secondsy);
                        dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex + (dataGridView1.RowCount - 1)].Cells[collumnCounter++].Value = $"{result:f2}";
                    }
                }
                stopWatch.Stop();
                break;

            case "SHA3-512":
                var alghorithmSha3_512 = new SHA3Managed();
                dataGridView1.Rows.Add();
                collumnCounter = 2;
                stopWatch.Reset();
                stopWatch.Start();
                for (int i = 0; i < times; i++)
                {
                    alghorithmSha3_512.ComputeHash(someData);

                    if (i % 5 == 0)
                    {
                        double secondsy = (double)stopWatch.ElapsedMilliseconds / 1000;
                        result = (double)(i / secondsy);
                        dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex + (dataGridView1.RowCount - 1)].Cells[collumnCounter++].Value = $"{result:f2}";
                    }
                }
                stopWatch.Stop();
                break;

            default:

                break;
            }


            double seconds = (double)stopWatch.ElapsedMilliseconds / 1000;

            Console.WriteLine("HASH {0} with speed: {1} Mb data in {2:f2}", hashName, times, seconds);

            result = (double)(times / seconds);

            return(result);
        }
Exemplo n.º 13
0
        private void generateFileHashBtn_Click(object sender, EventArgs e)
        {
            var stopwatch       = new Stopwatch();
            var stopwatchSHA224 = new Stopwatch();
            var stopwatchSHA256 = new Stopwatch();
            var stopwatchSHA384 = new Stopwatch();
            var stopwatchSHA512 = new Stopwatch();


            Stream fileStream     = null;
            var    openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = "\\";
            openFileDialog.Filter           = @"All files (*.*)|*.*";
            openFileDialog.FilterIndex      = 2;
            openFileDialog.RestoreDirectory = true;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if (!((fileStream = openFileDialog.OpenFile()) == null))
                    {
                        using (fileStream)
                        {
                            var imageData = new byte[fileStream.Length];

                            fileStream.Read(imageData, 0, Convert.ToInt32(fileStream.Length));
                            var fs = fileStream as FileStream;


                            var hashSha1   = new Sha1();
                            var hashSha224 = new SHA2Managed(224);
                            var hashSha256 = new SHA2Managed(256);
                            var hashSha384 = new SHA2Managed(384);
                            var hashSha512 = new SHA2Managed(512);
                            var hashSha3   = new SHA3Managed();

                            stopwatch.Start();
                            Console.WriteLine("FILE HASH SHA1: " +
                                              UintArrayToString(hashSha1.Hash(FileToByteArray(fs.Name))));
                            stopwatch.Stop();
                            Console.WriteLine($"Data hashed in: {stopwatch.Elapsed} s");

                            stopwatchSHA224.Start();
                            Console.WriteLine("FILE HASH SHA224: " +
                                              ByteArrayToString(hashSha224.ComputeHash(FileToByteArray(fs.Name))));
                            stopwatchSHA224.Stop();
                            Console.WriteLine($"Data hashed in: {stopwatchSHA224.Elapsed} s");

                            stopwatchSHA256.Start();
                            Console.WriteLine("FILE HASH SHA256: " +
                                              ByteArrayToString(hashSha256.ComputeHash(FileToByteArray(fs.Name))));
                            stopwatchSHA256.Stop();
                            Console.WriteLine($"Data hashed in: {stopwatchSHA256.Elapsed} s");

                            stopwatchSHA384.Start();
                            Console.WriteLine("FILE HASH SHA384: " +
                                              ByteArrayToString(hashSha384.ComputeHash(FileToByteArray(fs.Name))));
                            stopwatchSHA384.Stop();
                            Console.WriteLine($"Data hashed in: {stopwatchSHA384.Elapsed} s");


                            stopwatchSHA512.Start();
                            Console.WriteLine("FILE HASH SHA512: " +
                                              ByteArrayToString(hashSha512.ComputeHash(FileToByteArray(fs.Name))));
                            stopwatchSHA512.Stop();
                            Console.WriteLine($"Data hashed in: {stopwatchSHA512.Elapsed} s");


                            stopwatchSHA512.Reset();
                            stopwatchSHA512.Start();
                            Console.WriteLine("FILE HASH SHA3-512: " +
                                              ByteArrayToString(hashSha3.ComputeHash(FileToByteArray(fs.Name))));
                            stopwatchSHA512.Stop();
                            Console.WriteLine($"Data hashed in: {stopwatchSHA512.Elapsed} s");

                            //Write length of file
                            Console.WriteLine($"File Length: {fileStream.Length}");

                            //Close the File Stream
                            fileStream.Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }
Exemplo n.º 14
0
        private static async Task TestRepository(IChasmRepository repository)
        {
            var g = Guid.NewGuid();

            var data = g.ToByteArray();
            var sha  = Sha1.Hash(data);

            // Unknown SHA
            var usha  = Sha1.Hash(Guid.NewGuid().ToByteArray());
            var usha2 = Sha1.Hash(Guid.NewGuid().ToByteArray());

            // Blob
            await repository.WriteObjectAsync(sha, new ArraySegment <byte>(data), false, default);

            var rdata = (await repository.ReadObjectAsync(sha, default));

            Assert.True(rdata.HasValue);
            Assert.Equal(16, rdata.Value.Length);
            Assert.Equal(g, rdata.Value.Span.NonPortableCast <byte, Guid>()[0]);

            var urdata = await repository.ReadObjectAsync(usha, default);

            Assert.False(urdata.HasValue);

            // Tree
            var tree = new TreeNodeMap(
                new TreeNode("firstItem", NodeKind.Blob, sha),
                new TreeNode("secondItem", NodeKind.Blob, sha)
                );
            var treeId = await repository.WriteTreeAsync(tree, default);

            var rtree = await repository.ReadTreeAsync(treeId, default);

            Assert.True(rtree.HasValue);
            Assert.Equal(tree, rtree.Value);

            var urtree = await repository.ReadTreeAsync(new TreeId(usha), default);

            Assert.False(urtree.HasValue);

            // Commit
            var commit = new Commit(
                new CommitId?(),
                treeId,
                new Audit("User1", DateTimeOffset.UtcNow.AddDays(-1)),
                new Audit("User2", DateTimeOffset.UtcNow),
                "Initial commit"
                );
            var commitId = await repository.WriteCommitAsync(commit, default);

            var rcommit = await repository.ReadCommitAsync(commitId, default);

            Assert.True(rcommit.HasValue);
            Assert.Equal(commit, rcommit);

            var urcommit = await repository.ReadCommitAsync(new CommitId(usha), default);

            Assert.False(urcommit.HasValue);

            // CommitRef
            var commitRefName = Guid.NewGuid().ToString("N");
            var commitRef     = new CommitRef("production", commitId);
            await repository.WriteCommitRefAsync(null, commitRefName, commitRef, default);

            var rcommitRef = await repository.ReadCommitRefAsync(commitRefName, commitRef.Branch, default);

            Assert.True(rcommit.HasValue);
            Assert.Equal(commitRef, rcommitRef);

            var urcommitRef = await repository.ReadCommitRefAsync(commitRefName + "_", commitRef.Branch, default);

            Assert.False(urcommit.HasValue);

            await Assert.ThrowsAsync <ChasmConcurrencyException>(() =>
                                                                 repository.WriteCommitRefAsync(null, commitRefName, new CommitRef("production", new CommitId(usha)), default));

            await Assert.ThrowsAsync <ChasmConcurrencyException>(() =>
                                                                 repository.WriteCommitRefAsync(new CommitId(usha2), commitRefName, new CommitRef("production", new CommitId(usha)), default));

            await repository.WriteCommitRefAsync(null, commitRefName, new CommitRef("dev", commitId), default);

            await repository.WriteCommitRefAsync(null, commitRefName, new CommitRef("staging", new CommitId(usha)), default);

            await repository.WriteCommitRefAsync(null, commitRefName + "_1", new CommitRef("production", new CommitId(usha)), default);

            var names = await repository.GetNamesAsync(default);
Exemplo n.º 15
0
        internal async void UpdateSummonerInformation()
        {
            if (Client.IsLoggedIn)
            {
                AllSummonerData playerData =
                    await RiotCalls.GetAllSummonerDataByAccount(Client.LoginPacket.AllSummonerData.Summoner.AcctId);

                SummonerNameLabel.Content = playerData.Summoner.Name;


                SummonerActiveBoostsDTO activeBoost = await RiotCalls.GetSummonerActiveBoosts();

                string xpBoostTime = ConvertBoostTime(activeBoost.XpBoostEndDate);
                if (xpBoostTime != string.Empty && activeBoost.XpBoostEndDate > 0)
                {
                    XPBoost.Content = "XP Boost " + ConvertBoostTime(activeBoost.XpBoostEndDate) + ". " + activeBoost.XpBoostPerWinCount + " Win.";
                }
                else if (xpBoostTime != string.Empty)
                {
                    XPBoost.Content = "XP Boost " + ConvertBoostTime(activeBoost.XpBoostEndDate) + ".";
                }
                else if (activeBoost.XpBoostPerWinCount > 0)
                {
                    XPBoost.Content = "XP Boost " + activeBoost.XpBoostPerWinCount + ".";
                }
                else
                {
                    XPBoost.Visibility = Visibility.Hidden;
                }

                string ipBoostTime = ConvertBoostTime(activeBoost.IpBoostEndDate);
                if (ipBoostTime != string.Empty && activeBoost.IpBoostEndDate > 0)
                {
                    IPBoost.Content = "IP Boost " + ipBoostTime + ". " + activeBoost.IpBoostPerWinCount + " Win.";
                }
                else if (ipBoostTime != string.Empty)
                {
                    IPBoost.Content = "IP Boost " + ipBoostTime + ".";
                }
                else if (activeBoost.IpBoostPerWinCount > 0)
                {
                    IPBoost.Content = "IP Boost " + activeBoost.IpBoostPerWinCount + ".";
                }
                else
                {
                    IPBoost.Visibility = Visibility.Hidden;
                }

                Sha1 sha1 = new Sha1();
                if (!CheckedDev)
                {
                    if (DevUsers.getDevelopers().Contains(sha1.Hash(playerData.Summoner.Name + " " + Client.Region.RegionName)))
                    {
                        Client.Dev = true;
                    }
                    CheckedDev = true;
                }

                if (Client.Dev)
                {
                    Client.UserTitleBarLabel.Content = "Dev ∙ " + playerData.Summoner.Name;
                }
                else
                {
                    Client.UserTitleBarLabel.Content = playerData.Summoner.Name;
                }

                if (Client.LoginPacket.AllSummonerData.SummonerLevel.Level < 30)
                {
                    PlayerProgressBar.Value = (playerData.SummonerLevelAndPoints.ExpPoints /
                                               playerData.SummonerLevel.ExpToNextLevel) * 100;
                    PlayerProgressLabel.Content        = string.Format("Level {0}", playerData.SummonerLevel.Level);
                    PlayerCurrentProgressLabel.Content = string.Format("{0}XP", playerData.SummonerLevelAndPoints.ExpPoints);
                    PlayerAimProgressLabel.Content     = string.Format("{0}XP", playerData.SummonerLevel.ExpToNextLevel);
                    Client.UserTitleBarLabel.Content   = Client.UserTitleBarLabel.Content + string.Format(" ∙ Level: {0}", playerData.SummonerLevel.Level);
                }
                else
                {
                    GotLeaguesForPlayer(await RiotCalls.GetAllLeaguesForPlayer(playerData.Summoner.SumId));
                }

                if (Client.LoginPacket.BroadcastNotification.broadcastMessages != null)
                {
                    var message = Client.LoginPacket.BroadcastNotification.broadcastMessages[0];
                    if (message != null)
                    {
                        //BroadcastMessage.Text = message.Content;
                    }
                }

                foreach (PlayerStatSummary x in Client.LoginPacket.PlayerStatSummaries.PlayerStatSummarySet)
                {
                    if (x.PlayerStatSummaryTypeString == "Unranked")
                    {
                        Client.IsRanked     = false;
                        Client.AmountOfWins = x.Wins;
                    }
                    if (x.PlayerStatSummaryTypeString != "RankedSolo5x5")
                    {
                        continue;
                    }

                    if (x.Rating != 0)
                    {
                        Client.IsRanked     = true;
                        Client.AmountOfWins = x.Wins;
                    }
                    break;
                }

                Client.InfoLabel.Content = "IP: " + Client.LoginPacket.IpBalance + " ∙ RP: " + Client.LoginPacket.RpBalance;
                int profileIconId = Client.LoginPacket.AllSummonerData.Summoner.ProfileIconId;
                var UriSource     =
                    new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", profileIconId + ".png"),
                                   UriKind.RelativeOrAbsolute);
                try
                {
                    ProfileImage.Source             = new BitmapImage(UriSource);
                    Client.UserTitleBarImage.Source = new BitmapImage(UriSource);
                }
                catch
                {
                    Client.Log("Can't load profile image.", "ERROR");
                }
                Client.MainPageProfileImage = ProfileImage;
            }
        }
Exemplo n.º 16
0
        public static void Repo_ReadCommitRef() //byte[] x, byte[] y, bool isEqual)
        {
            var repo = new Mock <IChasmRepository>();

            repo.Setup(r => r.Serializer).Returns(new JsonChasmSerializer());
            repo.Setup(r => r.CompressionLevel).Returns(System.IO.Compression.CompressionLevel.NoCompression);
            repo.Setup(r => r.MaxDop).Returns(-1);

            repo.Setup(r => r.ReadCommitRefAsync(null, null, CancellationToken.None)).Returns(new ValueTask <CommitRef?>(CommitRef.Empty));
            repo.Setup(r => r.ReadCommitRefAsync(string.Empty, null, CancellationToken.None)).Returns(new ValueTask <CommitRef?>(CommitRef.Empty));
            repo.Setup(r => r.ReadCommitRefAsync(null, string.Empty, CancellationToken.None)).Returns(new ValueTask <CommitRef?>(CommitRef.Empty));
            repo.Setup(r => r.ReadCommitRefAsync(string.Empty, string.Empty, CancellationToken.None)).Returns(new ValueTask <CommitRef?>(CommitRef.Empty));

            repo.Setup(r => r.ReadCommitRefAsync("branch", "name", CancellationToken.None)).Returns(new ValueTask <CommitRef?>(new CommitRef("branch-name", new CommitId(Sha1.Hash("branch-name")))));
        }