コード例 #1
0
        public void ReadErrorLogFileThrowsException()
        {
            var mockFile = Mock.Of <File>();

            Mock.Get(mockFile).Setup(file => file.ReadAllText()).Throws(new System.IO.IOException());
            Assert.IsNull(ErrorLogHelper.ReadErrorLogFile(mockFile));
        }
コード例 #2
0
        public void ReadErrorLogFile()
        {
            var errorLog = new ManagedErrorLog
            {
                Id        = Guid.NewGuid(),
                ProcessId = 123
            };
            var serializedErrorLog = LogSerializer.Serialize(errorLog);
            var mockFile           = Mock.Of <File>();

            Mock.Get(mockFile).Setup(file => file.ReadAllText()).Returns(serializedErrorLog);
            var actualContents = ErrorLogHelper.ReadErrorLogFile(mockFile);

            Assert.AreEqual(errorLog.Id, actualContents.Id);
            Assert.AreEqual(errorLog.ProcessId, actualContents.ProcessId);
        }