private static void InitializeMockedField(object target, FieldInfo mockField, MockAttribute mockAttribute) { var fieldType = mockField.FieldType; var mock = NMockitoStatic.CreateMock(fieldType, mockAttribute.Tracked); mockField.SetValue(target, mock); var staticType = mockAttribute.StaticType; if (staticType != null) { var staticFields = staticType.GetFields(BindingFlags.NonPublic | BindingFlags.Static); var staticInstanceFields = staticFields.Where(field => field.Name.EndsWith("instance") && field.FieldType == fieldType).ToArray(); if (staticInstanceFields.Length != 1) { throw new AmbiguousMatchException("NMockito unable to determine instance field of static " + staticType.FullName + " candidates " + string.Join(", ", staticInstanceFields.Select(f => f.Name).ToArray())); } else { staticInstanceFields.First().SetValue(null, mock); } } }
[DebuggerHidden] public T CreateRef <T>() where T : class { return(NMockitoStatic.CreateRef <T>()); }
[DebuggerHidden] public object CreateUntrackedMock(Type type) { return(NMockitoStatic.CreateUntrackedMock(type)); }
[DebuggerHidden] public void ClearInteractions <T>(T mock) { NMockitoStatic.ClearInteractions(mock); }
[DebuggerHidden] public void VerifyNoMoreInteractions <T>(T mock) { NMockitoStatic.VerifyNoMoreInteractions(mock); }
[DebuggerHidden] public WhenContext <T> When <T>(T value) { return(NMockitoStatic.When(value)); }
[DebuggerHidden] public INMockitoTimesMatcher Once() { return(NMockitoStatic.Once()); }
[DebuggerHidden] public INMockitoTimesMatcher Times(int count) { return(NMockitoStatic.Times(count)); }
[DebuggerHidden] public void AssertThrows <TException>(Action action) where TException : Exception { NMockitoStatic.AssertThrows <TException>(action); }
[DebuggerHidden] public void AssertFalse(bool value) { NMockitoStatic.AssertFalse(value); }
[DebuggerHidden] public void AssertNotNull <T>(T value) { NMockitoStatic.AssertNotNull(value); }
[DebuggerHidden] public void AssertNotEquals <T>(T expected, T actual) { NMockitoStatic.AssertNotEquals(expected, actual); }
public NMockitoInstance() { NMockitoStatic.ReinitializeMocks(this); }
[DebuggerHidden] public void ClearInteractions <T>(T mock, int expectedCount) { NMockitoStatic.ClearInteractions(mock, expectedCount); }
[DebuggerHidden] public T CreatePlaceholder <T>() { return(NMockitoStatic.CreatePlaceholder <T>()); }
[DebuggerHidden] public INMockitoTimesMatcher AnyOrNoneTimes() { return(NMockitoStatic.AnyOrNoneTimes()); }
[DebuggerHidden] public NMockitoOrder DontCare() { return(NMockitoStatic.DontCare()); }
[DebuggerHidden] public INMockitoTimesMatcher Never() { return(NMockitoStatic.Never()); }
[DebuggerHidden] public NMockitoOrder WithPrevious() { return(NMockitoStatic.WithPrevious()); }
[DebuggerHidden] public WhenContext <object> When(Expression <Action> expression) { return(NMockitoStatic.When(expression)); }
[DebuggerHidden] public NMockitoOrder AfterPrevious() { return(NMockitoStatic.AfterPrevious()); }
[DebuggerHidden] public T Verify <T>(T mock, INMockitoTimesMatcher times = null, NMockitoOrder order = NMockitoOrder.DontCare) where T : class { return(NMockitoStatic.Verify(mock, times, order)); }
[DebuggerHidden] public NMockitoOrder Whenever() { return(NMockitoStatic.Whenever()); }
[DebuggerHidden] public void ClearInteractions() { NMockitoStatic.ClearInteractions(); }
[DebuggerHidden] public T CreateUntrackedMock <T>() where T : class { return(NMockitoStatic.CreateUntrackedMock <T>()); }