示例#1
0
        public void PropertiesWithNotification()
        {
            MultiThreadingObservableCollection <IAlertItem> items = new MultiThreadingObservableCollection <IAlertItem>();
            MockAlertDialogView  view      = new MockAlertDialogView();
            AlertDialogViewModel viewModel = new AlertDialogViewModel(view, items);

            Assert.AreEqual(items, viewModel.Items);
            Assert.AreEqual(0, viewModel.Items.Count);

            bool hasAlertSound = viewModel.HasAlertSound;

            AssertHelper.PropertyChangedEvent(viewModel, x => x.HasAlertSound, () => viewModel.HasAlertSound = !hasAlertSound);
            Assert.AreEqual(!hasAlertSound, viewModel.HasAlertSound);

            MultiThreadingObservableCollection <IAlertItem> newItems = new MultiThreadingObservableCollection <IAlertItem>();

            newItems.Add(
                new AlertItem
            {
                Time      = DateTime.Now,
                AlertTime = DateTime.Now,
                Notice    = "Test 1"
            }
                );

            AssertHelper.PropertyChangedEvent(viewModel, x => x.Items, () => viewModel.AddItems(newItems));
            Assert.AreEqual(1, viewModel.Items.Count);
        }
        public void PropertiesWithNotification()
        {
            MultiThreadingObservableCollection<IAlertItem> items = new MultiThreadingObservableCollection<IAlertItem>();
            MockAlertDialogView view = new MockAlertDialogView();
            AlertDialogViewModel viewModel = new AlertDialogViewModel(view, items);

            Assert.AreEqual(items, viewModel.Items);
            Assert.AreEqual(0, viewModel.Items.Count);

            bool hasAlertSound = viewModel.HasAlertSound;

            AssertHelper.PropertyChangedEvent(viewModel, x => x.HasAlertSound, () => viewModel.HasAlertSound = !hasAlertSound);
            Assert.AreEqual(!hasAlertSound, viewModel.HasAlertSound);

            MultiThreadingObservableCollection<IAlertItem> newItems = new MultiThreadingObservableCollection<IAlertItem>();
            newItems.Add(
                new AlertItem
                {
                    Time = DateTime.Now,
                    AlertTime = DateTime.Now,
                    Notice = "Test 1"
                }
            );

            AssertHelper.PropertyChangedEvent(viewModel, x => x.Items, () => viewModel.AddItems(newItems));
            Assert.AreEqual(1, viewModel.Items.Count);
        }
示例#3
0
 public DataService()
 {
     this.userBugs              = new MultiThreadingObservableCollection <Bug>();
     this.teamBugs              = new MultiThreadingObservableCollection <Bug>();
     this.refreshTime           = DateTime.Now;
     this.userBugsQueryState    = QueryStatus.QureyPause;
     this.userBugsProgressValue = 0;
     this.teamBugsQueryState    = QueryStatus.QureyPause;
     this.teamBugsProgressValue = 0;
     this.initializeStatus      = InitializeStatus.Initializing;
 }
示例#4
0
 public DataService()
 {
     this.userBugs = new MultiThreadingObservableCollection<Bug>();
     this.teamBugs = new MultiThreadingObservableCollection<Bug>();
     this.refreshTime = DateTime.Now;
     this.userBugsQueryState = QueryStatus.QureyPause;
     this.userBugsProgressValue = 0;
     this.teamBugsQueryState = QueryStatus.QureyPause;
     this.teamBugsProgressValue = 0;
     this.initializeStatus = InitializeStatus.Initializing;
 }
示例#5
0
        public DataService()
        {
            this.items = new MultiThreadingObservableCollection<IAlertItem>();
            this.alertedItems = new MultiThreadingObservableCollection<IAlertItem>();
            this.selectedItems = new ObservableCollection<IAlertItem>();

            this.branches = new ObservableCollection<string>();

            AddWeakEventListener(this.items, ItemsChanged);
            AddWeakEventListener(this.selectedItems, SelectedItemsChanged);
            AddWeakEventListener(this.alertedItems, AlertedItemsChanged);
        }
