PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/src/BurnSystems/tests/BurnSystems.UnitTests/Collections/AutoDictionaryTests.cs

https://bitbucket.org/mbrenn/entityconnector
C# | 67 lines | 48 code | 7 blank | 12 comment | 0 complexity | 7006f03419d27f35a8d8ea428f13ecf9 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using BurnSystems.Collections;
  6. using NUnit.Framework;
  7. namespace BurnSystems.UnitTests.Collections
  8. {
  9. /// <summary>
  10. /// Implements some tests for the autodictionary
  11. /// </summary>
  12. [TestFixture]
  13. public class AutoDictionaryTests
  14. {
  15. [Test]
  16. public void TestAutoInsert()
  17. {
  18. var dictionary = new AutoDictionary<Item>();
  19. var itemA_1 = new Item("A", "1");
  20. var itemB_2 = new Item("B", "2");
  21. var itemB_3 = new Item("B", "3");
  22. var itemC_2 = new Item("C", "2");
  23. dictionary.Add(itemA_1);
  24. dictionary.Add(itemB_2);
  25. dictionary.Add(itemB_3);
  26. dictionary.Add(itemC_2);
  27. Assert.That(dictionary.Count, Is.EqualTo(3));
  28. Assert.That(dictionary["A"].Value, Is.EqualTo("1"));
  29. Assert.That(dictionary["B"].Value, Is.EqualTo("3"));
  30. Assert.That(dictionary["C"].Value, Is.EqualTo("2"));
  31. }
  32. /// <summary>
  33. /// Defines the item which is used to test the autodictionary
  34. /// </summary>
  35. public class Item : IHasKey
  36. {
  37. public Item(string key, string value)
  38. {
  39. this.Key = key;
  40. this.Value = value;
  41. }
  42. /// <summary>
  43. /// Gets or sets the key
  44. /// </summary>
  45. public string Key
  46. {
  47. get;
  48. set;
  49. }
  50. /// <summary>
  51. /// Gets or sets the value
  52. /// </summary>
  53. public string Value
  54. {
  55. get;
  56. set;
  57. }
  58. }
  59. }
  60. }