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);
            }
        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();
        }