Ejemplo n.º 1
0
        public void do_not_blow_up_building_one()
        {
            var storage = DocumentStorageBuilder.Build(null, new DocumentMapping(typeof(User)));

            storage.ShouldNotBeNull();


            storage.IdType.ShouldBe(NpgsqlDbType.Uuid);
        }
Ejemplo n.º 2
0
        public void implements_the_id_type()
        {
            DocumentStorageBuilder.Build(null, new DocumentMapping(typeof(User))).IdType.ShouldBe(NpgsqlDbType.Uuid);

            var schema = Container.For <DevelopmentModeRegistry>().GetInstance <IDocumentSchema>();

            DocumentStorageBuilder.Build(schema, typeof(IntDoc)).IdType.ShouldBe(NpgsqlDbType.Integer);
            DocumentStorageBuilder.Build(schema, typeof(LongDoc)).IdType.ShouldBe(NpgsqlDbType.Bigint);
            DocumentStorageBuilder.Build(null, typeof(StringDoc)).IdType.ShouldBe(NpgsqlDbType.Text);
        }
Ejemplo n.º 3
0
        public void generate_code()
        {
            var mapping = new DocumentMapping(typeof(Target));

            mapping.DuplicateField("Number");
            mapping.DuplicateField("Date");

            var code = DocumentStorageBuilder.GenerateDocumentStorageCode(new[] { mapping });

            Debug.WriteLine(code);
        }
Ejemplo n.º 4
0
        public string DocumentStorageCodeFor <T>()
        {
            var documentMapping = _schema.MappingFor(typeof(T));

            if (documentMapping is DocumentMapping)
            {
                return(DocumentStorageBuilder.GenerateDocumentStorageCode(new[] { documentMapping.As <DocumentMapping>() }));
            }

            return($"Docuemnt Storage for {typeof (T).FullName} is not generated");
        }
Ejemplo n.º 5
0
        public void do_not_blow_up_building_more_than_one()
        {
            var mappings = new[]
            {
                new DocumentMapping(typeof(User)),
                new DocumentMapping(typeof(Company)),
                new DocumentMapping(typeof(Issue))
            };

            DocumentStorageBuilder.Build(null, mappings).Count()
            .ShouldBe(3);
        }
Ejemplo n.º 6
0
        public void implements_the_identity_method()
        {
            var schema = Container.For <DevelopmentModeRegistry>().GetInstance <IDocumentSchema>();

            var guid = Guid.NewGuid();

            DocumentStorageBuilder.Build(schema, typeof(IntDoc)).Identity(new IntDoc {
                Id = 3
            }).ShouldBe(3);
            DocumentStorageBuilder.Build(schema, typeof(LongDoc)).Identity(new LongDoc {
                Id = 4
            }).ShouldBe(4L);
            DocumentStorageBuilder.Build(null, typeof(StringDoc)).Identity(new StringDoc {
                Id = "abc"
            }).ShouldBe("abc");
            DocumentStorageBuilder.Build(null, typeof(User)).Identity(new User {
                Id = guid
            }).ShouldBe(guid);
        }
Ejemplo n.º 7
0
        public void load_with_small_batch()
        {
            // SAMPLE: using_bulk_insert
            // This is just creating some randomized
            // document data
            var data = Target.GenerateRandomData(100).ToArray();

            // Load all of these into a Marten-ized database
            theStore.BulkInsert(data);

            // And just checking that the data is actually there;)
            theSession.Query <Target>().Count().ShouldBe(data.Length);
            // ENDSAMPLE


            theSession.Load <Target>(data[0].Id).ShouldNotBeNull();


            Debug.WriteLine(DocumentStorageBuilder.GenerateDocumentStorageCode(new DocumentMapping[] { new DocumentMapping(typeof(Target)), }));
        }
Ejemplo n.º 8
0
        public void generates_the_resolve_method()
        {
            var storage = DocumentStorageBuilder.Build(null, DocumentMapping.For <User>());

            storage.ShouldBeAssignableTo <IResolver <User> >();
        }
Ejemplo n.º 9
0
 public string DocumentStorageCodeFor <T>()
 {
     return(DocumentStorageBuilder.GenerateDocumentStorageCode(new[] { _schema.MappingFor(typeof(T)) }));
 }
Ejemplo n.º 10
0
        public void do_not_blow_up_building_one()
        {
            var storage = DocumentStorageBuilder.Build(new DocumentMapping(typeof(User)));

            storage.ShouldNotBeNull();
        }
Ejemplo n.º 11
0
        public void WriteStorageCode(string file)
        {
            var code = DocumentStorageBuilder.GenerateDocumentStorageCode(Options.AllDocumentMappings.ToArray());

            new FileSystem().WriteStringToFile(file, code);
        }
Ejemplo n.º 12
0
 public void generate_document_storage_code_for_the_hierarchy_without_blowing_up()
 {
     DocumentStorageBuilder.Build(null, theHierarchy).ShouldNotBeNull();
 }