0

Below is my test:

   [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);

    }

This is the method being tested:

  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);
                    }
                });
            }

Each model is being called with the void Update() method. Is there a way to verify this behavior? To verify the method had been called? Something equivalent to Expect() and verifyAllExpectations() in Rhino mocks?


I found a workaround solution in the following post.

Community
  • 1
  • 1
Ori Price
  • 3,593
  • 2
  • 22
  • 37

0 Answers0