public void ProjectOneDocumentNotFound(IDocument <Guid> document, TestProjection projection) { this.Given(_ => RepositoryContains(document)) .When(_ => ProjectOne(document.GetType(), d => d.Version.Equals(-1), p => new TestProjection { Id = p.Id, Version = p.Version })) .Then(_ => DocumentNotProjected()) .BDDfy(); }
public void Build_WithCertainDependencyLifetimeScopeFactory_ShouldGetPassedToProjectorInstance() { var projection = new TestProjection("A"); var builder = new ProjectorBuilder <string, FakeMessageEnvelope>(); builder.Register(projection).SetDependencyLifetimeScopeFactory(_factoryMock.Object); var projector = builder.Build <TestNextSequenceNumberRepository>(); Assert.That(projector.DependencyLifetimeScopeFactory, Is.EqualTo(_factoryMock.Object)); }
public void Should_add_using_only_projection_property_name() { // Arrange var message = new TestMessage {MappedByName = 10}; var projection = new TestProjection {MappedByName = 10}; var builder = new AddNewProjectionStrategyArguments<TestMessage, TestProjection>(); builder.Add(p => p.MappedByName); // Act builder.Mappers.Map(message, projection); // Assert Assert.AreEqual(20, projection.MappedByName); }
public void Should_decrement_projection() { // Arrange var message = new TestMessage(); var projection = new TestProjection {ProjectionProperty = 5}; var builder = new AddNewProjectionStrategyArguments<TestMessage, TestProjection>(); builder.Decrement(p => p.ProjectionProperty); // Act builder.Mappers.Map(message, projection); // Assert Assert.AreEqual(4, projection.ProjectionProperty); }
public void Should_add_to_projection() { // Arrange var message = new TestMessage {MessageProperty = 5}; var projection = new TestProjection {ProjectionProperty = 5}; var builder = new AddNewProjectionStrategyArguments<TestMessage, TestProjection>(); builder.Add(p => p.ProjectionProperty, e => e.MessageProperty); // Act builder.Mappers.Map(message, projection); // Assert Assert.AreEqual(10, projection.ProjectionProperty); }
public void Should_do_lambda_expression() { // Arrange var message = new TestMessage {MessageProperty = 5}; var projection = new TestProjection {ProjectionProperty = 5}; var builder = new AddNewProjectionStrategyArguments<TestMessage, TestProjection>(); builder.Do((e, p) => p.ProjectionProperty = p.ProjectionProperty*e.MessageProperty); // Act builder.Mappers.Map(message, projection); // Assert Assert.AreEqual(25, projection.ProjectionProperty); }
public void Init() { var message = new TestMessage { ValueInt32 = 777, ValueInt64 = 888 }; _targetProjection = new TestProjection(); _targetProvider = new TestProvider(_targetProjection); var persistenceFactory = new TestProvidersFactory(_targetProvider); new TestHandler(persistenceFactory).Handle(message); }
public void Should_set_to_projection() { // Arrange var message = new TestMessage(); var projection = new TestProjection(); var builder = new AddNewProjectionStrategyArguments <TestMessage, TestProjection>(); builder.Set(p => p.ProjectionProperty, 555); // Act builder.Mappers.Map(message, projection); // Assert Assert.AreEqual(555, projection.ProjectionProperty); }
protected async Task ProjectOne(Type type, Expression <Func <IDocument <Guid>, bool> > predicate, Expression <Func <IDocument <Guid>, TestProjection> > projection) { if (type.IsATypeOf(typeof(Parent))) { _projection = await _unitOfWork.ProjectOneAsync <Parent, TestProjection>(predicate, projection); } if (type.IsATypeOf(typeof(Child))) { _projection = await _unitOfWork.ProjectOneAsync <Child, TestProjection>(predicate, projection); } if (type.IsATypeOf(typeof(Event))) { _projection = await _unitOfWork.ProjectOneAsync <Event, TestProjection>(predicate, projection); } }
public void Should_map_to_projection() { // Arrange var message = new TestMessage { MessageProperty = 777 }; var projection = new TestProjection(); var builder = new AddNewProjectionStrategyArguments <TestMessage, TestProjection>(); builder.Map(p => p.ProjectionProperty, e => e.MessageProperty); // Act builder.Mappers.Map(message, projection); // Assert Assert.AreEqual(message.MessageProperty, projection.ProjectionProperty); }
public void Should_map_using_only_projection_property_name() { // Arrange var message = new TestMessage { MappedByName = 555 }; var projection = new TestProjection(); var builder = new AddNewProjectionStrategyArguments <TestMessage, TestProjection>(); builder.Map(p => p.MappedByName); // Act builder.Mappers.Map(message, projection); // Assert Assert.AreEqual(message.MappedByName, projection.MappedByName); }
public void Should_decrement_projection() { // Arrange var message = new TestMessage(); var projection = new TestProjection { ProjectionProperty = 5 }; var builder = new AddNewProjectionStrategyArguments <TestMessage, TestProjection>(); builder.Decrement(p => p.ProjectionProperty); // Act builder.Mappers.Map(message, projection); // Assert Assert.AreEqual(4, projection.ProjectionProperty); }
public void Handle_TwoDifferentMessages_ShouldCallCorrectHandlerWithCorrectArguments() { var connectionMock = new Mock <FakeConnection>(); Func <object> connectionFactory = () => connectionMock.Object; var token = new CancellationToken(); var messageA = new RegisteredMessageA(); var messageB = new RegisteredMessageB(); var messageEnvelopeA = new FakeMessageEnvelope(1, messageA); var messageEnvelopeB = new FakeMessageEnvelope(2, messageB); IProjection <string, FakeMessageEnvelope> projection = new TestProjection("A"); projection.Handle(connectionFactory, messageEnvelopeA, token); projection.Handle(connectionFactory, messageEnvelopeB, token); connectionMock.Verify(x => x.UpdateA(messageEnvelopeA, messageA), Times.Once); connectionMock.Verify(x => x.UpdateB(messageEnvelopeB, messageB, token), Times.Once); }
public void Should_do_lambda_expression() { // Arrange var message = new TestMessage { MessageProperty = 5 }; var projection = new TestProjection { ProjectionProperty = 5 }; var builder = new AddNewProjectionStrategyArguments <TestMessage, TestProjection>(); builder.Do((e, p) => p.ProjectionProperty = p.ProjectionProperty * e.MessageProperty); // Act builder.Mappers.Map(message, projection); // Assert Assert.AreEqual(25, projection.ProjectionProperty); }
public void Should_substract_from_projection() { // Arrange var message = new TestMessage { MessageProperty = 5 }; var projection = new TestProjection { ProjectionProperty = 15 }; var builder = new AddNewProjectionStrategyArguments <TestMessage, TestProjection>(); builder.Substract(p => p.ProjectionProperty, e => e.MessageProperty); // Act builder.Mappers.Map(message, projection); // Assert Assert.AreEqual(10, projection.ProjectionProperty); }
public void Should_substract_from_projection() { // Arrange var @event = new TestEvent {EventProperty = 5}; var projection = new TestProjection {ProjectionProperty = 15}; var builder = new AddNewProjectionStrategyArguments<TestEvent, TestProjection>(); builder.Substract(p => p.ProjectionProperty, e => e.EventProperty); // Act builder.Mappers.Map(@event, projection); // Assert Assert.AreEqual(10, projection.ProjectionProperty); }
public TestProjectionBuilder() { _projection = new TestProjection(); }
protected void DocumentProjected(TestProjection expected) => _projection.Should().BeEquivalentTo(expected);
public void Should_increment_projection() { // Arrange var @event = new TestEvent(); var projection = new TestProjection {ProjectionProperty = 5}; var builder = new AddNewProjectionStrategyArguments<TestEvent, TestProjection>(); builder.Increment(p => p.ProjectionProperty); // Act builder.Mappers.Map(@event, projection); // Assert Assert.AreEqual(6, projection.ProjectionProperty); }
public void Should_set_to_projection() { // Arrange var message = new TestMessage(); var projection = new TestProjection(); var builder = new AddNewProjectionStrategyArguments<TestMessage, TestProjection>(); builder.Set(p => p.ProjectionProperty, 555); // Act builder.Mappers.Map(message, projection); // Assert Assert.AreEqual(555, projection.ProjectionProperty); }
public void Should_substract_using_only_projection_property_name() { // Arrange var @event = new TestEvent {MappedByName = 5}; var projection = new TestProjection {MappedByName = 15}; var builder = new AddNewProjectionStrategyArguments<TestEvent, TestProjection>(); builder.Substract(p => p.MappedByName); // Act builder.Mappers.Map(@event, projection); // Assert Assert.AreEqual(10, projection.MappedByName); }
public void Should_map_to_projection() { // Arrange var @event = new TestEvent {EventProperty = 777}; var projection = new TestProjection(); var builder = new AddNewProjectionStrategyArguments<TestEvent, TestProjection>(); builder.Map(p => p.ProjectionProperty, e => e.EventProperty); // Act builder.Mappers.Map(@event, projection); // Assert Assert.AreEqual(@event.EventProperty, projection.ProjectionProperty); }
public TestProvider(TestProjection readProjection) { ReadProjection = readProjection; }