public void FileInstall_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);

            session.FileInstall(file).PassedCheck.Should().BeFalse();
        }
        public void FileInstall_SpecfileData_PassesCheck()
        {
            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("SpecfileData", new Dictionary <string, string> {
                { "Size", "110" }
            })
                );

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

            session.FileInstall(file).PassedCheck.Should().BeTrue();
        }
        public void FileInstall_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.FileInstall(file));
        }
        public void FileInstall_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.FileInstall(file));
        }
Exemple #5
0
        private void FileInstallTest(string fileName)
        {
            try
            {
                var file = new File {
                    Name = fileName, Type = FileType.RepGen
                };
                SpecfileResult result = _session.FileInstall(file);
                LogResponse(_session.Log.Aggregate((a, b) => a + "\n" + b));

                LogResponse(result.PassedCheck);
                LogResponse(result.FileWithError);
                LogResponse(result.ErrorMessage);
            }
            catch (Exception ex)
            {
                LogResponse(_session.Log.Aggregate((a, b) => a + "\n" + b));
                LogResponse(ex.Message);
            }
            finally
            {
                _session.Log.Clear();
            }
        }
        public void FileInstall_SpecfileData_PassesCheck()
        {
            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("SpecfileData", new Dictionary<string, string> { { "Size", "110" } })
                );

            var file = new File("symitar", "10", "FILE.TO.CHECK", FileType.RepGen, DateTime.Now, 110);
            var session = new SymSession(mockSocket, 10);
            session.FileInstall(file).PassedCheck.Should().BeTrue();
        }
        public void FileInstall_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.FileInstall(file));
        }
        public void FileInstall_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.FileInstall(file));
        }
        public void FileInstall_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);
            session.FileInstall(file).PassedCheck.Should().BeFalse();
        }