Ejemplo n.º 1
0
        public void given_a_url_is_provided_on_construction()
        {
            const string baseUrl = "http://www.google.com/";
            var expectedUrl = new Uri(new Uri(baseUrl), UriElements.ConfigurationPath).ToString();
            var target = new ConfigurationProxy(null, "http://www.google.com/");

            context["when i retrieve the listener url form the configurationProxy instance"] = () =>
                {
                    var retrievedUrl = target.ConfigurationUrl;
                    it["then the provided url is returned"] = () => retrievedUrl.should_be(expectedUrl);
                };
        }
Ejemplo n.º 2
0
 public void given_a_url_is_not_provided_on_construction()
 {
     var target = new ConfigurationProxy();
     context["when i retrieve the listener and configuration url from the configurationProxy instance"] = () =>
         {
             var configUrl = target.ConfigurationUrl;
             var listenerUrl = target.ListenerUrl;
             var defaultProvider = new DefaultConfigurationProvider();
             var defaultConfigUrl = defaultProvider.ConfigurationUrl.ToString();
             var defaultListenerUrl = defaultProvider.TfsListenerUrl.ToString();
             it["then the default url is returned"] = () =>
                 {
                     configUrl.should_be(defaultConfigUrl);
                     listenerUrl.should_be(defaultListenerUrl);
                 };
         };
 }
Ejemplo n.º 3
0
        public static TfsTeamProjectCollection ConnectToTFS()
        {
            var config = new ConfigurationProxy().Retrieve();
            var user = config.TfsUserName;
            var domain = string.Empty;
            var pos = config.TfsUserName.IndexOf('\\');

            if (pos >= 0)
            {
                domain = config.TfsUserName.Substring(0, pos);
                user = user.Substring(pos + 1);
            }

            var creds = new NetworkCredential(user, config.TfsPassword, domain);
            var tfsServer = new TfsTeamProjectCollection(new Uri(config.TfsUrl), creds);
            tfsServer.Authenticate();
            return tfsServer;
        }
Ejemplo n.º 4
0
        private void TFSUpdateB_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                var proxy = new ConfigurationProxy();
                var config = proxy.Retrieve();

                config.TfsUrl = ListenerURLTB.Text;
                proxy.Store(config);

                // Get Eventing Service
                var eventService = (IEventService)TfsServer.GetService(typeof(IEventService));

                // Set delivery preferences
                var dPref = new DeliveryPreference { Schedule = DeliverySchedule.Immediate, Address = config.TfsUrl, Type = DeliveryType.Soap };

                const string tag = "VersionOneTFSServer";

                // Unsubscribe to all events
                foreach (var s in eventService.GetEventSubscriptions(TfsServer.AuthorizedIdentity.Descriptor, tag))
                {
                    eventService.UnsubscribeEvent(s.ID);
                }

                // Subscribe to checked events
                var filter = string.Empty;
                eventService.SubscribeEvent("CheckinEvent", filter, dPref, tag);
                eventService.SubscribeEvent("BuildCompletionEvent2", filter, dPref, tag);

                UpdateFormControlStatus();
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Ejemplo n.º 5
0
        private void TFSConnectB_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                var proxy = new ConfigurationProxy();
                var config = proxy.Retrieve();

                config.TfsUrl = TFSURLTB.Text;
                config.TfsUserName = TFSUsernameTB.Text;
                config.TfsPassword = TFSPasswordTB.Text;

                proxy.Store(config);

                TFSStatusLabel.Text = "Not connected";

                TfsServer = null;
                // Connect to TFS
                TfsServer = Utils.ConnectToTFS();

                TFSStatusLabel.Text = "Connected to " + TFSURLTB.Text;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
            finally
            {
                Cursor.Current = Cursors.Default;
                UpdateFormControlStatus();
            }
        }
Ejemplo n.º 6
0
        private TfsServerConfiguration GetConfigurationData()
        {
            if (tcSettings.Enabled == false) tcSettings.Enabled = true;
            if (btnSaveAllSettings.Enabled == false) btnSaveAllSettings.Enabled = true;

            var tfsConfig = new TfsServerConfiguration();
            var proxy = new ConfigurationProxy(null, tbBaseUrl.Text);

            UpdateStatusText(string.Format("Updating configuration information from {0}.", proxy.ConfigurationUrl), false);

            try
            {
                tfsConfig = proxy.Retrieve();
            }
            catch (Exception e)
            {
                UpdateStatusText(string.Format("Could not use the to TFS Listener at url {0}.  Exception:  {1}.", proxy.ConfigurationUrl, e.Message), true);
                tcSettings.Enabled = false;
                btnSaveAllSettings.Enabled = false;
            }
            finally
            {
                tbBaseUrl.Text = proxy.BaseListenerUrl;
            }

            return tfsConfig;
        }
Ejemplo n.º 7
0
        private void btnSaveVersionOneSettings_Click(object sender, EventArgs e)
        {
            var configToSave = new TfsServerConfiguration()
                {
                    VersionOneUrl = V1URLTB.Text,
                    VersionOneUserName = V1UsernameTB.Text,
                    VersionOnePassword = V1PasswordTB.Text,
                    TfsUrl = TFSURLTB.Text,
                    TfsUserName = TFSUsernameTB.Text,
                    TfsPassword = TFSPasswordTB.Text,
                    TfsWorkItemRegex = RegExTB.Text,
                    DebugMode = chkDebugMode.Checked,
                    IsWindowsIntegratedSecurity = UseIntegratedAuthenticationCB.Checked,
                    ProxyIsEnabled = chkUseProxy.Checked,
                    ProxyUrl = txtProxyUrl.Text,
                    ProxyUsername = txtProxyUsername.Text,
                    ProxyPassword = txtProxyPassword.Text,
                    ProxyDomain = txtProxyDomain.Text,
                    BaseListenerUrl = tbBaseUrl.Text
                };

            var results = new ConfigurationProxy().Store(configToSave);
            if(results != null && results[StatusKey.Status] == StatusCode.Ok)
            {
                UpdateStatusText("Save successful.", false);
                return;
            }

            if (results == null) throw new Exception("Unable to retrieve results from server.");

            var missingFields = string.Join(", ", results.Keys.Where(key => key != "status"));
            var text = string.Format("The following values must be present in order to save settings:  {0}.", missingFields);
            UpdateStatusText(text, true);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Exercise mock server
 /// </summary>
 public void given_data_is_being_sent_and_received_to_the_server()
 {
     var mock = new PretendsToBeConnectedToHttpClient();
     var proxy = new ConfigurationProxy(mock);
     it["then its possible to submit valid configuration"] = () =>
         {
             var result = proxy.Store(_serializationTarget);
             result[StatusKey.Status].should_be(StatusCode.Ok);
         };
     it["then the original object is retrieved on get"] = () => proxy.Retrieve().should_be(_serializationTarget);
 }