public void Setup() { _bugZillaClient = MockRepository.GenerateMock <IBugzillaClient>(); _bugZillaClient.Stub(client => client.Login()).Return("123"); _bugZillaClient.Stub(client => client.AcceptBug(Arg <int> .Is.Anything, Arg <string> .Is.Anything)).Return(true); var bugZillaClientFactory = MockRepository.GenerateMock <IBugzillaClientFactory>(); bugZillaClientFactory.Stub(factory => factory.CreateNew()).Return(_bugZillaClient); var logger = MockRepository.GenerateMock <ILogger>(); var config = new BugzillaServiceConfiguration(); var bugZillaBugStatusToSet = "IN_PROGRESS"; config.OnCreateResolveValue = bugZillaBugStatusToSet; _bugzillaReaderUpdater = new BugzillaReaderUpdater(config, bugZillaClientFactory, logger); var versionOneDefect = new Defect(string.Empty, String.Empty, String.Empty, string.Empty); var bugId = "1"; versionOneDefect.ExternalId = bugId; var versionOneWorkitemCreationResult = new WorkitemCreationResult(versionOneDefect); _bugzillaReaderUpdater.OnDefectCreated(versionOneWorkitemCreationResult); }
public void DefectCreatedResolve() { BugzillaServiceConfiguration config = GetStockConfig(); config.OnCreateResolveValue = "fixed"; OnDefectCreated(config); }
public void DefectCreatedReassign() { BugzillaServiceConfiguration config = GetStockConfig(); config.OnCreateReassignValue = "fred"; OnDefectCreated(config); }
public void DefectCreated() { BugzillaServiceConfiguration config = GetStockConfig(); config.OnCreateFieldName = "cf_V1Status"; config.OnCreateFieldValue = "Open"; OnDefectCreated(config); }
private void GetBugs(BugzillaServiceConfiguration config) { BugzillaMocks mocks = new BugzillaMocks(); List <Bug> expectedBugs = CreateSomeBogusRemoteBugs(5); List <int> expectedIds = new List <int>(); // Product expectedProduct = Product.Create(new GetProductResult(productId, productName, "Expected Descr")); // User expectedOwner = User.Create(new GetUserResult(ownerId, "Fred", "FredsLogin")); foreach (Bug bug in expectedBugs) { expectedIds.Add(int.Parse(bug.ID)); } // SetupResult.For(mocks.ClientFactory.CreateNew(config.Url, mocks.Logger)).Return(mocks.Client); Expect.Call(mocks.Client.Login()).Return(expectedUserId); for (int i = 0; i < expectedBugs.Count; i++) { Bug bug = expectedBugs[i]; Expect.Call(mocks.Client.GetBug(int.Parse(bug.ID))).Return(bug); Expect.Call(mocks.Client.Search(expectedFilterId)).Return(new List <int> { 1, 2, 3, 4, 5 }); //Expect.Call(mocks.Client.GetProduct(bug.ProductID)).Return(expectedProduct); //Expect.Call(mocks.Client.GetUser(bug.AssignedToID)).Return(expectedOwner); } mocks.Repository.ReplayAll(); BugzillaReaderUpdater reader = new BugzillaReaderUpdater(config, mocks.ClientFactory, mocks.Logger); List <Defect> returnedBugs = reader.GetBugs(); Assert.AreEqual(expectedBugs.Count, returnedBugs.Count, "Did not get back the right number of defects."); foreach (Defect defect in returnedBugs) { Assert.AreEqual(defect.ProjectId, v1ProjectId); Assert.AreEqual(defect.Owners, assignTo); Assert.AreEqual(defect.Priority, v1PriorityId); if (!string.IsNullOrEmpty(config.UrlTemplateToIssue) && !string.IsNullOrEmpty(config.UrlTitleToIssue)) { Assert.AreEqual(config.UrlTemplateToIssue.Replace("#key#", defect.ExternalId), defect.ExternalLink.Url); Assert.AreEqual(config.UrlTitleToIssue, defect.ExternalLink.Title); } } mocks.Repository.VerifyAll(); }
public void GetBugsWithUrl() { // This test wasn't working when we picked up work on the RESTful client in Sept/Oct of 2016. // Not sure why it was left in a failing state. We were pressed for time (surprise... surprise) and // for the near term have left this test in a failing state. Need to look closer at its intent // and make things right. BugzillaServiceConfiguration config = GetStockConfig(); config.UrlTemplateToIssue = "http://localhost/show_bug.cgi?id=#key#"; config.UrlTitleToIssue = "Bugz"; GetBugs(config); }
private void OnDefectCreated(BugzillaServiceConfiguration config) { BugzillaMocks mocks = new BugzillaMocks(); Defect defect = GetStockBug(); int expectedExternalId = 1234; string expectedDefectLinkValue = "http://localhost/VersionOne.Web/assetdetail.v1?Oid=Defect:1000"; defect.ExternalId = expectedExternalId.ToString(); WorkitemCreationResult workitemCreationResult = new WorkitemCreationResult(defect); workitemCreationResult.Messages.Add("Message1"); workitemCreationResult.Permalink = expectedDefectLinkValue; SetupResult.For(mocks.ClientFactory.CreateNew()).Return(mocks.Client); Expect.Call(mocks.Client.Login()).Return(expectedUserId); Expect.Call(mocks.Client.Logout); Expect.Call(mocks.Client.AcceptBug(Arg <int> .Is.Anything, Arg <string> .Is.Anything)).Return(true); if (!string.IsNullOrEmpty(config.OnCreateFieldName)) { Expect.Call(mocks.Client.UpdateBug(expectedExternalId, config.OnCreateFieldName, config.OnCreateFieldValue)).Return(true); } if (!string.IsNullOrEmpty(config.DefectLinkFieldName)) { Expect.Call(mocks.Client.UpdateBug(expectedExternalId, config.DefectLinkFieldName, expectedDefectLinkValue)).Return(true); } if (!string.IsNullOrEmpty(config.OnCreateReassignValue)) { Expect.Call(mocks.Client.ReassignBug(expectedExternalId, config.OnCreateReassignValue)).Return(true); } mocks.Repository.ReplayAll(); BugzillaReaderUpdater updater = new BugzillaReaderUpdater(config, mocks.ClientFactory, mocks.Logger); updater.OnDefectCreated(workitemCreationResult); mocks.Repository.VerifyAll(); }
private BugzillaServiceConfiguration GetStockConfig() { BugzillaServiceConfiguration config = new BugzillaServiceConfiguration(); config.UserName = userName; config.Password = password; config.Url = expectedUrl; config.OpenIssueFilterId = expectedFilterId; MappingInfo zillaProject = new MappingInfo(productId.ToString(), productName); MappingInfo v1Project = new MappingInfo(v1ProjectId, null); config.ProjectMappings.Add(zillaProject, v1Project); MappingInfo zillaPriority = new MappingInfo(null, expectedPriority); MappingInfo v1Priority = new MappingInfo(v1PriorityId, null); config.PriorityMappings.Add(zillaPriority, v1Priority); return(config); }