コード例 #1
0
        public void DebugMethodTest()
        {
            LogDTO mock = new LogDTO()
            {
                Module = "LoggerServiceTest", Function = "MethodTest", Message = "Test message"
            };

            _sut.Debug(mock);

            _mockLogger.Received(1).Debug(Arg.Is <string>(s => s.Contains(mock.Module) && s.Contains(mock.Function) && s.Contains(mock.Message) && s.Contains("127.0.0.1")));
        }
コード例 #2
0
        public void FindEmployeesMethodTest_Error()
        {
            _mockRepo.When(x => x.Find(Arg.Any <Func <Employee, bool> >())).Do(x => { throw new Exception("Test Exception"); });

            IEnumerable <Employee> result = _sut.FindEmployees("", "", "", "");

            Assert.IsNull(result);

            _mockLogger.Received(1).ErrorMethod(Arg.Any <Exception>(), Arg.Any <MethodBase>());
            _mockLogger.Received(1).TraceMethodResult(Arg.Any <MethodBase>(), HttpStatusCode.InternalServerError);
        }