public void Command_decorated_with_Transactional_attribute_mapped_to_method_should_be_executed_in_context_of_transaction() { bool executedInTransaction = false; var instance = new AggregateRootTarget("TitleSetInConstructor"); var command = new TransactionalAggregateRootTargetUpdateTitleCommand { Title = "TransactionalAggregateRootTargetUpdateTitleCommand" }; var executor = new TestAttributeMappedCommandExecutor<AggregateRootTarget>(command, instance); executor.VerificationAction = () => executedInTransaction = Transaction.Current != null; executor.Execute(); Assert.True(executedInTransaction); }
public void Command_should_update_the_title_of_the_existing_aggregate_root() { var instance = new AggregateRootTarget("TitleSetInConstructor"); var command = new AggregateRootTargetCreateOrUpdateTitleCommand { Title = "AggregateRootTargetUpdateTitleCommand" }; var executor = new TestAttributeMappedCommandExecutor <AggregateRootTarget>(command, instance); executor.Execute(); executor.Instance.Title.Should().Be("AggregateRootTargetUpdateTitleCommand"); }
public void Command_decorated_with_Transactional_attribute_mapped_to_method_should_be_executed_in_context_of_transaction() { bool executedInTransaction = false; var instance = new AggregateRootTarget("TitleSetInConstructor"); var command = new TransactionalAggregateRootTargetUpdateTitleCommand { Title = "TransactionalAggregateRootTargetUpdateTitleCommand" }; var executor = new TestAttributeMappedCommandExecutor <AggregateRootTarget>(command, instance); executor.VerificationAction = () => executedInTransaction = Transaction.Current != null; executor.Execute(); Assert.IsTrue(executedInTransaction); }
private static AggregateRootTarget GetAggregateRoot() { return(AggRoot ?? (AggRoot = new AggregateRootTarget("from GetAggregateRoot()"))); }
private static AggregateRootTarget GetAggregateRoot() { return AggRoot ?? (AggRoot = new AggregateRootTarget("from GetAggregateRoot()")); }
public void Command_should_update_the_title_of_the_existing_aggregate_root() { var instance = new AggregateRootTarget("TitleSetInConstructor"); var command = new AggregateRootTargetCreateOrUpdateTitleCommand { Title = "AggregateRootTargetUpdateTitleCommand" }; var executor = new TestAttributeMappedCommandExecutor<AggregateRootTarget>(command, instance); executor.Execute(); executor.Instance.Title.Should().Be("AggregateRootTargetUpdateTitleCommand"); }
public void Setup() { var service = new CommandService(); Map.Command<AggregateRootTargetStaticCreateCommand>().ToAggregateRoot<AggregateRootTarget>().CreateNew((cmd) => AggregateRootTarget.CreateNew(cmd.Title)).StoreIn((cmd, aggroot) => AggRoot = aggroot).RegisterWith(service); Map.Command<AggregateRootTargetUpdateTitleCommand>().ToAggregateRoot<AggregateRootTarget>().WithId(cmd => cmd.Id, (guid, knownVersion) => GetAggregateRoot()).ToCallOn((cmd, aggroot) => aggroot.UpdateTitle(cmd.Title)).RegisterWith(service); Map.Command<AggregateRootTargetCreateNewCommand>().ToAggregateRoot<AggregateRootTarget>().CreateNew((cmd) => new AggregateRootTarget(cmd.Title)).StoreIn((cmd, aggroot) => AggRoot = aggroot).RegisterWith(service); Map.Command<AggregateRootTargetCreateOrUpdateTitleCommand>().ToAggregateRoot<AggregateRootTarget>().UseExistingOrCreateNew(cmd => cmd.Id, (guid, knownVersion) => GetAggregateRoot(guid), (cmd) => new AggregateRootTarget(cmd.Id, cmd.Title)).ToCallOn((cmd, aggroot) => aggroot.UpdateTitle(cmd.Title)).RegisterWith(service); TheService = service; }
public FluentCommandMappingTests() { var service = new CommandService(); Map.Command <AggregateRootTargetStaticCreateCommand>().ToAggregateRoot <AggregateRootTarget>().CreateNew((cmd) => AggregateRootTarget.CreateNew(cmd.Title)).StoreIn((cmd, aggroot) => AggRoot = aggroot).RegisterWith(service); Map.Command <AggregateRootTargetUpdateTitleCommand>().ToAggregateRoot <AggregateRootTarget>().WithId(cmd => cmd.Id, (guid, knownVersion) => GetAggregateRoot()).ToCallOn((cmd, aggroot) => aggroot.UpdateTitle(cmd.Title)).RegisterWith(service); Map.Command <AggregateRootTargetCreateNewCommand>().ToAggregateRoot <AggregateRootTarget>().CreateNew((cmd) => new AggregateRootTarget(cmd.Title)).StoreIn((cmd, aggroot) => AggRoot = aggroot).RegisterWith(service); Map.Command <AggregateRootTargetCreateOrUpdateTitleCommand>().ToAggregateRoot <AggregateRootTarget>().UseExistingOrCreateNew(cmd => cmd.Id, (guid, knownVersion) => GetAggregateRoot(guid), (cmd) => new AggregateRootTarget(cmd.Id, cmd.Title)).ToCallOn((cmd, aggroot) => aggroot.UpdateTitle(cmd.Title)).RegisterWith(service); TheService = service; }
public void Setup() { var service = new CommandService(); Map.Command <AggregateRootTargetUpdateTitleCommand>().ToAggregateRoot <AggregateRootTarget>().WithId(cmd => cmd.Id, guid => GetAggregateRoot()).ToCallOn((cmd, aggroot) => aggroot.UpdateTitle(cmd.Title)).RegisterWith(service); Map.Command <AggregateRootTargetCreateNewCommand>().ToAggregateRoot <AggregateRootTarget>().CreateNew((cmd) => new AggregateRootTarget(cmd.Title)).StoreIn((cmd, aggroot) => AggRoot = aggroot).RegisterWith(service); TheService = service; }