CodeSnippet/RabbitMQTests/MQPubSubTests.cs

(开头部分) 16KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

namespace CodeSnippet.RabbitMQTests
{
    using global::RabbitMQ.Client;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using RabbitMQ.Client.Events;

    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Text;
    using System.Threading;

    /// <summary>
    /// 使用RabbitMQClient
    /// </summary>
    /// <seealso cref="CodeSnippet.RabbitMQ.TestBase" />
    [TestCategory("RebbitMQ-Client")]
    [TestClass()]
    public class MQPubSubTests
    {
        private static readonly string queueName = $"test.pubsub.ut.queue";
        private static ConnectionFactory factory;
        private static IConnection connection;
        private static IModel channel;

        private static TestContext _testContext;
        private static readonly Stopwatch sw = new();

        [ClassInitialize]
        public static void ClassInit(TestContext testContext)
        {
            _testContext = testContext;

            factory = new ConnectionFactory()
            {
                HostName = "192.168.248.191",
                // 用户名
                UserName = "guest",
                // 密码
                Password = "guest",
                // 网络故障自动恢复连接
                AutomaticRecoveryEnabled = true,
                // 心跳处理
                RequestedHeartbeat = new TimeSpan(5000)
            };


        }

        [TestInitialize]
        public void TestCaseInit()
        {
            Console.WriteLine($"TestName: {_testContext.TestName}");
            connection = factory.CreateConnection();
            channel = connection.CreateModel();
            sw.Restart();
        }

后面还有 396 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。