17、微服务测试编写指南

微服务测试编写指南

1. 为微服务端点注入模拟对象

在测试 UserModule 的端点后,我们将转向对忠诚度计划事件源的测试。事件源是一个 Nancy 模块,它依赖于 IEventStore 来存储和读取事件。以下是 IEventStore 接口的定义:

using System.Collections.Generic;
namespace LoyaltyProgram.EventFeed
{
    public interface IEventStore
    {
        IEnumerable<Event> GetEvents(
            long firstEventSequenceNumber,
            long lastEventSequenceNumber);
        void Raise(string eventName, object content);
    }
}

事件源模块的代码如下:

namespace LoyaltyProgram.EventFeed
{
    using Nancy;
    public class EventsFeedModule : NancyModule
    {
        public EventsFeedModule(IEventStore eventStore) : ba
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值