Exemplo n.º 1
0
        public async Task SavesDaysVisitedSchema()
        {
            var command = new CreateSchemaCommand
            {
                Type = SchemaType.DaysVisited,
            };

            _shopMock.Setup(x => x.SaveSchema(It.IsAny <Schema>()))
            .ReturnsAsync(true);

            var result = await _handler.Handle(command, CancellationToken.None);

            False(result.Error);
            _shopMock.Verify(x => x.SaveSchema(It.IsAny <Schema>()));
        }
        public async Task <IActionResult> Post([FromBody] CreateSchemaCommand command)
        {
            try
            {
                Schema schema = await this._mediator.Send(command);

                return(Ok(schema));
            }
            catch (SchemaDomainException exception)
            {
                this._logger.LogError(0, exception, exception.Message);
                return(BadRequest(new { Reason = exception.Message }));
            }
            catch (Exception exception)
            {
                this._logger.LogError(0, exception, exception.Message);
                return(BadRequest());
            }
        }
        public void CreateNewSchema()
        {
            // Arrange
            const string schemaName = "Test Schema";

            string[] schemaProperties = new string[] { "Aap", "Noot", "Mies " };

            // Act
            var command = new CreateSchemaCommand()
            {
                Name       = schemaName,
                Properties = schemaProperties
            };

            Should.NotThrow(async() => await _commandHandler.Handle(command));

            AssertEventsRecorded(
                (@event) => @event.Is <SchemaRenamed>(schemaRenamed => schemaRenamed.SchemaName == schemaName),
                (@event) => @event.Is <SchemaPropertyCreated>(schemaPropertyCreated => schemaPropertyCreated.PropertyName == schemaProperties[0]),
                (@event) => @event.Is <SchemaPropertyCreated>(schemaPropertyCreated => schemaPropertyCreated.PropertyName == schemaProperties[1]),
                (@event) => @event.Is <SchemaPropertyCreated>(schemaPropertyCreated => schemaPropertyCreated.PropertyName == schemaProperties[2])
                );
        }
Exemplo n.º 4
0
 public Task <Response <Schema> > ActivateShopSchema([FromRoute] CreateSchemaCommand command)
 {
     return(Mediator.Send(command));
 }
Exemplo n.º 5
0
        public void CreateSchema(string schemaName)
        {
            var createSchemaCommand = new CreateSchemaCommand(_root, schemaName);

            _root.Add(createSchemaCommand);
        }
Exemplo n.º 6
0
 // POST api/<controller>
 public void Post(CreateSchemaCommand cmd)
 {
     _commandDispatcher.Dispatch(cmd);
     //return await Task.FromResult(new HttpResponseMessage(HttpStatusCode.Created));
 }