예제 #1
0
        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);
                }
            }
        }
예제 #2
0
 [DebuggerHidden] public T CreateRef <T>() where T : class
 {
     return(NMockitoStatic.CreateRef <T>());
 }
예제 #3
0
 [DebuggerHidden] public object CreateUntrackedMock(Type type)
 {
     return(NMockitoStatic.CreateUntrackedMock(type));
 }
예제 #4
0
 [DebuggerHidden] public void ClearInteractions <T>(T mock)
 {
     NMockitoStatic.ClearInteractions(mock);
 }
예제 #5
0
 [DebuggerHidden] public void VerifyNoMoreInteractions <T>(T mock)
 {
     NMockitoStatic.VerifyNoMoreInteractions(mock);
 }
예제 #6
0
 [DebuggerHidden] public WhenContext <T> When <T>(T value)
 {
     return(NMockitoStatic.When(value));
 }
예제 #7
0
 [DebuggerHidden] public INMockitoTimesMatcher Once()
 {
     return(NMockitoStatic.Once());
 }
예제 #8
0
 [DebuggerHidden] public INMockitoTimesMatcher Times(int count)
 {
     return(NMockitoStatic.Times(count));
 }
예제 #9
0
 [DebuggerHidden] public void AssertThrows <TException>(Action action) where TException : Exception
 {
     NMockitoStatic.AssertThrows <TException>(action);
 }
예제 #10
0
 [DebuggerHidden] public void AssertFalse(bool value)
 {
     NMockitoStatic.AssertFalse(value);
 }
예제 #11
0
 [DebuggerHidden] public void AssertNotNull <T>(T value)
 {
     NMockitoStatic.AssertNotNull(value);
 }
예제 #12
0
 [DebuggerHidden] public void AssertNotEquals <T>(T expected, T actual)
 {
     NMockitoStatic.AssertNotEquals(expected, actual);
 }
예제 #13
0
 public NMockitoInstance()
 {
     NMockitoStatic.ReinitializeMocks(this);
 }
예제 #14
0
 [DebuggerHidden] public void ClearInteractions <T>(T mock, int expectedCount)
 {
     NMockitoStatic.ClearInteractions(mock, expectedCount);
 }
예제 #15
0
 [DebuggerHidden] public T CreatePlaceholder <T>()
 {
     return(NMockitoStatic.CreatePlaceholder <T>());
 }
예제 #16
0
 [DebuggerHidden] public INMockitoTimesMatcher AnyOrNoneTimes()
 {
     return(NMockitoStatic.AnyOrNoneTimes());
 }
예제 #17
0
 [DebuggerHidden] public NMockitoOrder DontCare()
 {
     return(NMockitoStatic.DontCare());
 }
예제 #18
0
 [DebuggerHidden] public INMockitoTimesMatcher Never()
 {
     return(NMockitoStatic.Never());
 }
예제 #19
0
 [DebuggerHidden] public NMockitoOrder WithPrevious()
 {
     return(NMockitoStatic.WithPrevious());
 }
예제 #20
0
 [DebuggerHidden] public WhenContext <object> When(Expression <Action> expression)
 {
     return(NMockitoStatic.When(expression));
 }
예제 #21
0
 [DebuggerHidden] public NMockitoOrder AfterPrevious()
 {
     return(NMockitoStatic.AfterPrevious());
 }
예제 #22
0
 [DebuggerHidden] public T Verify <T>(T mock, INMockitoTimesMatcher times = null, NMockitoOrder order = NMockitoOrder.DontCare) where T : class
 {
     return(NMockitoStatic.Verify(mock, times, order));
 }
예제 #23
0
 [DebuggerHidden] public NMockitoOrder Whenever()
 {
     return(NMockitoStatic.Whenever());
 }
예제 #24
0
 [DebuggerHidden] public void ClearInteractions()
 {
     NMockitoStatic.ClearInteractions();
 }
예제 #25
0
 [DebuggerHidden] public T CreateUntrackedMock <T>() where T : class
 {
     return(NMockitoStatic.CreateUntrackedMock <T>());
 }