public void FileGet_HasOneMatch_ReturnsFile()
        {
            var mockSocket = Substitute.For <ISymSocket>();

            mockSocket.Server.Returns("symitar");
            mockSocket.ReadCommand()
            .Returns(
                new SymCommand("FileList",
                               new Dictionary <string, string>
            {
                { "Name", "RandomFile" },
                { "Date", "01012013" },
                { "Time", "1153" },
                { "Size", "1123" },
            }),
                new SymCommand("FileList", new Dictionary <string, string> {
                { "Done", "" }
            })
                );

            var expected = new File("symitar", "10", "RandomFile", FileType.RepGen, "01012013", "1153", 1123);

            var session = new SymSession(mockSocket, 10);

            File actual = session.FileGet("RandomFile", FileType.RepGen);

            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.Type, actual.Type);
        }
        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 FileList_HasMatches_CountIsCorrect()
        {
            var mockSocket = Substitute.For <ISymSocket>();

            mockSocket.ReadCommand()
            .Returns(
                new SymCommand("FileList", new Dictionary <string, string>
            {
                { "Name", "RandomFile" },
                { "Date", "01012013" },
                { "Time", "1153" },
                { "Size", "1123" },
            }),
                new SymCommand("FileList", new Dictionary <string, string>
            {
                { "Name", "RandomFile2" },
                { "Date", "01012013" },
                { "Time", "1153" },
                { "Size", "1123" },
            }),
                new SymCommand("FileList", new Dictionary <string, string> {
                { "Done", "" }
            })
                );

            var session = new SymSession(mockSocket, 10);

            session.FileList("RandomFile+", FileType.RepGen).Count.Should().Be(2);
        }
        public void FileExistsByFile_FilesReturned_IsTrue()
        {
            var file = new File("symitar", "000", "RandomFile", FileType.RepGen, DateTime.Now, 100);

            var mockSocket = Substitute.For <ISymSocket>();

            mockSocket.ReadCommand()
            .Returns(
                new SymCommand("FileList",
                               new Dictionary <string, string>
            {
                { "Name", "RandomFile" },
                { "Date", "01012013" },
                { "Time", "1153" },
                { "Size", "1123" },
            }),
                new SymCommand("FileList", new Dictionary <string, string> {
                { "Done", "" }
            })
                );

            var session = new SymSession(mockSocket, 10);

            bool result = session.FileExists(file);

            result.Should().BeTrue();
        }
        public void Constructor_WithSymDir_HasCorrectSymDir()
        {
            var mockSocket = Substitute.For <ISymSocket>();
            var session    = new SymSession(mockSocket, 10);

            session.SymDirectory.Should().Be(10);
        }
Exemple #7
0
 public void Connect_ZeroPort_ThrowsArgumentException()
 {
     var mockSocket = Substitute.For<ISymSocket>();
     var session = new SymSession(mockSocket);
     Assert.Throws<ArgumentOutOfRangeException>(
         () => session.Connect("symitar", 0));
 }
Exemple #8
0
 public void Constructor_WithSocketAndSymDir_HasCorrectSymDir()
 {
     var socketMock = Substitute.For<ISymSocket>();
     socketMock.Connect().Returns(true);
     var session = new SymSession(socketMock, 10);
     session.SymDirectory.Should().Be(10);
 }
        private void BeforeConnect()
        {
            var socketMock = Substitute.For <ISymSocket>();

            socketMock.Connect().Returns(true);
            _session = new SymSession(socketMock);
        }
Exemple #10
0
 public void Disconnect_CallsDisconnectOnSocket()
 {
     var socketMock = Substitute.For<ISymSocket>();
     var session = new SymSession(socketMock);
     session.Disconnect();
     socketMock.Received().Disconnect();
 }
Exemple #11
0
        public void IsFileRunning_ZeroSequence_ThrowsOutOfRange()
        {
            var mockSocket = Substitute.For<ISymSocket>();
            var session = new SymSession(mockSocket);

            Assert.Throws<ArgumentOutOfRangeException>(() => session.IsFileRunning(0));
        }
