public BugzillaMocks()
 {
     repository = new MockRepository();
     client = repository.StrictMock<IBugzillaClient>();
     serviceFactory = repository.DynamicMock<IBugzillaClientFactory>();
     logger = repository.Stub<ILogger>();
 }
            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 SetContext()
        {
            var liveInstanceOfBugzillaThatHasRestfulApi = "http://184.170.227.113/bugzilla/rest/";

            IBugzillaClientConfiguration bugzillaClientConfiguration = new BugzillaClientConfiguration
            {
                UserName = "******",
                Password = "******",
                Url = liveInstanceOfBugzillaThatHasRestfulApi
            };

            ILogger logger = MockRepository.GenerateMock<ILogger>();

            _client = new BugzillaClient(bugzillaClientConfiguration, logger);

            _loggedInUserToken = _client.Login();
        }
Example #4
0
        public void SetContext()
        {
            // This URL is what is setup if using the docker container
            var liveInstanceOfBugzillaThatHasRestfulApi = "http://localhost:8088/bugzilla/rest";

            IBugzillaClientConfiguration bugzillaClientConfiguration = new BugzillaClientConfiguration
            {
                UserName = "******",
                Password = "******",
                Url      = liveInstanceOfBugzillaThatHasRestfulApi
            };

            ILogger logger = MockRepository.GenerateMock <ILogger>();

            _client = new BugzillaClient(bugzillaClientConfiguration, logger);

            _loggedInUserToken = _client.Login();
        }
        private void ResolveBugIfRequired(string resolution, int bugId, IBugzillaClient client)
        {
            try
            {
                if (string.IsNullOrEmpty(resolution))
                {
                    throw new Exception("There was an attempt to resolve a bug without having a configured resolution value.");
                }

                if (!client.ResolveBug(bugId, resolution))
                {
                    logger.Log(LogMessage.SeverityType.Error, string.Format("Failed to resolve bug to {0}.", resolution));
                }
            }
            catch (Exception ex)
            {
                logger.Log(LogMessage.SeverityType.Error, "Failed to resolve bug: " + ex.InnerException.Message);
            }
        }
        private void ResolveBugIfRequired(string resolution, int bugId, IBugzillaClient client) 
        {
            if(string.IsNullOrEmpty(resolution)) 
            {
                return;
            }

            try 
            {
                if(!client.ResolveBug(bugId, resolution, string.Empty)) 
                {
                    logger.Log(LogMessage.SeverityType.Error, string.Format("Failed to resolve bug to {0}.", resolution));
                }
            } catch(BugzillaException ex) 
            {
                logger.Log(LogMessage.SeverityType.Error, "Failed to resolve bug: " + ex.InnerException.Message);
            }
        }
        private bool SkipCloseActions(int bugId, IBugzillaClient client) 
        {
            if(!string.IsNullOrEmpty(configuration.OnStateChangeFieldName)) 
            {
                var fieldValue = client.GetFieldValue(bugId, configuration.OnStateChangeFieldName);
                
                if(fieldValue.Equals(configuration.OnStateChangeFieldValue)) 
                {
                    return true;
                }
            }

            var reassignValue = configuration.OnStateChangeReassignValue;
            
            if(!string.IsNullOrEmpty(reassignValue)) 
            {
                var bug = client.GetBug(bugId);
                var user = client.GetUser(bug.AssignedToID);
                
                if(!string.IsNullOrEmpty(user.Login) && user.Login.Equals(reassignValue)) 
                {
                    return true;
                }
            }

            return false;
        }