Ejemplo n.º 1
0
        public async Task Create_should_create_schema_with_initial_fields()
        {
            var properties = new SchemaProperties();

            var fields = new List <CreateSchemaField>
            {
                new CreateSchemaField {
                    Name = "field1", Properties = ValidProperties()
                },
                new CreateSchemaField {
                    Name = "field2", Properties = ValidProperties()
                }
            };

            var command = new CreateSchema {
                Name = SchemaName, SchemaId = SchemaId, Properties = properties, Fields = fields
            };

            var result = await sut.ExecuteAsync(CreateCommand(command));

            result.ShouldBeEquivalent(EntityCreatedResult.Create(Id, 0));

            var @event = (SchemaCreated)LastEvents.Single().Payload;

            Assert.Equal(AppId, sut.Snapshot.AppId.Id);
            Assert.Equal(SchemaName, sut.Snapshot.Name);
            Assert.Equal(SchemaName, sut.Snapshot.SchemaDef.Name);

            Assert.Equal(2, @event.Fields.Count);
        }
Ejemplo n.º 2
0
        public async Task Create_should_create_schema_with_initial_fields()
        {
            var properties = new SchemaProperties();

            var fields = new List<UpsertSchemaField>
            {
                new UpsertSchemaField { Name = "field1", Properties = ValidProperties() },
                new UpsertSchemaField { Name = "field2", Properties = ValidProperties() },
                new UpsertSchemaField
                {
                    Name = "field3",
                    Partitioning = Partitioning.Language.Key,
                    Properties = new ArrayFieldProperties(),
                    Nested = new List<UpsertSchemaNestedField>
                    {
                        new UpsertSchemaNestedField { Name = "nested1", Properties = ValidProperties() },
                        new UpsertSchemaNestedField { Name = "nested2", Properties = ValidProperties() }
                    }
                }
            };

            var command = new CreateSchema { Name = SchemaName, SchemaId = SchemaId, Properties = properties, Fields = fields };

            var result = await sut.ExecuteAsync(CreateCommand(command));

            result.ShouldBeEquivalent(sut.Snapshot);

            var @event = (SchemaCreated)LastEvents.Single().Payload;

            Assert.Equal(AppId, sut.Snapshot.AppId.Id);
            Assert.Equal(SchemaName, sut.Snapshot.SchemaDef.Name);
            Assert.Equal(SchemaName, sut.Snapshot.SchemaDef.Name);

            Assert.Equal(3, @event.Schema.Fields.Count);
        }