Пример #1
0
        public void RemoveStoredErrorLogFile()
        {
            var file          = Mock.Of <File>();
            var expectedFiles = new List <File> {
                file
            };
            var id            = Guid.NewGuid();
            var mockDirectory = Mock.Of <Directory>();

            ErrorLogHelper.Instance._crashesDirectory = mockDirectory;
            Mock.Get(mockDirectory).Setup(d => d.EnumerateFiles($"{id}.json")).Returns(expectedFiles);
            ErrorLogHelper.RemoveStoredErrorLogFile(id);
            Mock.Get(file).Verify(f => f.Delete());
        }
Пример #2
0
        public void RemoveStoredErrorLogFileDoesNotThrow(Type exceptionType)
        {
            // Use reflection to create an exception of the given C# type.
            var exception = exceptionType.GetConstructor(Type.EmptyTypes).Invoke(null) as System.Exception;
            var file      = Mock.Of <File>();

            Mock.Get(file).Setup(f => f.Delete()).Throws(exception);
            var expectedFiles = new List <File> {
                file
            };
            var id            = Guid.NewGuid();
            var mockDirectory = Mock.Of <Directory>();

            ErrorLogHelper.Instance._crashesDirectory = mockDirectory;
            Mock.Get(mockDirectory).Setup(d => d.EnumerateFiles($"{id}.json")).Returns(expectedFiles);
            ErrorLogHelper.RemoveStoredErrorLogFile(id);
            Mock.Get(file).Verify(f => f.Delete());
            ErrorLogHelper.RemoveStoredErrorLogFile(id);

            // No exception should be thrown.
        }