Advertisement
nassss

Untitled

Mar 26th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using DictionaryWorkshop.Implementation;
  5. using DictionaryWorkshop.Implementation.Contracts;
  6. using DictionaryWorkshop.Models;
  7.  
  8. using Microsoft.VisualStudio.TestTools.UnitTesting;
  9.  
  10. namespace DictionaryWorkshop.Tests
  11. {
  12. [TestMethod]
  13. public void Keys_ShouldWorkCorrectly()
  14. {
  15. // Arrange
  16. var dictionary = new MyDictionary<string, double>();
  17.  
  18. // Assert
  19. CollectionAssert.AreEquivalent(new string[0], dictionary.GetKeys().ToArray());
  20.  
  21. // Arrange
  22. dictionary.Add("Vasko", 12.5);
  23. dictionary.Add("Maria", 99.9);
  24. dictionary["Vasko"] = 123.45;
  25.  
  26. // Act
  27. IEnumerable<string> keys = dictionary.GetKeys();
  28.  
  29. // Assert
  30. string[] expectedKeys = { "Vasko", "Maria" };
  31. CollectionAssert.AreEquivalent(expectedKeys, keys.ToArray());
  32. }
  33. [TestMethod]
  34. public void Values_ShouldWorkCorrectly()
  35. {
  36. // Arrange
  37. var dictionary = new MyDictionary<string, double>();
  38.  
  39. // Assert
  40. CollectionAssert.AreEquivalent(new string[0], dictionary.GetValues().ToArray());
  41.  
  42. // Arrange
  43. dictionary.Add("Vasko", 12.5);
  44. dictionary.Add("Maria", 99.9);
  45. dictionary["Vasko"] = 123.45;
  46.  
  47. // Act
  48. IEnumerable<double> values = dictionary.GetValues();
  49.  
  50. // Assert
  51. double[] expectedValues = { 99.9, 123.45 };
  52. CollectionAssert.AreEquivalent(expectedValues, values.ToArray());
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement