public void Arrange() { _mockCommandService = new Mock <ICommandService>(); _fixture = new Fixture(); _command = _fixture.Create <CreateIncentiveCommand>(); _sut = new HandleApprenticeshipIncentivesCreateCommand(_mockCommandService.Object); }
public Task Handle(EarningsCalculationRequired @event, CancellationToken cancellationToken = default) { var commands = new List <Task>(); foreach (var apprenticeship in @event.Model.ApprenticeshipModels) { var command = new CreateIncentiveCommand( @event.Model.AccountId, @event.Model.AccountLegalEntityId, apprenticeship.Id, apprenticeship.ApprenticeshipId, apprenticeship.FirstName, apprenticeship.LastName, apprenticeship.DateOfBirth, apprenticeship.ULN, apprenticeship.PlannedStartDate, apprenticeship.ApprenticeshipEmployerTypeOnApproval, apprenticeship.UKPRN, @event.Model.DateSubmitted.Value, @event.Model.SubmittedByEmail, apprenticeship.CourseName ); var task = _commandPublisher.Publish(command); commands.Add(task); } return(Task.WhenAll(commands)); }
public async Task Then_the_command_is_valid_when_all_mandatory_values_are_supplied() { // Arrange var command = new CreateIncentiveCommand(_fixture.Create <long>(), _fixture.Create <long>(), Guid.NewGuid(), _fixture.Create <long>(), _fixture.Create <string>(), _fixture.Create <string>(), _fixture.Create <DateTime>(), _fixture.Create <long>(), _fixture.Create <DateTime>(), _fixture.Create <ApprenticeshipEmployerType>(), _fixture.Create <long>(), _fixture.Create <DateTime>(), _fixture.Create <string>(), _fixture.Create <string>(), _fixture.Create <DateTime>(), _fixture.Create <Phase>()); // Act var result = await _sut.Validate(command); // Assert result.ValidationDictionary.Count.Should().Be(0); }
public async Task Run() { var endpointConfiguration = new EndpointConfiguration("SFA.DAS.EmployerIncentives.Functions.TestConsole"); var storageDirectory = Path.Combine(Directory.GetCurrentDirectory().Substring(0, Directory.GetCurrentDirectory().IndexOf("bin")), ".learningtransport"); endpointConfiguration .UseNewtonsoftJsonSerializer() .UseMessageConventions() .UseLearningTransport(s => s.AddRouting()) .UseTransport <LearningTransport>() .StorageDirectory(storageDirectory); var endpointInstance = await Endpoint.Start(endpointConfiguration) .ConfigureAwait(false); string command; do { //var message = new AddedLegalEntityEvent //{ // AccountId = 2, // AccountLegalEntityId = 2, // LegalEntityId = 3, // OrganisationName = "Org name" //}; //await endpointInstance.Publish(message); var message2 = new CreateIncentiveCommand(1, 2, Guid.NewGuid(), 2, "test", "test", new DateTime(2000, 1, 1), 1, new DateTime(2020, 9, 1), 0, 10001234, DateTime.Now, "*****@*****.**", "Course Name", new DateTime(2021, 04, 01), Phase.Phase1); await endpointInstance.Send(message2); Console.WriteLine("Message sent..."); Console.WriteLine("Enter 'q' to exit..." + Environment.NewLine); command = Console.ReadLine(); } while (!command.Equals("q")); await endpointInstance.Stop() .ConfigureAwait(false); }
public async Task WhenTheApprenticeshipIncentiveIsCreatedForEachApprenticeshipInTheApplication() { foreach (var apprenticeship in _apprenticeshipsModels) { var createCommand = new CreateIncentiveCommand(_applicationModel.AccountId, _applicationModel.AccountLegalEntityId, apprenticeship.Id, apprenticeship.ApprenticeshipId, apprenticeship.FirstName, apprenticeship.LastName, apprenticeship.DateOfBirth, apprenticeship.ULN, apprenticeship.PlannedStartDate, apprenticeship.ApprenticeshipEmployerTypeOnApproval, apprenticeship.UKPRN, _applicationModel.DateSubmitted.Value, _applicationModel.SubmittedByEmail, apprenticeship.CourseName); await _testContext.WaitFor <ICommand>(async (cancellationToken) => await _testContext.MessageBus.Send(createCommand), numberOfOnProcessedEventsExpected : _apprenticeshipsModels.Count()); } }
private static bool AreMatching(CreateIncentiveCommand expected, CreateIncentiveCommand actual) { expected.Should().BeEquivalentTo(actual, opt => opt.Excluding(x => x.Log)); return(true); }
public async Task HandleCommand([NServiceBusTrigger(Endpoint = QueueNames.ApprenticeshipIncentivesCreate)] CreateIncentiveCommand command) { await _commandService.Dispatch(command); }