0

下面是我的测试:

   [TestMethod]
    public void GetSubscribers()
    {

        stubSubscriptionMng.GetModelSubscribersInt32String = (mgr, i) => new List<IModel>() { modelStub };
        var dispatcher = UnitySingleton.Instance.UnityContainer.Resolve<Dispatcher>();
        IDispatchingMessage message = new DispatchingMessage(Guid.NewGuid().ToString(), "MessageName", "MessageVal", 1);
        dispatcher.Publish(message);

    }

这是正在测试的方法:

  if (message.UniverseId > 0 && !string.IsNullOrEmpty(message.EntityId) && !string.IsNullOrWhiteSpace(message.MessageName))
            {
                //the modelMgr will forword the the relevant Data to the relevant Models
                IList<IModel> models = subscriptionService.GetModelSubscribers(message.UniverseId, message.MessageName);
                Parallel.ForEach(models, (model) =>
                {
                    try
                    {
                        model.Update(message);
                    }
                    catch (Exception ex)
                    {
                        ResourceManager.Instance.Logger.LogException(ex);
                    }
                });
            }

void Update()使用该方法调用每个模型。有没有办法验证这种行为?验证方法是否被调用?相当于Expect()verifyAllExpectations()Rhino 模拟中的东西?


我在以下帖子中找到了解决方法。

4

0 回答 0