private static ICommandService InitializeCommandService() { var mapper = new AttributeBasedCommandMapper(); var service = new CommandService(); service.RegisterExecutor(typeof(CreatePersonCommand), new UoWMappedCommandExecutor(mapper)); service.RegisterExecutor(typeof(ChangeNameCommand), new UoWMappedCommandExecutor(mapper)); return service; }
private static ICommandService InitializeCommandService() { var mapper = new AttributeBasedCommandMapper(); var service = new CommandService(); service.RegisterExecutor(typeof(CreatePersonCommand), new UoWMappedCommandExecutor(mapper)); service.RegisterExecutor(typeof(ChangeNameCommand), new UoWMappedCommandExecutor(mapper)); return(service); }
public static void RegisterExecutorsInAssembly(this CommandService target, Assembly asm) { var mapper = new AttributeBasedCommandMapper(); foreach (var mappedCommand in asm.GetTypes().Where(mapper.CanMapCommand)) { var executor = new UoWMappedCommandExecutor(mapper); target.RegisterExecutor(mappedCommand, executor); } }
public void Creating_executor_with_runtime_determed_type_should_create_working_executor() { var mapper = new AttributeBasedCommandMapper(); var executor = new UoWMappedCommandExecutor(mapper); var command = new CorrectlyMappedCommand { Bar = 25, Foo = "Hello world" }; executor.Execute(command); TargetAggRoot.FooValue.Should().Be(command.Foo); TargetAggRoot.BarValue.Should().Be(command.Bar); }
public NsbCommandService() { _mapper = new AttributeBasedCommandMapper(); _executor = new UoWMappedCommandExecutor(_mapper); }
public void IsCommandMapped_should_return_true_for_correct_command_types_with_correct_attribute() { var factory = new AttributeBasedCommandMapper(); factory.CanMapCommand(typeof(CommandTypeAndWithAttribute)).Should().BeTrue(); }
public void IsCommandMapped_should_return_false_for_non_command_types_that_do_have_the_required_attribute() { var factory = new AttributeBasedCommandMapper(); factory.CanMapCommand(typeof(NonCommandTypeButWithCorrectAttribute)).Should().BeFalse(); }
public void IsCommandMapped_should_return_false_for_non_command_types() { var factory = new AttributeBasedCommandMapper(); factory.CanMapCommand(typeof(string)).Should().BeFalse(); }
public void IsCommandMapped_should_return_false_for_correct_command_types_but_that_does__not_have_the_required_attribute() { var factory = new AttributeBasedCommandMapper(); factory.CanMapCommand(typeof(CommandTypeButWithoutAttribute)).Should().BeFalse(); }