public async Task should_create_a_correct_command()
        {
            var request = new RegisterOrganisationRequest
            {
                OvoNumber = "OVO003347"
            };

            var commands = await Post("/v1/organisations", request);

            Assert.True(commands.Count == 1);

            commands[0].IsEqual(
                new RegisterOrganisation(
                    new OvoNumber(request.OvoNumber)));
        }
        public void should_validate_request()
        {
            var validator = new RegisterOrganisationRequestValidator();

            validator.ShouldHaveValidationErrorFor(x => x.OvoNumber, null as string);
            validator.ShouldHaveValidationErrorFor(x => x.OvoNumber, "bla");
            validator.ShouldHaveValidationErrorFor(x => x.OvoNumber, new string('a', OvoNumber.MaxLength + 10));

            var validRequest = new RegisterOrganisationRequest
            {
                OvoNumber = "OVO003347"
            };

            validator.ShouldNotHaveValidationErrorFor(x => x.OvoNumber, validRequest);
        }
        public async Task <IActionResult> CreateDomain(
            [FromServices] ICommandHandlerResolver bus,
            [FromCommandId] Guid commandId,
            [FromBody] RegisterOrganisationRequest request,
            CancellationToken cancellationToken = default)
        {
            await new RegisterOrganisationRequestValidator()
            .ValidateAndThrowAsync(request, cancellationToken: cancellationToken);

            var command = RegisterOrganisationRequestMapping.Map(request);

            return(Accepted(
                       $"/v1/organisations/{command.OvoNumber}",
                       await bus.Dispatch(
                           commandId,
                           command,
                           GetMetadata(),
                           cancellationToken)));
        }