Exemple #12
0
        //------------------------------------------------------------------------
        private void btnTest_Click(object sender, EventArgs e)
        {
            SymSession test = new SymSession();

            try
            {
                if (!test.Connect(txtIP.Text, int.Parse(txtPort.Text)))
                {
                    MessageBox.Show(test.error, "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (!test.AIXTest(txtUser.Text, txtPass.Text))
                {
                    MessageBox.Show(test.error, "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error During Login\n" + ex.Message, "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            test.Disconnect();
            MessageBox.Show("Server Connected Okay!", "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.None);
        }
Exemple #13
0
        public void IsFileRunning_ZeroSequence_ThrowsOutOfRange()
        {
            var mockSocket = Substitute.For <ISymSocket>();
            var session    = new SymSession(mockSocket);

            Assert.Throws <ArgumentOutOfRangeException>(() => session.IsFileRunning(0));
        }
Exemple #14
0
        public void FileRun_LetterFile_ThrowsException()
        {
            var file       = new File("symitar", "10", "RandomFile", FileType.Letter, DateTime.Now, 10);
            var mockSocket = Substitute.For <ISymSocket>();
            var session    = new SymSession(mockSocket, 10);

            Assert.Throws <InvalidOperationException>(() => session.FileRun(file, null, null, -1));
        }
Exemple #15
0
        public void Connect_ZeroPort_ThrowsArgumentException()
        {
            var mockSocket = Substitute.For <ISymSocket>();
            var session    = new SymSession(mockSocket);

            Assert.Throws <ArgumentOutOfRangeException>(
                () => session.Connect("symitar", 0));
        }
Exemple #16
0
 public SymInst(SymServer Parent, string SymDir, string SymId, bool Remember)
 {
     this.Parent     = Parent;
     this.SymDir     = SymDir;
     this.SymId      = SymId;
     this.Connection = null;
     this.Remember   = Remember;
 }
Exemple #17
0
 //========================================================================
 public SymInst(SymServer Parent)
 {
     this.Parent     = Parent;
     this.SymDir     = "";
     this.SymId      = "";
     this.Connection = null;
     this.Remember   = true;
 }
Exemple #18
0
        public void FileRun_LetterFile_ThrowsException()
        {
            var file = new File("symitar", "10", "RandomFile", FileType.Letter, DateTime.Now, 10);
            var mockSocket = Substitute.For<ISymSocket>();
            var session = new SymSession(mockSocket, 10);

            Assert.Throws<InvalidOperationException>(() => session.FileRun(file, null, null, -1));
        }
Exemple #19
0
        public void Disconnect_CallsDisconnectOnSocket()
        {
            var socketMock = Substitute.For <ISymSocket>();
            var session    = new SymSession(socketMock);

            session.Disconnect();
            socketMock.Received().Disconnect();
        }
        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));
        }
Exemple #21
0
 //========================================================================
 public void Disconnect()
 {
     if (Connection == null)
     {
         return;
     }
     Connection.Disconnect();
     Connection = null;
 }
Exemple #22
0
        public void IsFileRunning_DoneImmediate_ReturnsFalse()
        {
            var mockSocket = Substitute.For<ISymSocket>();
            mockSocket.ReadCommand()
                .Returns(new SymCommand("Misc", new Dictionary<string, string> {{"Done", ""}}));

            var session = new SymSession(mockSocket);
            session.IsFileRunning(1).Should().BeFalse();
        }
        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));
        }
Exemple #24
0
        public void Constructor_WithSocketAndSymDir_HasCorrectSymDir()
        {
            var socketMock = Substitute.For <ISymSocket>();

            socketMock.Connect().Returns(true);
            var session = new SymSession(socketMock, 10);

            session.SymDirectory.Should().Be(10);
        }
