Exemple #1
0
        public static void ShouldBeTraceEnterInto(this MockCallInfo mock, string methodFullName, params string[] parameters)
        {
            var split = methodFullName.Split(new [] { "::" }, StringSplitOptions.RemoveEmptyEntries);

            mock.LoggerName.Should().Be(split[0]);
            mock.ContainingMethod.Should().Contain(split[1]);
            mock.CallType.Should().Be(MockCallInfo.MockCallType.TraceEnter);
            if (parameters != null && parameters.Length > 0)
            {
                if (mock.ParamNames == null)
                {
                    throw new Exception(String.Format("No parameters in call"));
                }
                for (int idx = 0; idx < parameters.Length; idx++)
                {
                    int mockIdx = idx / 2;
                    if (mock.ParamNames.Length <= mockIdx)
                    {
                        throw new Exception(String.Format("Too many parameters in expected. We have only {0}.", mock.ParamNames.Length));
                    }
                    if (idx % 2 == 0)
                    {
                        mock.ParamNames[mockIdx].Should().Be(parameters[idx]);
                    }
                    else
                    {
                        mock.ParamValues[mockIdx].Should().Be(parameters[idx]);
                    }
                }
            }
        }
Exemple #2
0
 public static void ShouldBeTraceLeaveFrom(this MockCallInfo mock, string methodFullName)
 {
     string[] split = methodFullName.Split(new[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
     mock.LoggerName.Should().Be(split[0]);
     mock.ContainingMethod.Should().Contain(split[1]);
     mock.CallType.Should().Be(MockCallInfo.MockCallType.TraceLeave);
 }
Exemple #3
0
        public static void ShouldBeTraceLeaveFrom(this MockCallInfo mock, string methodFullName)
        {
            var split = methodFullName.Split(new[] { "::" }, StringSplitOptions.RemoveEmptyEntries);

            mock.LoggerName.Should().Be(split[0]);
            mock.ContainingMethod.Should().Contain(split[1]);
            mock.CallType.Should().Be(MockCallInfo.MockCallType.TraceLeave);
            if (!(mock.ParamValues == null || mock.ParamValues.Length == 0 || mock.ParamNames[0] != null))
            {
                throw new Exception("There's a return value");
            }
        }
Exemple #4
0
 public static void ShouldBeLogCall(this MockCallInfo mock, string methodFullName, string logMethodName,
                                    params string[] values)
 {
     string[] split = methodFullName.Split(new[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
     mock.LoggerName.Should().Be(split[0]);
     mock.ContainingMethod.Should().Contain(split[1]);
     mock.CallType.Should().Be(MockCallInfo.MockCallType.Log);
     mock.LogMethod.Should().Be(logMethodName);
     if (values != null && values.Length > 0)
     {
         for (int idx = 0; idx < values.Length; idx++)
         {
             mock.ParamValues[idx].Should().Be(values[idx]);
         }
     }
 }
Exemple #5
0
        public static void ShouldBeTraceLeaveWithOutsFrom(this MockCallInfo mock, string methodFullName, params string[] parameters)
        {
            var split = methodFullName.Split(new[] { "::" }, StringSplitOptions.RemoveEmptyEntries);

            mock.LoggerName.Should().Be(split[0]);
            mock.ContainingMethod.Should().Contain(split[1]);
            mock.CallType.Should().Be(MockCallInfo.MockCallType.TraceLeave);

            var mockIdxCorrection = 0;

            //check if the first one is a return value
            if (mock.ParamNames != null && mock.ParamNames.Length > 0 && mock.ParamNames[0] == null)
            {
                //if so step over it
                mockIdxCorrection = 1;
            }

            if (parameters != null && parameters.Length > 0)
            {
                if (mock.ParamNames == null)
                {
                    throw new Exception(String.Format("No out parameters in call"));
                }
                for (int idx = 0; idx < parameters.Length; idx++)
                {
                    int mockIdx = idx / 2 + mockIdxCorrection;
                    if (mock.ParamNames.Length <= mockIdx)
                    {
                        throw new Exception(String.Format("Too many parameters in expected. We have only {0}.", mock.ParamNames.Length));
                    }
                    if (idx % 2 == 0)
                    {
                        mock.ParamNames[mockIdx].Should().Be(parameters[idx]);
                    }
                    else
                    {
                        mock.ParamValues[mockIdx].Should().Be(parameters[idx]);
                    }
                }
            }
        }
 public static void LogPropertyCalled(string loggerName, string logPropertyCalled)
 {
     Calls.Add(MockCallInfo.CreatePropertyAccess(loggerName, logPropertyCalled));
 }
 public static void LogCalled(string loggerName, string containingMethod, string logMethodCalled,
                              string[] paramValues = null)
 {
     Calls.Add(MockCallInfo.CreateLog(loggerName, containingMethod, logMethodCalled, paramValues));
 }
 public static void TraceLeaveCalled(string loggerName, string containingMethod, long numberOfTicks, string[] paramNames, string[] paramValues, Tuple <string, string>[] configParameters)
 {
     Calls.Add(MockCallInfo.CreateLeave(loggerName, containingMethod, numberOfTicks, paramNames, paramValues, configParameters));
 }
 public static void TraceEnterCalled(string loggerName, string containingMethod, string[] paramNames, string[] paramValues, Tuple <string, string>[] configParameters)
 {
     Calls.Add(MockCallInfo.CreateEnter(loggerName, containingMethod, paramNames, paramValues, configParameters));
 }
Exemple #10
0
 public static void ShouldBeLogProperty(this MockCallInfo mock, string loggerName, string propertyName)
 {
     mock.CallType.Should().Be(MockCallInfo.MockCallType.PropertyAccess);
     mock.LoggerName.Should().Be(loggerName);
     mock.LogMethod.Should().Contain(propertyName);
 }