示例#1
0
        public void FileRename_NoStatusOrDone_ThrowsException()
        {
            var mockSocket = Substitute.For <ISymSocket>();

            mockSocket.ReadCommand().Returns(new SymCommand("Unknown"));

            var session = new SymSession(mockSocket, 10);

            Assert.Throws <Exception>(() => session.FileRename("OldName", "NewName", FileType.RepGen));
        }
示例#2
0
        public void FileRename_StatusNoSuchFile_ThrowsFileNotFoundException()
        {
            var mockSocket = Substitute.For <ISymSocket>();

            mockSocket.ReadCommand().Returns(new SymCommand("Rename", new Dictionary <string, string> {
                { "Status", "No such file or directory" }
            }));

            var session = new SymSession(mockSocket, 10);

            Assert.Throws <FileNotFoundException>(() => session.FileRename("OldName", "NewName", FileType.RepGen));
        }
示例#3
0
        public void FileRename_StatusUnknown_ThrowsFileNotFoundException()
        {
            var mockSocket = Substitute.For <ISymSocket>();

            mockSocket.ReadCommand().Returns(new SymCommand("Rename", new Dictionary <string, string> {
                { "Status", "" }
            }));

            var session = new SymSession(mockSocket, 10);

            Assert.Throws <Exception>(() => session.FileRename("OldName", "NewName", FileType.RepGen),
                                      "Filename Too Long");
        }
示例#4
0
        public void FileRename_CompletesSuccessfully_NoExceptions()
        {
            var mockSocket = Substitute.For <ISymSocket>();

            mockSocket.ReadCommand()
            .Returns(new SymCommand("Rename", new Dictionary <string, string> {
                { "Done", "" }
            }));

            var session = new SymSession(mockSocket, 10);

            Assert.DoesNotThrow(() => session.FileRename("OldName", "NewName", FileType.RepGen));
        }
示例#5
0
        public void FileRename_StatusUnknown_ThrowsFileNotFoundException()
        {
            var mockSocket = Substitute.For<ISymSocket>();
            mockSocket.ReadCommand().Returns(new SymCommand("Rename", new Dictionary<string, string> {{"Status", ""}}));

            var session = new SymSession(mockSocket, 10);

            Assert.Throws<Exception>(() => session.FileRename("OldName", "NewName", FileType.RepGen),
                                     "Filename Too Long");
        }
示例#6
0
        public void FileRename_StatusNoSuchFile_ThrowsFileNotFoundException()
        {
            var mockSocket = Substitute.For<ISymSocket>();
            mockSocket.ReadCommand().Returns(new SymCommand("Rename", new Dictionary<string, string> {{"Status", "No such file or directory"}}));

            var session = new SymSession(mockSocket, 10);

            Assert.Throws<FileNotFoundException>(() => session.FileRename("OldName", "NewName", FileType.RepGen));
        }
示例#7
0
        public void FileRename_NoStatusOrDone_ThrowsException()
        {
            var mockSocket = Substitute.For<ISymSocket>();
            mockSocket.ReadCommand().Returns(new SymCommand("Unknown"));

            var session = new SymSession(mockSocket, 10);

            Assert.Throws<Exception>(() => session.FileRename("OldName", "NewName", FileType.RepGen));
        }
示例#8
0
        public void FileRename_CompletesSuccessfully_NoExceptions()
        {
            var mockSocket = Substitute.For<ISymSocket>();
            mockSocket.ReadCommand()
                      .Returns(new SymCommand("Rename", new Dictionary<string, string> {{"Done", ""}}));

            var session = new SymSession(mockSocket, 10);

            Assert.DoesNotThrow(() => session.FileRename("OldName", "NewName", FileType.RepGen));
        }