Exemple #25
0
        private void AfterConnect()
        {
            var socketMock = Substitute.For <ISymSocket>();

            socketMock.Connect().Returns(true);
            socketMock.Connected.Returns(true);
            _session = new SymSession(socketMock);
            _session.Connect("symitar", 23);
        }
        public void UnitOfWork_Scenario_ExpectedBehavior()
        {
            var mockSocket = Substitute.For<ISymSocket>();
            mockSocket.ReadCommand().Returns(new SymCommand("FileList", new Dictionary<string, string> {{"Done", ""}}));

            var session = new SymSession(mockSocket, 10);

            int result = session.GetFileMaintenanceSequence("Report Title");
            result.Should().Be(-1);
        }
        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));
        }
        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));
        }
Exemple #29
0
        public void Login_SocketKeepAliveFail_ReturnsFalse()
        {
            var socketMock = Substitute.For <ISymSocket>();

            socketMock.Connected.Returns(true);
            socketMock.When(x => x.WaitFor("Password:"******"[c")).Do(x => { throw new InvalidOperationException(); });

            var session = new SymSession(socketMock, 10);

            session.Login("bob", "dole", "bobdole").Should().BeFalse();
        }
Exemple #30
0
        public void Login_SocketWriteFail_ReturnsFalse()
        {
            var socketMock = Substitute.For <ISymSocket>();

            socketMock.Connected.Returns(true);
            socketMock.WhenForAnyArgs(x => x.Write(new byte[] { }))
            .Do(x => { throw new NetworkInformationException(); });

            var session = new SymSession(socketMock, 10);

            session.Login("bob", "dole", "bobdole").Should().BeFalse();
        }
        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));
        }
Exemple #32
0
        public void IsFileRunning_QueueEntryWithoutMatchingSeq_ReturnsTrue()
        {
            var mockSocket = Substitute.For<ISymSocket>();
            mockSocket.ReadCommand()
                .Returns(
                    new SymCommand("Misc",new Dictionary<string, string>{{"Action", "QueueEntry"},{"Seq", "11"}}),
                    new SymCommand("Misc", new Dictionary<string, string> {{"Done", ""}})
                );

            var session = new SymSession(mockSocket);
            session.IsFileRunning(1).Should().BeFalse();
        }
Exemple #33
0
        public void Reconnect_CallsDisconnectAndConnect()
        {
            var socketMock = Substitute.For <ISymSocket>();
            var session    = new SymSession(socketMock, 10);

            session.Connect("symitar", 23);

            session.Reconnect();

            socketMock.Received().Disconnect();
            socketMock.Received().Connect("symitar", 23);
        }
Exemple #34
0
        public void Login_InvalidAixLoginUsername_ReturnsFalse()
        {
            var socketMock = Substitute.For <ISymSocket>();

            socketMock.Connected.Returns(true);
            socketMock.WaitFor("Password:"******"[c");
            socketMock.Read().Returns("invalid login");

            var session = new SymSession(socketMock, 10);

            session.Login("bob", "dole", "bobdole").Should().BeFalse();
        }
        public void FileDelete_NoStatusOrDone_ThrowsException()
        {
            var file = new File("symitar", "000", "RandomFile", FileType.RepGen, DateTime.Now, 100);

            var mockSocket = Substitute.For <ISymSocket>();

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

            var session = new SymSession(mockSocket, 10);

            Assert.Throws <Exception>(() => session.FileDelete("RandomFile", FileType.RepGen));
        }
        public void FileRead_LongFileName_ThrowException()
        {
            var mockSocket = Substitute.For <ISymSocket>();

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

            var session = new SymSession(mockSocket, 10);

            Assert.Throws <Exception>(() => session.FileRead("ReallyReallReallyReallyLongFileName", FileType.Report), "Filename Too Long");
        }
        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();
        }
        public void FileList_NoMatches_CountIsZero()
        {
            var mockSocket = Substitute.For <ISymSocket>();

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

            var session = new SymSession(mockSocket, 10);

            session.FileList("--", FileType.RepGen).Count.Should().Be(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));
        }
        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");
        }
        public void FileGet_NoMatches_ThrowsFileNotFound()
        {
            var mockSocket = Substitute.For <ISymSocket>();

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

            var session = new SymSession(mockSocket, 10);

            Assert.Throws <FileNotFoundException>(() => session.FileGet("RandomFile", FileType.RepGen));
        }
        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();
        }
