public void TestTrackEvent() { // Shims can be used only in a ShimsContext: using (ShimsContext.Create()) { Mock <MockShimAnalytics> mock = new Mock <MockShimAnalytics>(); mock.Object.InitFake(); mock.Setup(v => v.TrackEvent(It.IsAny <string>(), It.IsAny <IDictionary <string, string> >())); MyApp.Check(); mock.Verify(v => v.TrackEvent(It.IsAny <string>(), It.IsAny <IDictionary <string, string> >()), Times.Once()); } }