static void Main(string[] args) { if (!Environment.UserInteractive) { Run(new TheService()); } else { // If interactive, start up as a console app for easy debugging and/or installing/uninstalling the service switch (string.Concat(args)) { case "/i": ManagedInstallerClass.InstallHelper(new[] { Assembly.GetExecutingAssembly().Location }); break; case "/u": ManagedInstallerClass.InstallHelper(new[] { "/u", Assembly.GetExecutingAssembly().Location }); break; default: Console.WriteLine("Running service in console debug mode (use /i or /u to install or uninstall the service)"); var service = new TheService(); service.OnStart(null); Thread.Sleep(Timeout.Infinite); break; } } }
public void Command_should_create_and_then_use_existing() { var command = new AggregateRootTargetCreateOrUpdateTitleCommand { Title = "AggregateRootCreateNewCommand", Id = Guid.NewGuid() }; TheService.Execute(command); AggRoot.Title.Should().Be("AggregateRootCreateNewCommand"); var arId = AggRoot.ArId; command = new AggregateRootTargetCreateOrUpdateTitleCommand { Title = "AggregateRootCreateNewCommand2", Id = Guid.NewGuid() }; TheService.Execute(command); AggRoot.Title.Should().Be("AggregateRootCreateNewCommand2"); Assert.NotEqual(arId, AggRoot.ArId); var createTicks = AggRoot.created; arId = AggRoot.ArId; command = new AggregateRootTargetCreateOrUpdateTitleCommand { Title = "AggregateRootUpdatedCommand", Id = arId }; TheService.Execute(command); AggRoot.Title.Should().Be("AggregateRootUpdatedCommand"); AggRoot.ArId.Should().Be(arId); AggRoot.created.Should().Be(createTicks); }
public static void InitService() { if (service != null) { service = null; //Service.Dispose(); } service = new TheService(); }
public void All_interceptors_should_be_called_after_execution() { Interceptor1.Replay(); Interceptor2.Replay(); TheService.Execute(new CommandWithExecutor()); Interceptor1.AssertWasCalled(i => i.OnAfterExecution(null), options => options.IgnoreArguments()); Interceptor2.AssertWasCalled(i => i.OnAfterExecution(null), options => options.IgnoreArguments()); }
public void Executing_command_should_executure_correct_handler_with_it() { var theCommand = new CommandWithExecutor(); ExecutorForCommandWithExecutor.Replay(); TheService.Execute(theCommand); ExecutorForCommandWithExecutor.AssertWasCalled(e => e.Execute(theCommand)); }
public void Command_should_create_new_aggregate_root() { var command = new AggregateRootTargetCreateNewCommand { Title = "AggregateRootTargetCreateNewCommand" }; TheService.Execute(command); AggRoot.Title.Should().Be("AggregateRootTargetCreateNewCommand"); }
public void Command_should_throw_an_exception_when_the_command_is_not_mapped() { var command = new AggregateRootTargetNotAMappedCommand { Title = "AggregateRootTargetNotAMappedCommand" }; Action act = () => TheService.Execute(command); act.ShouldThrow <ExecutorForCommandNotFoundException>(); }
public void Command_should_create_new_aggregate_root_with_static_method() { var command = new AggregateRootTargetStaticCreateCommand { Title = "AggregateRootTargetStaticCreateCommand" }; TheService.Execute(command); AggRoot.Title.Should().Be("AggregateRootTargetStaticCreateCommand"); }
public void Command_should_update_the_title_of_the_aggregate_root() { var command = new AggregateRootTargetUpdateTitleCommand { Title = "AggregateRootTargetUpdateTitleCommand" }; TheService.Execute(command); AggRoot.Title.Should().Be("AggregateRootTargetUpdateTitleCommand"); }
public void Command_should_create_new_complex_aggregate_root_using_implicit_parameter_mappings() { var command = new ComplexAggregateRootTargetCreateNewCommand4 { Title = "ComplexAggregateRootTargetCreateNewCommand4", Quantity = 40 }; TheService.Execute(command); ComplexAggRoot.Title.Should().Be("ComplexAggregateRootTargetCreateNewCommand4"); ComplexAggRoot.Quantity.Should().Be(40); }
public void Command_should_update_the_title_of_the_aggregate_root() { // TODO: Fix the mocking for this test. Assert.Ignore("Fix mocking"); var command = new AggregateRootTargetUpdateTitleCommand { Title = "AggregateRootTargetUpdateTitleCommand" }; TheService.Execute(command); AggRoot.Title.Should().Be("AggregateRootTargetUpdateTitleCommand"); }
public void Executing_command_with_no_handler_should_cause_exception() { Action act = () => TheService.Execute(new CommandWithoutExecutor()); act.ShouldThrow <ExecutorForCommandNotFoundException>(); }
public static IDataClientService ServiceCreator() { return(service = new TheService()); }