Example #1
0
        public void Test_select_of_class_with_guid_property_and_no_default_constructor()
        {
            using (var connection = GetSQLiteConnection())
            {
                // Arrange.
                var seed = Guid.NewGuid();

                var expectedRes = new ClassWithGuidPropertyWithNoDefaultConstructor(seed, TEST_STRING);

                connection.Execute(CREATE_STATEMENT);
                connection.Execute(INSERT_STATEMENT, expectedRes);

                // Act.
                var res = connection.Query <ClassWithGuidPropertyWithNoDefaultConstructor>(SELECT_STATEMENT).FirstOrDefault();

                // Assert.
                Assert.Equal(expectedRes, res);
            }
        }
Example #2
0
        public void Test_Insert_Using_Anonymous_Object()
        {
            using (var connection = GetSQLiteConnection())
            {
                // Arrange.
                var seed = Guid.NewGuid();

                var expectedRes = new ClassWithGuidPropertyWithNoDefaultConstructor(seed, TEST_STRING);

                connection.Execute(CREATE_STATEMENT);
                connection.Execute(INSERT_STATEMENT, new
                {
                    Id   = seed,
                    Name = "Test Name"
                });

                // Act.
                var res = connection.Query <ClassWithGuidPropertyWithNoDefaultConstructor>(SELECT_STATEMENT).FirstOrDefault();

                // Assert.
                Assert.Equal(expectedRes, res);
            }
        }