示例#6
0
        public void AlertDialogViewModelCloseTest()
        {
            MultiThreadingObservableCollection <IAlertItem> items = new MultiThreadingObservableCollection <IAlertItem>();

            items.Add(new AlertItem
            {
                Time      = DateTime.Now,
                AlertTime = DateTime.Now,
                Notice    = "Test 1"
            }
                      );
            items.Add(new AlertItem
            {
                Time      = DateTime.Now,
                AlertTime = DateTime.Now,
                Notice    = "Test 2"
            }
                      );
            items.Add(new AlertItem
            {
                Time      = DateTime.Now,
                AlertTime = DateTime.Now,
                Notice    = "Test 3"
            }
                      );

            Assert.AreEqual(false, items[0].HasAlert);
            Assert.AreEqual(false, items[1].HasAlert);
            Assert.AreEqual(false, items[2].HasAlert);

            MockAlertDialogView  view      = new MockAlertDialogView();
            AlertDialogViewModel viewModel = new AlertDialogViewModel(view, items);

            Assert.AreEqual(items, viewModel.Items);

            object owner = new object();

            view.ShowDialogAction = v =>
            {
                viewModel.OKCommand.Execute(null);
            };
            bool?dialogResult = viewModel.ShowDialog(owner);

            Assert.AreEqual(true, dialogResult);

            Assert.AreEqual(true, items[0].HasAlert);
            Assert.AreEqual(true, items[1].HasAlert);
            Assert.AreEqual(true, items[2].HasAlert);
        }
        public void AlertDialogViewModelCloseTest()
        {
            MultiThreadingObservableCollection<IAlertItem> items = new MultiThreadingObservableCollection<IAlertItem>();
            items.Add(new AlertItem
                {
                    Time = DateTime.Now,
                    AlertTime = DateTime.Now,
                    Notice = "Test 1"
                }
            );
            items.Add(new AlertItem
                {
                    Time = DateTime.Now,
                    AlertTime = DateTime.Now,
                    Notice = "Test 2"
                }
            );
            items.Add(new AlertItem
                {
                    Time = DateTime.Now,
                    AlertTime = DateTime.Now,
                    Notice = "Test 3"
                }
            );

            Assert.AreEqual(false, items[0].HasAlert);
            Assert.AreEqual(false, items[1].HasAlert);
            Assert.AreEqual(false, items[2].HasAlert);

            MockAlertDialogView view = new MockAlertDialogView();
            AlertDialogViewModel viewModel = new AlertDialogViewModel(view, items);

            Assert.AreEqual(items, viewModel.Items);

            object owner = new object();
            view.ShowDialogAction = v =>
            {
                viewModel.OKCommand.Execute(null);
            };
            bool? dialogResult = viewModel.ShowDialog(owner);
            Assert.AreEqual(true, dialogResult);

            Assert.AreEqual(true, items[0].HasAlert);
            Assert.AreEqual(true, items[1].HasAlert);
            Assert.AreEqual(true, items[2].HasAlert);
        }
示例#8
0
        private void ShowAlert()
        {
            // Show the Alert dialg view to the user
            IAlertDialogView  alertDialog  = container.GetExportedValue <IAlertDialogView>();
            List <IAlertItem> newAlertItem = this.dataService.AlertedItems.Where(c => !c.HasAlert).ToList();;

            if (this.alertDialogViewModel == null)
            {
                MultiThreadingObservableCollection <IAlertItem> items = new MultiThreadingObservableCollection <IAlertItem>();

                this.alertDialogViewModel = new AlertDialogViewModel(alertDialog, items);
            }
            foreach (IAlertItem item in newAlertItem)
            {
                if (!this.alertDialogViewModel.Items.Contains(item))
                {
                    this.alertDialogViewModel.Items.Add(item);
                }
            }
            this.alertDialogViewModel.HasAlertSound = Settings.Default.HasAlertSound;

            this.alertDialogViewModel.ShowDialog(this.shellService.ShellView);
        }
示例#9
0
 public AlertDialogViewModel(IAlertDialogView view, MultiThreadingObservableCollection <IAlertItem> items)
     : base(view)
 {
     this.okCommand = new DelegateCommand(CloseCommand);
     this.items     = items;
 }