public void AuthResponseNotAuthenticatedTest() { AuthResponse response = new AuthResponse(); IList<string> lines = new List<string> { "blah\n\r blahI HATE YOUblah" }; response.Initialize(lines); response.Process(); Assert.AreEqual(AuthStatus.NotAuthenticated, response.Status); Assert.AreEqual(lines.Count, response.LineCount); }
public void TestCommandToXML() { IRoot root = new Root(TestConfig.RepositoryPath, TestConfig.ModuleName, TestConfig.CVSHost, TestConfig.CVSPort, TestConfig.Username, TestConfig.Password); root.WorkingDirectory = TestConfig.WorkingDirectory; MockRepository mocks = new MockRepository(); IConnection connection = mocks.Stub<IConnection>(); CheckOutCommand cmd = new CheckOutCommand(root, connection); // add requests to items foreach (ICommandItem item in cmd.RequiredRequests) { cmd.Items.Add(item); } foreach (ICommandItem item in cmd.Requests) { cmd.Items.Add(item); } // add responses to command IResponse response = new AuthResponse(); IList<string> process = new List<string> { "I LOVE YOU" }; response.Initialize(process); cmd.Items.Add(response); response = new ValidRequestsResponse(); IList<string> lines = new List<string> { "Root Valid-responses valid-requests Global_option" }; response.Initialize(lines); cmd.Items.Add(response); IList<IResponse> coresponses = TestHelper.GetMockCheckoutResponses("8 Dec 2009 15:26:27 -0000", "mymod/", "file1.cs"); foreach (IResponse cor in coresponses) { cmd.Responses.Add(cor); } XDocument xdoc = cmd.GetXDocument(); Console.WriteLine(xdoc.ToString()); bool result = TestHelper.ValidateCommandXML(xdoc); Assert.IsTrue(result); }
public void ExecuteRequiredRequestsAuthFailExitCodeFailTest() { IAuthRequest authRequest = _mocks.DynamicMock<IAuthRequest>(); IAuthResponse authResponse = new AuthResponse(); IList<string> lines = new List<string> { "I HATE YOU" }; authResponse.Initialize(lines); authResponse.Process(); _cmdbase.RequiredRequests = new List<IRequest> { authRequest }; Expect.Call(() => _connection.DoRequest(null)) .IgnoreArguments() .Repeat.Once(); Expect.Call(_connection.GetResponse()).Return(authResponse); _mocks.ReplayAll(); ExitCode result = _cmdbase.ExecuteRequiredRequests(); _mocks.VerifyAll(); Assert.AreEqual(ExitCode.Failed, result); }
public void CommandBaseExecuteWhenAuthFailedTest() { IAuthRequest authRequest = _mocks.DynamicMock<IAuthRequest>(); IAuthResponse authResponse = new AuthResponse(); IList<string> lines = new List<string> { "I HATE YOU" }; authResponse.Initialize(lines); authResponse.Process(); IRequest otherRequest = _mocks.DynamicMock<IRequest>(); _cmdbase.RequiredRequests = new List<IRequest> { authRequest, otherRequest }; Expect.Call(() => _connection.Connect(null)) .IgnoreArguments() .Repeat.Once(); Expect.Call(() => _connection.DoRequest(null)) .IgnoreArguments() .Repeat.Once(); Expect.Call(_connection.GetResponse()).Return(authResponse); Expect.Call(() => _connection.DoRequest(otherRequest)).Repeat.Never(); Expect.Call(_connection.Close).Repeat.Once(); _mocks.ReplayAll(); _cmdbase.Execute(); _mocks.VerifyAll(); }