Exemple #43
0
        public void Login_SocketWriteFail_ReturnsFalse()
        {
            var socketMock = Substitute.For<ISymSocket>();
            socketMock.Connected.Returns(true);
            socketMock.WhenForAnyArgs(x => x.Write(new byte[] { }))
                .Do(x => { throw new NetworkInformationException(); });

            var session = new SymSession(socketMock, 10);
            session.Login("bob", "dole", "bobdole").Should().BeFalse();
        }
Exemple #44
0
        public void Login_InputHasHelpCode_CallsHostSyncWrite()
        {
            var socketMock = Substitute.For<ISymSocket>();
            socketMock.Connected.Returns(true);
            socketMock.WaitFor("Password:"******"[c").Returns(0);
            socketMock.WaitFor(":").Returns(0);
            socketMock.Read().Returns("Password:"******":");
            socketMock.ReadCommand()
                .Returns(
                    new SymCommand("Request"),
                    new SymCommand("Input", new Dictionary<string, string> {{"HelpCode", "10025"}})
                );

            var session = new SymSession(socketMock, 10);
            session.Login("bob", "dole", "bobdole");
            socketMock.Received().Write("$WinHostSync$\r");
        }
        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));
        }
        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");
        }
Exemple #47
0
        public void Login_SocketWriteFail_HasError()
        {
            var socketMock = Substitute.For<ISymSocket>();
            socketMock.Connected.Returns(true);
            socketMock.WhenForAnyArgs(x => x.Write(new byte[] { }))
                .Do(x => { throw new NetworkInformationException(); });

            var session = new SymSession(socketMock, 10);
            session.Login("bob", "dole", "bobdole");
            session.Error.Should().Contain("Telnet communication failed");
        }
Exemple #48
0
        public void Login_CommandPromptNoWait_ReturnsTrue()
        {
            var socketMock = Substitute.For<ISymSocket>();
            socketMock.Connected.Returns(true);
            socketMock.WaitFor("Password:"******"[c").Returns(0);
            socketMock.WaitFor(":").Returns(0);
            socketMock.Read().Returns("Password:"******"[c");
            socketMock.ReadCommand().Returns(new SymCommand("Input", new Dictionary<string, string> { { "HelpCode", "10025" } }));

            var session = new SymSession(socketMock, 10);
            session.Login("bob", "dole", "bobdole").Should().BeTrue();
        }
Exemple #49
0
 public void Constructor_WithSymDir_HasCorrectSymDir()
 {
     var mockSocket = Substitute.For<ISymSocket>();
     var session = new SymSession(mockSocket, 10);
     session.SymDirectory.Should().Be(10);
 }
Exemple #50
0
        public void Login_SocketKeepAliveFail_ReturnsFalse()
        {
            var socketMock = Substitute.For<ISymSocket>();
            socketMock.Connected.Returns(true);
            socketMock.When(x => x.WaitFor("Password:"******"[c")).Do(x => { throw new InvalidOperationException(); });

            var session = new SymSession(socketMock, 10);
            session.Login("bob", "dole", "bobdole").Should().BeFalse();
        }
Exemple #51
0
        public void Login_InvalidSymLogin_ReturnsFalse()
        {
            var socketMock = Substitute.For<ISymSocket>();
            socketMock.Connected.Returns(true);
            socketMock.WaitFor("Password:"******"[c").Returns(0);
            socketMock.WaitFor(":").Returns(0);
            socketMock.Read().Returns("Password:"******":");
            socketMock.ReadCommand().Returns(new SymCommand("SymLogonInvalidUser"));

            var session = new SymSession(socketMock, 10);
            session.Login("bob", "dole", "bobdole").Should().BeFalse();
        }
