Ejemplo n.º 1
0
        public async Task GetPublishedMessageAsync_Test()
        {
            var sql            = @"INSERT INTO ""cap"".""published""(""Name"",""Content"",""Retries"",""Added"",""ExpiresAt"",""StatusName"") VALUES(@Name,@Content,@Retries,@Added,@ExpiresAt,@StatusName) RETURNING ""Id"";";
            var publishMessage = new CapPublishedMessage
            {
                Name       = "PostgreSqlStorageConnectionTest",
                Content    = "",
                StatusName = StatusName.Scheduled
            };
            var insertedId = default(int);

            using (var connection = ConnectionUtil.CreateConnection())
            {
                insertedId = connection.QueryFirst <int>(sql, publishMessage);
            }
            var message = await _storage.GetPublishedMessageAsync(insertedId);

            Assert.NotNull(message);
            Assert.Equal("PostgreSqlStorageConnectionTest", message.Name);
            Assert.Equal(StatusName.Scheduled, message.StatusName);
        }
Ejemplo n.º 2
0
        public async Task GetPublishedMessageAsync_Test()
        {
            var sql            = @"INSERT INTO ""cap"".""published""(""Id"",""Version"",""Name"",""Content"",""Retries"",""Added"",""ExpiresAt"",""StatusName"") VALUES(@Id,'v1',@Name,@Content,@Retries,@Added,@ExpiresAt,@StatusName);";
            var insertedId     = SnowflakeId.Default().NextId();
            var publishMessage = new CapPublishedMessage
            {
                Id         = insertedId,
                Name       = "PostgreSqlStorageConnectionTest",
                Content    = "",
                StatusName = StatusName.Scheduled
            };

            using (var connection = ConnectionUtil.CreateConnection())
            {
                await connection.ExecuteAsync(sql, publishMessage);
            }
            var message = await _storage.GetPublishedMessageAsync(insertedId);

            Assert.NotNull(message);
            Assert.Equal("PostgreSqlStorageConnectionTest", message.Name);
            Assert.Equal(StatusName.Scheduled, message.StatusName);
        }