コード例 #1
0
        public void MockFileSystem_AddDirectory_ShouldThrowExceptionForUnmappedParentDirectories()
        {
            // Arrange
            var fileSystem = new MockFileSystem();

            fileSystem.AddForbiddenDirectory(@"D:\forbidden");

            // Act
            try
            {
                fileSystem.AddDirectory(@"D:\file");
            }
            catch (Exception e)
            {
                Assert.Fail("The first directory should have been added without throwing an exception.");
            }
            fileSystem.AddDirectory(@"D:\forbidden\ohno");

            // Assert - expect an exception
        }
コード例 #2
0
        public void MockFileSystem_AddFile_ShouldThrowExceptionForUnmappedParentDirectories()
        {
            // Arrange
            var fileSystem = new MockFileSystem();

            fileSystem.AddForbiddenDirectory(@"C:\forbidden");

            // Act
            try
            {
                fileSystem.AddFile(@"C:\file.txt", "foo");
            }
            catch (Exception e)
            {
                Assert.Fail("The first file should have been added without throwing an exception.");
            }
            fileSystem.AddFile(@"C:\FORBIDDEN\thisWillBreak.txt", "foo");

            // Assert - expect an exception
        }