Exemplo n.º 1
0
        public void SelectAllFrom_UseCache()
        {
            var value = new TableWithGuid
            {
                Id   = Guid.NewGuid(),
                Text = "Text"
            };

            connection.Save(value);
            var parent = new ParentTableWithGuid {
                Key = Guid.NewGuid(), Reference = value
            };

            connection.Save(parent);
            var grandParent = new GrandParentWithGuid {
                Key = Guid.NewGuid(), Reference = parent
            };

            connection.Save(grandParent);
            value = connection.Get <TableWithGuid>(value.Id);
            var all = connection.SelectAllFrom <GrandParentWithGuid>().Where(x => x.Reference == parent).ToList();

            Assert.Equal(value, all[0].Reference.Reference);
            Assert.Equal("Text", value.Text);
        }
Exemplo n.º 2
0
        public BaseIntegrationTest(IDatabaseDriver databaseDriver, string connectionString, bool drop)
        {
            var mapper = new Mapper();

            connection  = FolkeConnection.Create(databaseDriver, mapper, connectionString);
            transaction = connection.BeginTransaction();
            connection.CreateTable <TestPoco>(drop: drop);
            connection.CreateTable <TestManyPoco>(drop: drop);
            connection.CreateTable <TestCollection>(drop: drop);
            connection.CreateTable <TestCollectionMember>(drop: drop);
            connection.CreateTable <TestOtherPoco>(drop: drop);
            connection.CreateTable <TestMultiPoco>(drop);
            connection.CreateTable <Playground>(drop);

            var parentTableWithGuidMapping = mapper.GetTypeMapping <ParentTableWithGuid>();

            parentTableWithGuidMapping.Property(x => x.Key).HasColumnName("KeyColumn");
            parentTableWithGuidMapping.HasKey(x => x.Key);
            connection.CreateOrUpdateTable <TableWithGuid>();
            connection.CreateOrUpdateTable <ParentTableWithGuid>();
            connection.CreateOrUpdateTable <GrandParentWithGuid>();

            testValue = new TableWithGuid
            {
                Id   = Guid.NewGuid(),
                Text = "Text"
            };
            connection.Save(testValue);
        }
        public void InsertInto_ObjectWithGuid()
        {
            var value = new TableWithGuid
            {
                Id   = Guid.NewGuid(),
                Text = "Text"
            };

            connection.InsertInto <TableWithGuid>().Values(value).Execute();
        }
Exemplo n.º 4
0
        public void Load_ObjectWithGuid()
        {
            var value = new TableWithGuid
            {
                Id   = Guid.NewGuid(),
                Text = "Text"
            };

            connection.Save(value);
            var result = connection.Load <TableWithGuid>(value.Id);

            Assert.Equal(value.Id, result.Id);
            Assert.Equal(value.Text, result.Text);
        }
        public async Task SaveAsync_ObjectWithGuid()
        {
            var value = new TableWithGuid
            {
                Id   = Guid.NewGuid(),
                Text = "Text"
            };
            await connection.SaveAsync(value);

            var result = await connection.GetAsync <TableWithGuid>(value.Id);

            Assert.Equal(value.Id, result.Id);
            Assert.Equal(value.Text, result.Text);
        }
Exemplo n.º 6
0
        public void Select_TableWithGuid_WhereParameter_List()
        {
            var value = new TableWithGuid
            {
                Id   = Guid.NewGuid(),
                Text = "Text"
            };

            connection.InsertInto <TableWithGuid>().Values(value).Execute();

            var values = connection.Select <TableWithGuid, FolkeTuple <TableWithGuid> >().All().From().Where((x, p) => x == p.Item0).Build(connection, value).ToList();

            Assert.NotEmpty(values);
            Assert.Equal(value.Id, values[0].Id);
            Assert.Equal(value.Text, values[0].Text);
        }
Exemplo n.º 7
0
        public void Select_TableWithGuid_WhereObject_List()
        {
            var value = new TableWithGuid
            {
                Id   = Guid.NewGuid(),
                Text = "Text"
            };

            connection.InsertInto <TableWithGuid>().Values(value).Execute();

            var values = connection.Select <TableWithGuid>().All().From().Where(x => x == value).ToList();

            Assert.NotEmpty(values);
            Assert.Equal(value.Id, values[0].Id);
            Assert.Equal(value.Text, values[0].Text);
        }
Exemplo n.º 8
0
        public void Load_ObjectWithGuid_WithAutoJoin()
        {
            var value = new TableWithGuid
            {
                Id   = Guid.NewGuid(),
                Text = "Text"
            };

            connection.Save(value);
            var parent = new ParentTableWithGuid
            {
                Key       = Guid.NewGuid(),
                Text      = "Parent",
                Reference = value
            };

            connection.Save(parent);
            var result = connection.Load <ParentTableWithGuid>(parent.Key, x => x.Reference);

            Assert.Equal(parent.Key, result.Key);
            Assert.Equal(parent.Text, result.Text);
            Assert.Equal(value.Id, parent.Reference.Id);
            Assert.Equal(value.Text, parent.Reference.Text);
        }