nassss

Untitled

Mar 26th, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 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. [TestClass]
  13. public class DictionaryTests
  14. {
  15. [TestMethod]
  16. public void Indexer_NotExistingElement_ShouldReturnTheValue()
  17. {
  18. // Arrange
  19. MyDictionary<int, string> dictionary = new MyDictionary<int, string> { { 555, "Vasko" } };
  20. string[] expectedValues = { "Vasko", "Gosho" };
  21.  
  22. // Act
  23. dictionary[5] = "Gosho";
  24. IEnumerable<string> values = dictionary.GetValues();
  25.  
  26. // Assert
  27. CollectionAssert.AreEquivalent(expectedValues, values.ToArray());
  28. }
  29.  
  30. [TestMethod]
  31. [ExpectedException(typeof(KeyNotFoundException))]
  32. public void Indexer_NonExistingElement_ShouldThrowException()
  33. {
  34. // Arrange
  35. MyDictionary<int, string> dictionary = new MyDictionary<int, string>();
  36.  
  37. // Act
  38. string value = dictionary[12345];
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment