public void FogbugzClient_saves_the_token_from_logging_on() { this.client = SetupStubbedClient("<response><token>24dsg34lok43un23</token></response>"); string token = this.client.Logon("*****@*****.**", "password"); token.ShouldEqual("24dsg34lok43un23"); }
public void FogbugzClient_does_not_allow_the_creation_of_command_objects_if_not_logged_on() { var client = new FogbugzClient(new Mock<IFogbugzHttpClient>().Object); Assert.Throws<InvalidOperationException>(() => { client.CreateCommand<CreationTestAuthorisedCommand>(); }); }
public void FogbugzClient_does_not_allow_the_creation_of_command_objects_if_not_logged_on() { var client = new FogbugzClient(new Mock <IFogbugzHttpClient>().Object); Assert.Throws <InvalidOperationException>(() => { client.CreateCommand <CreationTestAuthorisedCommand>(); }); }
private static FogbugzClient SetupLoggedOnClient(string token) { Mock<IFogbugzHttpClient> clientStub = new Mock<IFogbugzHttpClient>(); var responseString = string.Format("<response><token>{0}</token></response>", token); var response = XDocument.Parse(responseString); clientStub.Setup(c => c.ExecuteQuery(It.IsAny<string>())).Returns(response); var client = new FogbugzClient(clientStub.Object); client.Logon("email", "password"); return client; }
public void FogbugzClient_throws_a_property_populated_FogbugzException_when_logon_fails_at_the_client() { WebException e = new WebException("Could not connect to Fogbugz"); this.client = SetupStubbedClient(e); var exception = Assert.Throws<FogbugzException>(() => { this.client.Logon("*****@*****.**", "password"); }); exception.InnerException.ShouldBeSameAs(e); exception.Message.ShouldEqual("An error occurred while communicating with Fogbugz."); }
public void FogbugzClient_throws_a_properly_populated_FogbugzException_when_logon_fails_at_the_server() { this.client = SetupStubbedClient("<response><error code=\"1\">ERROR!</error></response>"); var exception = Assert.Throws<FogbugzException>(() => { this.client.Logon("*****@*****.**", "password"); }); exception.Message.ShouldEqual("ERROR!"); exception.ErrorCode.ShouldEqual("1"); }
public void FogbugzClient_throws_a_properly_populated_FogbugzException_when_logon_fails_at_the_server() { this.client = SetupStubbedClient("<response><error code=\"1\">ERROR!</error></response>"); var exception = Assert.Throws <FogbugzException>(() => { this.client.Logon("*****@*****.**", "password"); }); exception.Message.ShouldEqual("ERROR!"); exception.ErrorCode.ShouldEqual("1"); }
private static FogbugzClient SetupLoggedOnClient(string token) { Mock <IFogbugzHttpClient> clientStub = new Mock <IFogbugzHttpClient>(); var responseString = string.Format("<response><token>{0}</token></response>", token); var response = XDocument.Parse(responseString); clientStub.Setup(c => c.ExecuteQuery(It.IsAny <string>())).Returns(response); var client = new FogbugzClient(clientStub.Object); client.Logon("email", "password"); return(client); }
public void FogbugzClient_throws_a_property_populated_FogbugzException_when_logon_fails_at_the_client() { WebException e = new WebException("Could not connect to Fogbugz"); this.client = SetupStubbedClient(e); var exception = Assert.Throws <FogbugzException>(() => { this.client.Logon("*****@*****.**", "password"); }); exception.InnerException.ShouldBeSameAs(e); exception.Message.ShouldEqual("An error occurred while communicating with Fogbugz."); }
private void ExecuteRegistrationOfDate(DateTime date = default(DateTime)) { if (date == default(DateTime)) { date = GetDateFromInput(); } var validations = ExecuteValidateDate(date); if (validations.All(x => x.IsValid)) { var logService = new LogService(); foreach (var registration in validations.Select(x => x.Object).ToList()) { if (_client.HaveRegistration(registration)) { continue; } if (!string.IsNullOrEmpty(registration.Fogbugz)) { var fogbugzClient = new FogbugzClient(_configurationService.Configuration.Username, _configurationService.Configuration.FogbugzPassword, registration.Fogbugz, logService); if (!string.IsNullOrEmpty(registration.CaseNumber)) { fogbugzClient.SetEstimateIfNone(int.Parse(registration.CaseNumber) , validations.Where(x => x.Object.CaseNumber == registration.CaseNumber && !_client.HaveRegistration(x.Object)) .Sum(x => x.Object.Hours)); int caseNumber = 0; if (int.TryParse(registration.CaseNumber, out caseNumber)) { var fbcase = fogbugzClient.GetCase(caseNumber); if (fbcase != null) { registration.Note = fbcase.Title + ": " + registration.Note; } } } } _client.RegisterHours(registration); Console.WriteLine("Request sent for: " + registration); } Console.WriteLine("DONE..."); if (validations.Any()) { var syncSuccessfullMessage = $"B-) Regtime synch done... B-) {DateTime.Now:yyyy-MM-dd HH:mm}"; //_textMessageService.Send(_configurationService.Configuration.Mobile, syncSuccessfullMessage); _slackService.SendMessage(syncSuccessfullMessage); if (!string.IsNullOrEmpty(logService.ToString())) { var caseUpdatesMessage = $"Case updates: \n {logService}"; //_textMessageService.Send(_configurationService.Configuration.Mobile, caseUpdatesMessage); _slackService.SendMessage(caseUpdatesMessage); } } } else { var failureRegistrations = $"Entries at {date:yyyy-MM-dd} is not valid - execute manually"; //_textMessageService.Send(_configurationService.Configuration.Mobile, failureRegistrations); _slackService.SendMessage(failureRegistrations); } }