public void SerializeMetricsTest() { MethodInvocation testMethodInvocation = new MethodInvocation("TestMethod", new object[] { "abc", ((int)123), null, ((double)456.789) }); using (mocks.Ordered) { Expect.Once.On(mockMetricLogger).Method("Begin").With(IsMetric.Equal(new MethodInvocationSerializeTime())); Expect.Once.On(mockMetricLogger).Method("End").With(IsMetric.Equal(new MethodInvocationSerializeTime())); Expect.Once.On(mockMetricLogger).Method("Increment").With(IsMetric.Equal(new MethodInvocationSerialized())); Expect.Once.On(mockMetricLogger).Method("Add").With(IsAmountMetric.Equal(new SerializedMethodInvocationSize(381))); } testMethodInvocationSerializer.Serialize(testMethodInvocation); mocks.VerifyAllExpectationsHaveBeenMet(); }
public void SerializeLoggingTest() { MethodInvocation testMethodInvocation = new MethodInvocation("TestMethod", new object[] { "abc", ((int)123), null, ((double)456.789) }); using (mocks.Ordered) { Expect.Once.On(mockApplicationLogger).Method("Log").With(testMethodInvocationSerializer, LogLevel.Debug, "Serialized parameter of type '" + typeof(string).FullName + "'."); Expect.Once.On(mockApplicationLogger).Method("Log").With(testMethodInvocationSerializer, LogLevel.Debug, "Serialized parameter of type '" + typeof(int).FullName + "'."); Expect.Once.On(mockApplicationLogger).Method("Log").With(testMethodInvocationSerializer, LogLevel.Debug, "Serialized null parameter."); Expect.Once.On(mockApplicationLogger).Method("Log").With(testMethodInvocationSerializer, LogLevel.Debug, "Serialized parameter of type '" + typeof(double).FullName + "'."); Expect.Once.On(mockApplicationLogger).Method("Log").With(testMethodInvocationSerializer, LogLevel.Information, "Serialized method invocation to string '<?xml version=\"1.0\" encoding=\"utf-8\"?><MethodInvocation><MethodName>TestMethod</MethodName><Parameters><Parameter><DataT' (truncated)."); Expect.Once.On(mockApplicationLogger).Method("Log").With(testMethodInvocationSerializer, LogLevel.Debug, "Complete string content: '<?xml version=\"1.0\" encoding=\"utf-8\"?><MethodInvocation><MethodName>TestMethod</MethodName><Parameters><Parameter><DataType>string</DataType><Data>abc</Data></Parameter><Parameter><DataType>integer</DataType><Data>123</Data></Parameter><Parameter /><Parameter><DataType>double</DataType><Data>4.5678899999999999e+002</Data></Parameter></Parameters><ReturnType /></MethodInvocation>'."); } testMethodInvocationSerializer.Serialize(testMethodInvocation); mocks.VerifyAllExpectationsHaveBeenMet(); }