Exemplo n.º 1
0
        public async Task GetReceivedMessageAsync_Test()
        {
            var sql             = $@"
        INSERT INTO ""cap"".""received""(""Id"",""Version"",""Name"",""Group"",""Content"",""Retries"",""Added"",""ExpiresAt"",""StatusName"")
        VALUES(@Id,'v1',@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);";
            var insertedId      = SnowflakeId.Default().NextId();
            var receivedMessage = new CapReceivedMessage
            {
                Id         = insertedId,
                Name       = "PostgreSqlStorageConnectionTest",
                Content    = "",
                Group      = "mygroup",
                StatusName = StatusName.Scheduled
            };

            using (var connection = ConnectionUtil.CreateConnection())
            {
                await connection.ExecuteAsync(sql, receivedMessage);
            }

            var message = await _storage.GetReceivedMessageAsync(insertedId);

            Assert.NotNull(message);
            Assert.Equal(StatusName.Scheduled, message.StatusName);
            Assert.Equal("PostgreSqlStorageConnectionTest", message.Name);
            Assert.Equal("mygroup", message.Group);
        }
Exemplo n.º 2
0
        public async Task GetReceivedMessageAsync_Test()
        {
            var sql             = $@"
        INSERT INTO ""cap"".""received""(""Name"",""Group"",""Content"",""Retries"",""Added"",""ExpiresAt"",""StatusName"")
        VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName) RETURNING ""Id"";";
            var receivedMessage = new CapReceivedMessage
            {
                Name       = "PostgreSqlStorageConnectionTest",
                Content    = "",
                Group      = "mygroup",
                StatusName = StatusName.Scheduled
            };
            var insertedId = default(int);

            using (var connection = ConnectionUtil.CreateConnection())
            {
                insertedId = connection.QueryFirst <int>(sql, receivedMessage);
            }

            var message = await _storage.GetReceivedMessageAsync(insertedId);

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