Ejemplo n.º 1
0
        public void FileCheck_ActionFileInfo_FailsCheck()
        {
            var mockSocket = Substitute.For <ISymSocket>();

            mockSocket.ReadCommand()
            .Returns(
                new SymCommand("Check", new Dictionary <string, string> {
                { "Action", "Init" }
            }),
                new SymCommand("Check", new Dictionary <string, string> {
                { "Action", "Init" }
            }),
                new SymCommand("Check", new Dictionary <string, string> {
                { "Action", "Init" }
            }),
                new SymCommand("Check", new Dictionary <string, string> {
                { "Action", "Init" }
            }),
                new SymCommand("Check", new Dictionary <string, string> {
                { "Action", "FileInfo" }, { "Line", "22" }, { "Col", "1" }
            }),
                new SymCommand("Check", new Dictionary <string, string> {
                { "Action", "DisplayEdit" }
            })
                );

            var            file    = new File("symitar", "10", "FILE.TO.CHECK", FileType.RepGen, DateTime.Now, 110);
            var            session = new SymSession(mockSocket, 10);
            SpecfileResult result  = session.FileCheck(file);

            result.PassedCheck.Should().BeFalse();
        }
Ejemplo n.º 2
0
        public void FileCheck_LetterFile_ThrowsException()
        {
            var mockSocket = Substitute.For<ISymSocket>();

            var file = new File("symitar", "10", "FILE.TO.CHECK", FileType.Letter, DateTime.Now, 110);
            var session = new SymSession(mockSocket, 10);
            Assert.Throws<Exception>(() => session.FileCheck(file));
        }
Ejemplo n.º 3
0
        public void FileCheck_LetterFile_ThrowsException()
        {
            var mockSocket = Substitute.For <ISymSocket>();

            var file    = new File("symitar", "10", "FILE.TO.CHECK", FileType.Letter, DateTime.Now, 110);
            var session = new SymSession(mockSocket, 10);

            Assert.Throws <Exception>(() => session.FileCheck(file));
        }
Ejemplo n.º 4
0
        public void FileCheck_CommandHasWarning_ThrowsFileNotFoundException()
        {
            var mockSocket = Substitute.For<ISymSocket>();
            mockSocket.ReadCommand()
                      .Returns(new SymCommand("Check", new Dictionary<string, string> {{"Warning", ""}}));

            var file = new File("symitar", "10", "FILE.TO.CHECK", FileType.RepGen, DateTime.Now, 110);
            var session = new SymSession(mockSocket, 10);
            Assert.Throws<FileNotFoundException>(() => session.FileCheck(file));
        }
Ejemplo n.º 5
0
        public void FileCheck_ActionNoError_PassesCheck()
        {
            var mockSocket = Substitute.For<ISymSocket>();
            mockSocket.ReadCommand()
                      .Returns(new SymCommand("Check", new Dictionary<string, string> {{"Action", "NoError"}}));

            var file = new File("symitar", "10", "FILE.TO.CHECK", FileType.RepGen, DateTime.Now, 110);
            var session = new SymSession(mockSocket, 10);
            SpecfileResult result = session.FileCheck(file);

            result.PassedCheck.Should().BeTrue();
        }
Ejemplo n.º 6
0
        public void FileCheck_CommandHasWarning_ThrowsFileNotFoundException()
        {
            var mockSocket = Substitute.For <ISymSocket>();

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

            var file    = new File("symitar", "10", "FILE.TO.CHECK", FileType.RepGen, DateTime.Now, 110);
            var session = new SymSession(mockSocket, 10);

            Assert.Throws <FileNotFoundException>(() => session.FileCheck(file));
        }
Ejemplo n.º 7
0
        public void FileCheck_UnknownCommands_ThrowsException()
        {
            var mockSocket = Substitute.For <ISymSocket>();

            mockSocket.ReadCommand()
            .Returns(new SymCommand("Check", new Dictionary <string, string> {
                { "Action", "Random" }
            }));

            var file    = new File("symitar", "10", "FILE.TO.CHECK", FileType.RepGen, DateTime.Now, 110);
            var session = new SymSession(mockSocket, 10);

            Assert.Throws <Exception>(() => session.FileCheck(file), "An unknown error occurred.");
        }
Ejemplo n.º 8
0
        public void FileCheck_ActionNoError_PassesCheck()
        {
            var mockSocket = Substitute.For <ISymSocket>();

            mockSocket.ReadCommand()
            .Returns(new SymCommand("Check", new Dictionary <string, string> {
                { "Action", "NoError" }
            }));

            var            file    = new File("symitar", "10", "FILE.TO.CHECK", FileType.RepGen, DateTime.Now, 110);
            var            session = new SymSession(mockSocket, 10);
            SpecfileResult result  = session.FileCheck(file);

            result.PassedCheck.Should().BeTrue();
        }
Ejemplo n.º 9
0
        public void FileCheck_ActionFileInfo_FailsCheck()
        {
            var mockSocket = Substitute.For<ISymSocket>();
            mockSocket.ReadCommand()
                      .Returns(
                        new SymCommand("Check", new Dictionary<string, string> {{"Action", "Init"}}),
                        new SymCommand("Check", new Dictionary<string, string> {{"Action", "Init"}}),
                        new SymCommand("Check", new Dictionary<string, string> {{"Action", "Init"}}),
                        new SymCommand("Check", new Dictionary<string, string> {{"Action", "Init"}}),
                        new SymCommand("Check", new Dictionary<string, string> {{"Action", "FileInfo"},{"Line", "22"},{"Col", "1"}}),
                        new SymCommand("Check", new Dictionary<string, string> {{"Action", "DisplayEdit"}})
                        );

            var file = new File("symitar", "10", "FILE.TO.CHECK", FileType.RepGen, DateTime.Now, 110);
            var session = new SymSession(mockSocket, 10);
            SpecfileResult result = session.FileCheck(file);

            result.PassedCheck.Should().BeFalse();
        }
Ejemplo n.º 10
0
        public void FileCheck_UnknownCommands_ThrowsException()
        {
            var mockSocket = Substitute.For<ISymSocket>();
            mockSocket.ReadCommand()
                      .Returns(new SymCommand("Check", new Dictionary<string, string> {{"Action", "Random"}}));

            var file = new File("symitar", "10", "FILE.TO.CHECK", FileType.RepGen, DateTime.Now, 110);
            var session = new SymSession(mockSocket, 10);

            Assert.Throws<Exception>(() => session.FileCheck(file), "An unknown error occurred.");
        }