Exemplo n.º 1
0
            public void SetUp()
            {
                log        = Substitute.For <ILog>();
                fileSystem = Substitute.For <IFileSystem>();
                dataSource = Substitute.For <IDataSource>();

                createSiteCommand = new CreateSiteCommand(log, fileSystem, dataSource);
            }
        public void ShouldContainNoErrors()
        {
            // Arrange
            var command = new CreateSiteCommand("Code", "Name", "Source");

            // Act
            var validationResult = _validator.Validate(command);
            var exists           = validationResult.Errors.Count > 0;

            // Assert
            exists.Should().BeFalse();
        }
Exemplo n.º 3
0
            public void SetUp()
            {
                pathThatAlreadyExists = Path.Combine("path", "that", "already", "exists");

                log        = Substitute.For <ILog>();
                fileSystem = Substitute.For <IFileSystem>();
                dataSource = Substitute.For <IDataSource>();

                fileSystem.DirectoryExists(pathThatAlreadyExists).Returns(true);

                createSiteCommand = new CreateSiteCommand(log, fileSystem, dataSource);
            }
Exemplo n.º 4
0
            public void SetUp()
            {
                validPath = Path.Combine("some", "valid", "path");

                log        = Substitute.For <ILog>();
                fileSystem = Substitute.For <IFileSystem>();
                dataSource = Substitute.For <IDataSource>();

                fileSystem.DirectoryExists(validPath).Returns(false);
                fileSystem.ChangeDirectory(validPath, Arg.Invoke());

                createSiteCommand = new CreateSiteCommand(log, fileSystem, dataSource);
            }
        public void ShouldHaveSiteSourceMandatoryValidationFailureWhenSourceIsNull()
        {
            // Arrange
            string source = null;

            var command = new CreateSiteCommand("Code", "Name", source);

            // Act
            var validationResult = _validator.Validate(command);
            var exists           =
                validationResult.Errors.Any(
                    a => a.PropertyName.Equals("Source") && a.ErrorMessage.Contains(ValidationFailures.SiteSourceMandatory));

            // Assert
            exists.Should().BeTrue();
        }
Exemplo n.º 6
0
 public async Task <dynamic> CreateSite([FromBody] CreateSiteCommand cmd)
 {
     _logger.LogInformation($"接收到接口请求/api/Site/CreateSite,参数 Name={cmd.Name} Domain={cmd.Domain}");
     return(await _mediator.Send(cmd, HttpContext.RequestAborted));
 }
Exemplo n.º 7
0
 // PUT: api/Site/5
 public void Put(int id, [FromBody] CreateSiteCommand command)
 {
     ExecuteCommand(command);
 }
Exemplo n.º 8
0
        public CreateSiteCommand Map(CreateSiteRequest request)
        {
            var result = new CreateSiteCommand(request.BodyCode, request.BodyName, request.BodySource);

            return(result);
        }
Exemplo n.º 9
0
 public async Task <IHttpActionResult> CreateSite([FromUri] string urlFriendlyName, [FromBody] CreateSiteCommand command)
 {
     command.AccountUrlFriendlyName = urlFriendlyName;
     return(Ok(await Mediator.Send(command)));
 }