@@ -33,5 +33,53 @@ public async Task Should_Be_Able_To_Get_Message()
33
33
TestChannel . ExchangeDelete ( exchangeName ) ;
34
34
}
35
35
}
36
+
37
+ [ Fact ]
38
+ public async Task Should_Be_Able_To_Get_BasicGetResult_Message ( )
39
+ {
40
+ using ( var client = RawRabbitFactory . CreateTestClient ( ) )
41
+ {
42
+ /* Setup */
43
+ var message = new BasicMessage { Prop = "Get me, get it?" } ;
44
+ var conventions = new NamingConventions ( ) ;
45
+ var exchangeName = conventions . ExchangeNamingConvention ( message . GetType ( ) ) ;
46
+ var queueName = conventions . QueueNamingConvention ( message . GetType ( ) ) ;
47
+ TestChannel . QueueDeclare ( queueName , true , false , false , null ) ;
48
+ TestChannel . ExchangeDeclare ( exchangeName , ExchangeType . Topic ) ;
49
+ TestChannel . QueueBind ( queueName , exchangeName , conventions . RoutingKeyConvention ( message . GetType ( ) ) + ".#" ) ;
50
+
51
+ await client . PublishAsync ( message , ctx => ctx . UsePublishConfiguration ( cfg => cfg . OnExchange ( exchangeName ) ) ) ;
52
+
53
+ /* Test */
54
+ var ackable = await client . GetAsync ( cfg => cfg . FromQueue ( queueName ) ) ;
55
+
56
+ /* Assert */
57
+ Assert . NotNull ( ackable ) ;
58
+ Assert . NotEmpty ( ackable . Content . Body ) ;
59
+ TestChannel . QueueDelete ( queueName ) ;
60
+ TestChannel . ExchangeDelete ( exchangeName ) ;
61
+ }
62
+ }
63
+
64
+ [ Fact ]
65
+ public async Task Should_Be_Able_To_Get_BasicGetResult_When_Queue_IsEmpty ( )
66
+ {
67
+ using ( var client = RawRabbitFactory . CreateTestClient ( ) )
68
+ {
69
+ /* Setup */
70
+ var message = new BasicMessage ( ) ;
71
+ var conventions = new NamingConventions ( ) ;
72
+ var queueName = conventions . QueueNamingConvention ( message . GetType ( ) ) ;
73
+ TestChannel . QueueDeclare ( queueName , true , false , false , null ) ;
74
+
75
+ /* Test */
76
+ var ackable = await client . GetAsync ( cfg => cfg . FromQueue ( queueName ) ) ;
77
+
78
+ /* Assert */
79
+ Assert . NotNull ( ackable ) ;
80
+ Assert . Null ( ackable . Content ) ;
81
+ TestChannel . QueueDelete ( queueName ) ;
82
+ }
83
+ }
36
84
}
37
85
}
0 commit comments