Ejemplo n.º 1
0
        public void TestDbRepositoryBytesMappedCrud()
        {
            // Setup
            var text   = "RepoDb"; // Helper.GetAssemblyDescription();
            var bytes  = Encoding.UTF8.GetBytes(text);
            var entity = new BytesMapClass
            {
                SessionId             = Guid.NewGuid(),
                ColumnBinaryMapped    = bytes,
                ColumnImageMapped     = bytes,
                ColumnVarBinaryMapped = bytes,
                ColumnTinyIntMapped   = 128
            };

            using (var repository = new DbRepository <SqlConnection>(Database.ConnectionStringForRepoDb))
            {
                // Act Insert
                var id = repository.Insert(entity);

                // Act Query
                var data = repository.Query <BytesMapClass>(e => e.SessionId == (Guid)id).FirstOrDefault();

                // Assert
                Assert.IsNotNull(data);
                Assert.AreEqual(text, Encoding.UTF8.GetString(data.ColumnBinaryMapped.Take(entity.ColumnBinaryMapped.Length).ToArray()));
                Assert.AreEqual(text, Encoding.UTF8.GetString(data.ColumnImageMapped));
                Assert.AreEqual(text, Encoding.UTF8.GetString(data.ColumnVarBinaryMapped));
                Assert.AreEqual(entity.ColumnTinyIntMapped, data.ColumnTinyIntMapped);
            }
        }
Ejemplo n.º 2
0
        public void TestBaseRepositoryBytesMappedNullCrud()
        {
            // Setup
            var entity = new BytesMapClass
            {
                SessionId             = Guid.NewGuid(),
                ColumnBinaryMapped    = null,
                ColumnImageMapped     = null,
                ColumnTinyIntMapped   = null,
                ColumnVarBinaryMapped = null
            };

            using (var repository = new BytesMapClassRepository(Database.ConnectionStringForRepoDb))
            {
                // Act Insert
                var id = repository.Insert(entity);

                // Act Query
                var data = repository.Query(e => e.SessionId == (Guid)id).FirstOrDefault();

                // Assert
                Assert.IsNotNull(data);
                Assert.IsNull(data.ColumnBinaryMapped);
                Assert.IsNull(data.ColumnImageMapped);
                Assert.IsNull(data.ColumnTinyIntMapped);
                Assert.IsNull(data.ColumnVarBinaryMapped);
            }
        }
Ejemplo n.º 3
0
        public void TestDbRepositoryBytesMappedNullCrudAsync()
        {
            // Setup
            var entity = new BytesMapClass
            {
                SessionId             = Guid.NewGuid(),
                ColumnBinaryMapped    = null,
                ColumnImageMapped     = null,
                ColumnTinyIntMapped   = null,
                ColumnVarBinaryMapped = null
            };

            using (var repository = new DbRepository <SqlConnection>(Database.ConnectionStringForRepoDb))
            {
                // Act Insert
                var insertResult = repository.InsertAsync(entity);
                var id           = insertResult.Result;

                // Act Query
                var queryResult = repository.QueryAsync <BytesMapClass>(e => e.SessionId == (Guid)id);
                var data        = queryResult.Result.FirstOrDefault();

                // Assert
                Assert.IsNotNull(data);
                Assert.IsNull(data.ColumnBinaryMapped);
                Assert.IsNull(data.ColumnImageMapped);
                Assert.IsNull(data.ColumnTinyIntMapped);
                Assert.IsNull(data.ColumnVarBinaryMapped);
            }
        }
Ejemplo n.º 4
0
        public void TestSqlConnectionBytesMappedCrudAsync()
        {
            // Setup
            var text   = Helper.GetAssemblyDescription();
            var bytes  = Encoding.UTF8.GetBytes(text);
            var entity = new BytesMapClass
            {
                SessionId             = Guid.NewGuid(),
                ColumnBinaryMapped    = bytes,
                ColumnImageMapped     = bytes,
                ColumnVarBinaryMapped = bytes,
                ColumnTinyIntMapped   = 128
            };

            using (var connection = new SqlConnection(Database.ConnectionStringForRepoDb))
            {
                // Act Insert
                var insertResult = connection.InsertAsync(entity);
                var id           = insertResult.Result;

                // Act Query
                var queryResult = connection.QueryAsync <BytesMapClass>(e => e.SessionId == (Guid)id);
                var data        = queryResult.Result.FirstOrDefault();

                // Assert
                Assert.IsNotNull(data);
                Assert.AreEqual(text, Encoding.UTF8.GetString(data.ColumnBinaryMapped.Take(entity.ColumnBinaryMapped.Length).ToArray()));
                Assert.AreEqual(text, Encoding.UTF8.GetString(data.ColumnImageMapped));
                Assert.AreEqual(text, Encoding.UTF8.GetString(data.ColumnVarBinaryMapped));
                Assert.AreEqual(entity.ColumnTinyIntMapped, data.ColumnTinyIntMapped);
            }
        }