PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/Framework/src/Ncqrs.Tests/Eventing/EventBaseSpecs.cs

http://github.com/ncqrs/ncqrs
C# | 51 lines | 39 code | 12 blank | 0 comment | 0 complexity | b37df4488c7b8a0c6c3bfc49da87d60f 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;
  4. using Xunit;
  5. using Rhino.Mocks;
  6. namespace Ncqrs.Tests.Eventing
  7. {
  8. public class EventBaseSpecs
  9. {
  10. [Fact]
  11. public void Constructing_a_new_event_base_it_should_call_the_GenerateNewId_method_from_the_generator_that_has_been_set_in_the_environment()
  12. {
  13. var generator = MockRepository.GenerateMock<IUniqueIdentifierGenerator>();
  14. NcqrsEnvironment.SetDefault<IUniqueIdentifierGenerator>(generator);
  15. var mock = MockRepository.GenerateStub<Event>();
  16. generator.AssertWasCalled(g=>g.GenerateNewId());
  17. }
  18. [Fact]
  19. public void Constructing_a_new_event_base_it_should_set_the_event_identifier_to_identifier_that_has_been_given_from_the_IUniqueIdentifierGenerator_from_the_NcqrsEnvironment()
  20. {
  21. var identiefier = Guid.NewGuid();
  22. var generator = MockRepository.GenerateStrictMock<IUniqueIdentifierGenerator>();
  23. generator.Stub(g => g.GenerateNewId()).Return(identiefier);
  24. NcqrsEnvironment.SetDefault<IUniqueIdentifierGenerator>(generator);
  25. var mock = MockRepository.GenerateStub<Event>();
  26. mock.EventIdentifier.Should().Be(identiefier);
  27. }
  28. [Fact]
  29. public void Constructing_a_new_event_base_it_should_set_the_event_time_stap_to_the_time_given_by_the_IClock_from_the_NcqrsEnvironment()
  30. {
  31. var theTimeStamp = new DateTime(2000, 1, 1, 1, 1, 1, 1, DateTimeKind.Utc);
  32. var clock = MockRepository.GenerateStrictMock<IClock>();
  33. clock.Stub(c => c.UtcNow()).Return(theTimeStamp);
  34. NcqrsEnvironment.SetDefault<IClock>(clock);
  35. var eventBase = MockRepository.GenerateStub<Event>();
  36. eventBase.EventTimeStamp.Should().Be(theTimeStamp);
  37. }
  38. }
  39. }