PageRenderTime 22ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/Framework/src/Ncqrs.Tests/Eventing/Storage/PropertyBagTests.cs

http://github.com/ncqrs/ncqrs
C# | 76 lines | 62 code | 14 blank | 0 comment | 1 complexity | 5ce158c95096de7da67ad1cbfffeff35 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, Apache-2.0
  1. using System;
  2. using FluentAssertions;
  3. using Ncqrs.Eventing.Storage;
  4. using Xunit;
  5. namespace Ncqrs.Tests.Eventing.Storage
  6. {
  7. public class PropertyBagTests
  8. {
  9. [Fact]
  10. public void Creating_a_bag_should_not_throw_exception()
  11. {
  12. Action act = ()=>new PropertyBag("testing");
  13. act();
  14. }
  15. [Fact]
  16. public void EventName_information_should_match_initialized_name()
  17. {
  18. var bag = new PropertyBag("testing");
  19. bag.EventName.Should().Be("testing");
  20. }
  21. [Fact]
  22. public void An_new_instance_should_not_contain_any_properties()
  23. {
  24. var bag = new PropertyBag("testing");
  25. bag.Properties.Count.Should().Be(0);
  26. }
  27. [Fact]
  28. public void Calling_AddPropertyValue_should_add_the_property_info()
  29. {
  30. var thePropName = "MyProperty";
  31. var thePropValue = "Hello world";
  32. var bag = new PropertyBag("testing");
  33. bag.AddPropertyValue(thePropName, thePropValue);
  34. bag.Properties.Should().ContainKey(thePropName);
  35. bag.Properties.Should().ContainValue(thePropValue);
  36. }
  37. [Fact]
  38. public void The_number_of_properties_should_be_equal_to_the_number_of_calls_to_AddPropertyValue()
  39. {
  40. var callCount = 5;
  41. var bag = new PropertyBag("testing");
  42. for(int i =0; i<callCount; i++)
  43. {
  44. var name = "prop" + i;
  45. var value = i;
  46. bag.AddPropertyValue(name, value);
  47. }
  48. bag.Properties.Count.Should().Be(callCount);
  49. }
  50. [Fact]
  51. public void Adding_the_same_property_twice_should_cause_exception()
  52. {
  53. var propertyName = "MyProperty";
  54. var firstValue = 1;
  55. var secondValue = 2;
  56. var bag = new PropertyBag("testing");
  57. bag.AddPropertyValue(propertyName, firstValue);
  58. Action act = ()=>bag.AddPropertyValue(propertyName, secondValue);
  59. act.ShouldThrow<ArgumentException>();
  60. }
  61. }
  62. }