Exemple #52
0
        public void Login_Successful_StartsKeepAliveOnSocket()
        {
            var socketMock = Substitute.For<ISymSocket>();
            socketMock.Connected.Returns(true);
            socketMock.WaitFor("Password:"******"[c").Returns(0);
            socketMock.WaitFor(":").Returns(0);
            socketMock.Read().Returns("Password:"******":");
            socketMock.ReadCommand().Returns(new SymCommand("Input", new Dictionary<string, string> {{"HelpCode", "10025"}}));

            var session = new SymSession(socketMock, 10);
            session.Login("bob", "dole", "bobdole");
            socketMock.Received().KeepAliveStart();
        }
Exemple #53
0
        public void Login_SocketKeepAliveException_ReturnsFalse()
        {
            var socketMock = Substitute.For<ISymSocket>();
            socketMock.Connected.Returns(true);
            socketMock.WaitFor("Password:"******"[c").Returns(0);
            socketMock.WaitFor(":").Returns(0);
            socketMock.Read().Returns("Password:"******":");
            socketMock.ReadCommand().Returns(new SymCommand("Input", new Dictionary<string, string> { { "HelpCode", "10025" } }));
            socketMock.When(x => x.KeepAliveStart()).Do(x => { throw new Exception(); });

            var session = new SymSession(socketMock, 10);
            session.Login("bob", "dole", "bobdole").Should().BeFalse();
        }
Exemple #54
0
        public void Reconnect_CallsDisconnectAndConnect()
        {
            var socketMock = Substitute.For<ISymSocket>();
            var session = new SymSession(socketMock, 10);
            session.Connect("symitar", 23);

            session.Reconnect();

            socketMock.Received().Disconnect();
            socketMock.Received().Connect("symitar", 23);
        }
Exemple #55
0
        public void Login_InvalidAixLoginUsername_ReturnsFalse()
        {
            var socketMock = Substitute.For<ISymSocket>();
            socketMock.Connected.Returns(true);
            socketMock.WaitFor("Password:"******"[c");
            socketMock.Read().Returns("invalid login");

            var session = new SymSession(socketMock, 10);
            session.Login("bob", "dole", "bobdole").Should().BeFalse();
        }
        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.");
        }
Exemple #57
0
 private void BeforeConnect()
 {
     var socketMock = Substitute.For<ISymSocket>();
     socketMock.Connect().Returns(true);
     _session = new SymSession(socketMock);
 }
Exemple #58
0
        public void Login_InvalidAixLoginPassword_HasErrorMessage()
        {
            var socketMock = Substitute.For<ISymSocket>();
            socketMock.Connected.Returns(true);
            socketMock.WaitFor("Password:"******"[c").Returns(0);
            socketMock.WaitFor(":").Returns(0);
            socketMock.Read().Returns("Password:"******"invalid login");

            var session = new SymSession(socketMock, 10);
            session.Login("bob", "dole", "bobdole");
            session.Error.Should().Contain("Invalid AIX Login");
        }
Exemple #59
0
 private void AfterConnect()
 {
     var socketMock = Substitute.For<ISymSocket>();
     socketMock.Connect().Returns(true);
     socketMock.Connected.Returns(true);
     _session = new SymSession(socketMock);
     _session.Connect("symitar", 23);
 }
Exemple #60
0
        public void Login_LocksDuringLogin_ReturnsFalse()
        {
            var socketMock = Substitute.For<ISymSocket>();
            socketMock.Connected.Returns(true);
            socketMock.WaitFor("Password:"******"[c").Returns(0);
            socketMock.WaitFor(":").Returns(0);
            socketMock.Read().Returns("Password:"******":");
            socketMock.ReadCommand()
                      .Returns(new SymCommand("SymLogonError",
                                             new Dictionary<string, string>
                                                 {
                                                     {"Text", "Too Many Invalid Password Attempts"}
                                                 }));

            var session = new SymSession(socketMock, 10);
            session.Login("bob", "dole", "bobdole").Should().BeFalse();
        }