コード例 #1
0
        public void TestBaseRepositoryStringsMappedNullCrudAsync()
        {
            // Setup
            var entity = new StringsMapClass
            {
                SessionId            = Guid.NewGuid(),
                ColumnCharMapped     = null,
                ColumnNCharMapped    = null,
                ColumnNTextMapped    = null,
                ColumnNVarCharMapped = null,
                ColumnTextMapped     = null,
                ColumnVarCharMapped  = null
            };

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

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

                // Assert
                Assert.IsNotNull(data);
                Assert.IsNull(data.ColumnCharMapped);
                Assert.IsNull(data.ColumnNCharMapped);
                Assert.IsNull(data.ColumnNTextMapped);
                Assert.IsNull(data.ColumnNVarCharMapped);
                Assert.IsNull(data.ColumnTextMapped);
                Assert.IsNull(data.ColumnVarCharMapped);
            }
        }
コード例 #2
0
        public void TestBaseRepositoryStringsMappedCrudAsync()
        {
            // Setup
            var text   = Helper.GetUnicodeString();
            var entity = new StringsMapClass
            {
                SessionId            = Guid.NewGuid(),
                ColumnCharMapped     = text,
                ColumnNCharMapped    = text,
                ColumnNTextMapped    = text,
                ColumnNVarCharMapped = text,
                ColumnTextMapped     = text,
                ColumnVarCharMapped  = text
            };

            using (var repository = new StringsMapClassRepository(Database.ConnectionStringForRepoDb))
            {
                // Act Insert
                var insertResult = repository.InsertAsync(entity);
                var id           = insertResult.Result.Extract();

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

                // Assert
                Assert.IsNotNull(data);
                Assert.AreEqual(entity.ColumnCharMapped, data.ColumnCharMapped.Trim());
                Assert.AreEqual(entity.ColumnNCharMapped, data.ColumnNCharMapped.Trim());
                Assert.AreEqual(entity.ColumnNTextMapped, data.ColumnNTextMapped);
                Assert.AreEqual(entity.ColumnNVarCharMapped, data.ColumnNVarCharMapped);
                Assert.AreEqual(entity.ColumnTextMapped, data.ColumnTextMapped);
                Assert.AreEqual(entity.ColumnVarCharMapped, data.ColumnVarCharMapped);
            }
        }