Ejemplo n.º 1
0
        public void ShouldNotMarkTheSameGroupTwice(
            string group,
            UpdateDetector sut)
        {
            sut.MarkForUpdate(group);
            sut.MarkForUpdate(group);

            Assert.Equal(group, sut.PopMarked().Single());
        }
Ejemplo n.º 2
0
    public void ShouldMarkManyGroupsForUpdate(
        string[] groups,
        UpdateDetector sut)
    {
        sut.MarkForUpdate(groups);

        var result = sut.PopMarked();

        foreach (var group in groups)
        {
            Assert.Contains(group, result);
        }
    }
Ejemplo n.º 3
0
        public async Task ShouldMarkThreadSafely(UpdateDetector sut)
        {
            var tasks = new List <Task>(100);

            for (var i = 1; i <= 100; i++)
            {
                var group = Create <string>();
                tasks.Add(new Task(() => sut.MarkForUpdate(group)));
                tasks.Add(new Task(() => sut.MarkForUpdate(group)));
            }

            Parallel.ForEach(tasks, t => t.Start());
            await Task.WhenAll(tasks);

            Assert.Equal(100, sut.PopMarked().Count());
        }
Ejemplo n.º 4
0
        public void ShouldPopAllMarkedGroups(UpdateDetector sut)
        {
            var groups = Fixture.CreateMany <string>(3).ToList();

            foreach (var group in groups)
            {
                sut.MarkForUpdate(group);
            }

            Assert.Equal(3, sut.PopMarked().Count());
            Assert.Empty(sut.PopMarked());

            sut.MarkForUpdate(groups[0]);
            Assert.Equal(groups[0], sut.PopMarked().Single());
            Assert.Empty(sut.PopMarked());
        }
Ejemplo n.º 5
0
        private void UserControl_Loaded(Object sender, RoutedEventArgs e)
        {
            try
            {
                log.Info("XAML Loaded...");

                var scroll = itemsControl.FindChild <ScrollContentPresenter>();

                _userPref = UserPreferencesStorage.Load();
                _cfg      = _persistor.Restore <Config.DogConfig>(_userPref);

                UpdateDetector = new UpdateDetector(_userPref);
                UpdateDetector.NewVersionFound += UpdateDetector_NewVersionFound;

                _processor.RequestFailed += new Action <Request, Exception>(_processor_RequestFailed);
                StudioController.Initialise();
                StudioController.SetConfiguration(_cfg);
                StudioController.OnServersAdded    += StudioController_OnServersAdded;
                StudioController.OnServersRemoved  += StudioController_OnServersRemoved;
                StudioController.OnDatabaseChanged += StudioController_OnDatabaseChanged;
                StudioController.ShowYourself      += new System.Action(StudioController_ShowYourself);
                ReloadServers();

                ResultsFontSize = _cfg.FontSize;

                var lastSrvName = _userPref.GetByName(UserPref_LastSelectedServer);
                RestoreLastSearchTextFromUserProfile();

                // select first server
                if ((cbServer.SelectedIndex == -1) && (cbServer.Items.Count > 1))
                {
                    cbServer.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                log.Error("Fatal error loading main control:" + ex.Message, ex);
            }
        }