Inheritance: INotifyPropertyChanged
        public void should_load_the_user_from_the_id_on_the_principal()
        {
            var model = new TestViewModel();
            _behavior.PrepareInput(model);

            _repo.AssertWasCalled(r => r.Load<User>(_userId));
        }
            public void ReturnsViewModelCommandManagerForViewModel()
            {
                var viewModel = new TestViewModel();
                var viewModelCommandManager = ViewModelCommandManager.Create(viewModel);

                Assert.IsNotNull(viewModelCommandManager);
            }
            public void ThrowsArgumentNullExceptionForNullHandler()
            {
                var viewModel = new TestViewModel();
                var viewModelCommandManager = ViewModelCommandManager.Create(viewModel);

                ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => viewModelCommandManager.AddHandler(null));
            }            
        public void TestPropertyChangedSend()
        {
            Messenger.Reset();
            var receivedDateTimeMessengerOld = DateTime.MaxValue;
            var receivedDateTimeMessengerNew = DateTime.MinValue;
            var receivedDateTimeLocal = DateTime.MinValue;

            Messenger.Default.Register<PropertyChangedMessage<DateTime>>(this, m =>
                {
                    if (m.PropertyName == TestViewModel.LastChanged1PropertyName)
                    {
                        receivedDateTimeMessengerOld = m.OldValue;
                        receivedDateTimeMessengerNew = m.NewValue;
                    }
                });

            var vm = new TestViewModel();
            vm.PropertyChanged += (s, e) =>
                {
                    if (e.PropertyName == TestViewModel.LastChanged1PropertyName)
                    {
                        receivedDateTimeLocal = vm.LastChanged1;
                    }
                };

            var now = DateTime.Now;
            vm.LastChanged1 = now;

            Assert.AreEqual(now, vm.LastChanged1);
            Assert.AreEqual(DateTime.MinValue, receivedDateTimeMessengerOld);
            Assert.AreEqual(now, receivedDateTimeMessengerNew);
            Assert.AreEqual(now, receivedDateTimeLocal);
        }
 public void InputOfPropertyShouldBeCheckboxIfPropertyIsABool()
 {
     var model = new TestViewModel();
     var helper = MvcMockHelpers.GetHtmlHelper(model);
     var tag = helper.Input(x => x.IsCorrect);
     tag.Attr("type").ShouldBe("checkbox");
 }
        public void ExtenstionTest2() {
            var service = new TestDialogService();
            var viewModel = new TestViewModel();
            var parentViewModel = new TestViewModel();
            var commands = new List<UICommand>();

            service = new TestDialogService();
            service.ShowDialog(commands, "title1", viewModel);
            Assert.AreEqual(commands, service.Commands);
            Assert.AreEqual("title1", service.Title);
            Assert.AreEqual(null, service.DocumentType);
            Assert.AreEqual(null, service.Parameter);
            Assert.AreEqual(viewModel, service.ViewModel);
            Assert.AreEqual(null, service.ParentViewModel);

            service = new TestDialogService();
            commands = new List<UICommand>();
            service.ShowDialog(commands, "title1", "docType", viewModel);
            Assert.AreEqual(commands, service.Commands);
            Assert.AreEqual("title1", service.Title);
            Assert.AreEqual("docType", service.DocumentType);
            Assert.AreEqual(null, service.Parameter);
            Assert.AreEqual(viewModel, service.ViewModel);
            Assert.AreEqual(null, service.ParentViewModel);


            service = new TestDialogService();
            service.ShowDialog(commands, "title3", "docType2", "param", parentViewModel);
            Assert.AreEqual(commands, service.Commands);
            Assert.AreEqual("title3", service.Title);
            Assert.AreEqual("docType2", service.DocumentType);
            Assert.AreEqual("param", service.Parameter);
            Assert.AreEqual(null, service.ViewModel);
            Assert.AreEqual(parentViewModel, service.ParentViewModel);
        }
 public void PropertyWithHiddenInputAttributeShouldMakeTheTypeHidden()
 {
     var model = new TestViewModel();
     var tag = MvcMockHelpers.GetHtmlHelper(model).Input(x => x.Hidden);
     tag.TagName().ShouldBe("input");
     tag.Attr("type").ShouldBe("hidden");
 }
 public void PropertyWithDataTypePasswordAttributeShouldHaveTheTypePassword()
 {
     var model = new TestViewModel();
     var tag = MvcMockHelpers.GetHtmlHelper(model).Input(x => x.Password);
     tag.TagName().ShouldBe("input");
     tag.Attr("type").ShouldBe("password");
 }
 public virtual void InitializeTest(TestViewModel viewModel) {
     // This is called when a TestViewModel is created
     viewModel.DoSomething.Action = this.DoSomethingHandler;
     viewModel.DoSomethingElse.Action = this.DoSomethingElseHandler;
     viewModel.CommandReference.Action = this.CommandReferenceHandler;
     TestViewModelManager.Add(viewModel);
 }
        public void DefaultViewModelSerializer_NoEncryptedValues()
        {
            var oldViewModel = new TestViewModel()
            {
                Property1 = "a",
                Property2 = 4,
                Property3 = new DateTime(2000, 1, 1),
                Property4 = new List<TestViewModel2>()
                {
                    new TestViewModel2() { PropertyA = "t", PropertyB = 15 },
                    new TestViewModel2() { PropertyA = "xxx", PropertyB = 16 }
                },
                Property5 = null
            };
            context.ViewModel = oldViewModel;
            serializer.BuildViewModel(context);
            var result = context.GetSerializedViewModel();
            result = UnwrapSerializedViewModel(result);
            result = WrapSerializedViewModel(result);

            var newViewModel = new TestViewModel();
            context.ViewModel = newViewModel;
            serializer.PopulateViewModel(context, result);

            Assert.AreEqual(oldViewModel.Property1, newViewModel.Property1);
            Assert.AreEqual(oldViewModel.Property2, newViewModel.Property2);
            Assert.AreEqual(oldViewModel.Property3, newViewModel.Property3);
            Assert.AreEqual(oldViewModel.Property4[0].PropertyA, newViewModel.Property4[0].PropertyA);
            Assert.AreEqual(oldViewModel.Property4[0].PropertyB, newViewModel.Property4[0].PropertyB);
            Assert.AreEqual(oldViewModel.Property4[1].PropertyA, newViewModel.Property4[1].PropertyA);
            Assert.AreEqual(oldViewModel.Property4[1].PropertyB, newViewModel.Property4[1].PropertyB);
            Assert.AreEqual(oldViewModel.Property5, newViewModel.Property5);
        }
Exemplo n.º 11
0
 public void ViewModel_NavigationReturnsNavigation()
 {
     var mockNav = Mock.Of<INavigation>();
     Container.Current.RegisterInstance<INavigation>(mockNav);
     var t = new TestViewModel();
     Assert.That(t.Navigation, Is.Not.Null);
 }
Exemplo n.º 12
0
        public void Can_Use_MerchelloContext_In_RazorEngine()
        {
            //// Arrange
            var model = new TestViewModel();
            model.MerchelloContext = MerchelloContext.Current;
            model.Product = _product.ToProductDisplay();

            var template = @"
            @{
                var product = Model.MerchelloContext.Services.ProductService.GetByKey(Model.Product.Key);
            }

            <html>
                <body>
                    <div>@Model.Product.Name, @Model.Product.Sku, @Model.Product.Price</div>

                    <ul>
                    @foreach(var option in Model.Product.ProductOptions)
                    {
                        <li>@option.Name</li>
                    }
                    </ul>
                </body>
            </html>";

            //// Act
            var result = Razor.Parse(template, model);

            //// Assert
            Assert.NotNull(result);
            Assert.IsTrue(result.Contains("Color"));
        }
Exemplo n.º 13
0
 public void SetUp()
 {
     viewModel = new TestViewModel()
                     {
                         Id = -10
                     };
 }
Exemplo n.º 14
0
        public void TestDisableCommandAndRectangle()
        {
            var trigger = new EventToCommand
            {
                MustToggleIsEnabledValue = true
            };

            var rectangle = new Rectangle();

            ((IAttachedObject)trigger).Attach(rectangle);

            var vm = new TestViewModel();
            var binding = new Binding
            {
                Source = vm.ToggledCommand
            };

            vm.EnableToggledCommand = false;

            #if SILVERLIGHT3
            trigger.Command = binding;
            #else
            BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
            #endif

            #if !SILVERLIGHT
            Assert.IsFalse(rectangle.IsEnabled);
            #endif
            trigger.Invoke();
            Assert.IsFalse(vm.CommandExecuted);
        }
        public void ExpressionEvaluator_UpdateSource_Simple()
        {
            var viewModel = new TestViewModel() { SubObject = new TestViewModel2() { Value = "hello" } };
            var view = new RedwoodView()
            {
                DataContext = viewModel,
                Children =
                {
                    new HtmlGenericControl("html")
                    {
                        Children =
                        {
                            new TextBox()
                            {
                                ID = "txb"
                            }
                            .WithBinding(TextBox.TextProperty, new ValueBindingExpression("Value"))
                        }
                    }
                    .WithBinding(RedwoodBindableControl.DataContextProperty, new ValueBindingExpression("SubObject"))
                }
            };
            var textbox = view.FindControl("txb") as TextBox;
            var binding = textbox.GetBinding(TextBox.TextProperty) as ValueBindingExpression;

            binding.UpdateSource("test", textbox, TextBox.TextProperty);

            Assert.AreEqual("test", viewModel.SubObject.Value);
        }
 public void PropertyWithRequiredAttributeDefinedShouldHaveRequiredClass()
 {
     var model = new TestViewModel();
     var helper = MvcMockHelpers.GetHtmlHelper(model);
     helper.ViewContext.HttpContext.Items[TagGenerator.FORMINPUTTYPE] = typeof (TestInputModel);
     var tag = helper.Input(x => x.Name);
     tag.HasClass("required").ShouldBe(true);
 }
Exemplo n.º 17
0
 public void TestPropertyChangedIsRaisedCorrectly()
 {
     TestViewModel target = new TestViewModel();
     bool eventWasRaised = false;
     target.PropertyChanged += (sender, e) => eventWasRaised = e.PropertyName == "GoodProperty";
     target.GoodProperty = "Some new value...";
     Assert.IsTrue(eventWasRaised, "PropertyChanged event was not raised correctly.");
 }
Exemplo n.º 18
0
            public void ThrowsArgumentNullExceptionForNullModel()
            {
                var model = new Person();
                var vm = new TestViewModel(model);
                var vmManager = new ViewModelManager();

                ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => vmManager.UnregisterModel(vm, null));
            }
Exemplo n.º 19
0
 public void TestPropertyChangedShouldRaiseCorrectly()
 {
     var target = new TestViewModel();
     bool eventWasRaised = false;
     target.PropertyChanged += (sender, e) => eventWasRaised = e.PropertyName == "SomeProperty";
     target.SomeProperty = "Some value";
     Assert.IsTrue(eventWasRaised, "PropertyChanged event was not raised correctly.");
 }
 public void PropertyWithDataTypePasswordAttributeShouldHaveNoValue()
 {
     var model = new TestViewModel() { Password = "******"};
     var helper = MvcMockHelpers.GetHtmlHelper(model);
     var tag = helper.Input(x => x.Password);
     tag.TagName().ShouldBe("input");
     tag.Attr("value").ShouldBe("");
 }
 public void PropertyWithStringLengthAttributeDefinedShouldHaveMaxLengthAttr()
 {
     var model = new TestViewModel();
     var helper = MvcMockHelpers.GetHtmlHelper(model);
     helper.ViewContext.HttpContext.Items[TagGenerator.FORMINPUTTYPE] = typeof(TestInputModel);
     var tag = helper.Input(x => x.Name);
     tag.HasAttr("maxlength").ShouldBe(true);
     tag.Attr("maxlength").ShouldBe("20");
 }
Exemplo n.º 22
0
        public ActionResult Create(TestViewModel model)
        {
            if (ModelState.IsValid) return RedirectToAction("Index");
            model.Items = CreateItemsList();
             
            return View(model);

            //do save here
        }
        public void VmIsValidWhenNoValidatorsInPlace()
        {
            var vm = new TestViewModel();

            var validationResult = validationProvider.Validate(vm);

            Assert.True(validationResult.IsModelValid());
            Assert.True(validationResult.GetErrorCount() == 0);
        }
        public void should_not_do_anything_if_no_principal_is_loaded()
        {
            Thread.CurrentPrincipal = _previousPrin;

            var model = new TestViewModel();
            _behavior.ModifyOutput(model);

            model.CurrentUser.ShouldBeNull();
        }
Exemplo n.º 25
0
        public void ViewModelValidator_SimpleObject()
        {
            var testViewModel = new TestViewModel();
            var validator = new ViewModelValidator();
            var results = validator.ValidateViewModel(testViewModel).OrderBy(n => n.PropertyPath).ToList();

            Assert.AreEqual(1, results.Count);
            Assert.AreEqual("Text", results[0].PropertyPath);
        }
Exemplo n.º 26
0
 public void PropertyWithNotEmptyFluentValidationDefinedShouldHaveUnObtrusiveDataAttributesWithDefaultMessage()
 {
     var model = new TestViewModel();
     var helper = MvcMockHelpers.GetHtmlHelper(model);
     helper.ViewContext.UnobtrusiveJavaScriptEnabled = true;
     helper.ViewContext.HttpContext.Items[TagGenerator.FORMINPUTTYPE] = typeof(TestInputModel);
     var tag = helper.Input(x => x.CreditCard);
     tag.Attr("data-val-required").ShouldBe("'Credit Card' should not be empty.");
 }
Exemplo n.º 27
0
 public void LabelOfPropertyShouldByDefaultUseSpanTag()
 {
     var model = new TestViewModel();
     Expression<Func<TestViewModel, object>> expression = x => x.Name;
     var tag = MvcMockHelpers.GetHtmlHelper(model).Label(expression);
     var name = expression.GetMemberExpression(false).Member.Name;
     tag.TagName().ShouldBe("label");
     tag.Text().ShouldBe(name);
 }
        public void AllDisplaysShouldHaveIdWithDisplaySuffix()
        {
            var model = new TestViewModel();
            var helper = MvcMockHelpers.GetHtmlHelper(model);

            var tag = helper.Display(x => x.Name);

            tag.Attr("id").ShouldBe("Name_Display");
        }
 public void PropertyWithCompareAttributeDefinedShouldHaveValEqualToPassword()
 {
     var model = new TestViewModel();
     var helper = MvcMockHelpers.GetHtmlHelper(model);
     helper.ViewContext.HttpContext.Items[TagGenerator.FORMINPUTTYPE] = typeof(TestInputModel);
     var tag = helper.Input(x => x.PasswordConfirm);
     tag.Data("val-equalto").ShouldBe("The Error");
     tag.Data("val-equalto-other").ShouldBe("*.Password");
 }
Exemplo n.º 30
0
        public void PropertyChanged_is_raised_correctly_when_a_property_is_changed()
        {
            var target = new TestViewModel();
            var eventWasRaised = false;
            target.PropertyChanged += (sender, e) => eventWasRaised = e.PropertyName == "GoodProperty";

            target.GoodProperty = "Some new value...";

            Assert.IsTrue(eventWasRaised);
        }
Exemplo n.º 31
0
        public ViewResult Edit(int Id)
        {
            TestViewModel test = TestService.GetTestEntity(Id).ToMvcTest();

            return(View(test));
        }
Exemplo n.º 32
0
 public void SetUp()
 {
     _uut = new TestViewModel();
 }
Exemplo n.º 33
0
 public TestView()
 {
     InitializeComponent();
     testViewModel       = new TestViewModel(this.Navigation);
     this.BindingContext = testViewModel;
 }
Exemplo n.º 34
0
 public void SetUp()
 {
     _testViewModel = new TestViewModel();
 }
 private void M1(object sender, System.Timers.ElapsedEventArgs e)  //5
 {
     Application.Current.Dispatcher.Invoke(() => testViewModel = new TestViewModel(GroupBoxDynamicChart, list));
 }
 public void SetUp()
 {
     _config   = new SiteConfiguration();
     _model    = new TestViewModel();
     _behavior = new set_the_current_site_details_on_the_output_viewmodel(_config);
 }
Exemplo n.º 37
0
 public TestView()
 {
     InitializeComponent();
     TestViewModel = new TestViewModel();
     DataContext   = TestViewModel;
 }
Exemplo n.º 38
0
 public TestPage()
 {
     InitializeComponent();
     //LabelTest.Text = AppResources.TestLabel;
     BindingContext = viewModel = new TestViewModel();
 }
Exemplo n.º 39
0
        async Task RefreshScene()
        {
            if (!Directory.Exists(this.CurrentScene.Value1))
            {
                MessageService.ShowSnackMessageWithNotice("场景路径不存在,请检查"); return;
            }

            this.Files.Clear();

            ManualResetEvent waitHandle = new ManualResetEvent(false);

            await MessageService.ShowWinProgressBarMessage <bool>(l =>
            {
                l.Message = "读取文件中...";

                var extends = this.SelectedTemplate.Value1?.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                Predicate <FileInfo> match = m =>
                {
                    if (extends == null || extends.Count() == 0)
                    {
                        return(true);
                    }

                    return(extends.Count(k => k == m.Extension) > 0);
                };

                var files = this.GetFiles(this.CurrentScene.Value1, match);

                if (files == null || files.Count == 0)
                {
                    return(false);
                }

                l.Message = "加载文件中...";

                for (int i = 0; i < files.Count; i++)
                {
                    var item = files[i];

                    TestViewModel model = new TestViewModel();

                    model.Value = item.Name;

                    model.Value1 = item.FullName;

                    model.Value2 = item.Extension;

                    model.Int1 = i;

                    System.Windows.Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new Action(() =>
                    {
                        this.Files.Add(model);

                        l.Value = double.Parse(model.Int1.ToString()) * 100 / double.Parse((files.Count - 1).ToString());

                        if (model.Int1 == files.Count - 1)
                        {
                            waitHandle.Set();
                        }
                    }));
                }

                waitHandle.WaitOne();

                return(true);
            });

            MessageService.ShowSnackMessageWithNotice($"场景加载完成 <{this.CurrentScene.Value}>");
        }
 public ViewModelsAndProperties()
 {
     InitializeComponent();
     BindingContext = new TestViewModel();
 }
Exemplo n.º 41
0
        public ActionResult Index(string searchStringName, string currentFilter, int?page)
        {
            GetCurrentUserInViewBag();

            try
            {
                int intPage           = 1;
                int intPageSize       = 10;
                int intTotalPageCount = 0;

                if (searchStringName != null)
                {
                    intPage = 1;
                }
                else
                {
                    if (currentFilter != null)
                    {
                        searchStringName = currentFilter;
                        intPage          = page ?? 1;
                    }
                    else
                    {
                        searchStringName = "";
                        intPage          = page ?? 1;
                    }
                }

                ViewBag.CurrentFilter = searchStringName;
                List <TestViewModel> StudentInventorylist = new List <TestViewModel>();
                int intSkip = (intPage - 1) * intPageSize;
                intTotalPageCount = db.Students
                                    .Where(x => x.StudentFirstName.Contains(searchStringName))
                                    .Count();

                var datalist = db.Students
                               .Where(x => x.StudentLastName.Contains(searchStringName) || x.StudentFirstName.Contains(searchStringName) || x.StudentID.Contains(searchStringName))
                               .OrderBy(x => x.StudentLastName)
                               .Skip(intSkip)
                               .Take(intPageSize)
                               .ToList();

                foreach (var item in datalist)
                {
                    TestViewModel pvm = new TestViewModel();
                    pvm.StudentFirstName  = item.StudentFirstName;
                    pvm.StudentMiddleName = item.StudentMiddleName;
                    pvm.StudentLastName   = item.StudentLastName;
                    pvm.UserID            = item.UserID;

                    StudentInventorylist.Add(pvm);
                }

                // Set the number of pages
                var _UserAsIPagedList =
                    new StaticPagedList <TestViewModel>
                    (
                        StudentInventorylist, intPage, intPageSize, intTotalPageCount
                    );

                return(View(_UserAsIPagedList));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, "Error: " + ex);
                List <TestViewModel> StudentInventorylist = new List <TestViewModel>();

                return(View(StudentInventorylist.ToPagedList(1, 25)));
            }
        }
        public ListViewPage(bool insideLayout)
        {
            Title = "ListView (Pull to Refresh)";

            BindingContext = new TestViewModel(this);

            var listView = new ListView();

            //ListView now has a built in pull to refresh!
            //You most likely could enable the listview pull to refresh and use it instead of the refresh view
            //listView.IsPullToRefreshEnabled = true;
            //
            //listView.SetBinding<TestViewModel>(ListView.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay);
            //listView.SetBinding<TestViewModel>(ListView.RefreshCommandProperty, vm => vm.RefreshCommand);



            listView.SetBinding(ItemsView <Cell> .ItemsSourceProperty, new Binding("Items"));

            //ListView now has a built in pull to refresh!
            //You most likely could disable the listview pull to refresh and re-enable this
            //However, I wouldn't recommend that.
            var refreshView = new PullToRefreshLayout
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Content           = new StackLayout
                {
                    Spacing  = 0,
                    Children =
                    {
                        new Label
                        {
                            TextColor             = Color.White,
                            Text                  = "In a StackLayout",
                            FontSize              = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                            BackgroundColor       = Color.FromHex("#3498db"),
                            VerticalTextAlignment = TextAlignment.Center,
                            HorizontalOptions     = LayoutOptions.FillAndExpand
                        },
                        listView
                    }
                },
                RefreshColor = Color.FromHex("#3498db")
            };

            refreshView.SetBinding(PullToRefreshLayout.IsRefreshingProperty, new Binding("IsBusy", BindingMode.OneWay));
            refreshView.SetBinding(PullToRefreshLayout.RefreshCommandProperty, new Binding("RefreshCommand"));
            refreshView.SetBinding(PullToRefreshLayout.IsPullToRefreshEnabledProperty, new Binding("CanRefresh"));

            if (insideLayout)
            {
                Content = new StackLayout
                {
                    Spacing  = 0,
                    Children =
                    {
                        new Label
                        {
                            TextColor             = Color.White,
                            Text                  = "In a StackLayout",
                            FontSize              = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                            BackgroundColor       = Color.FromHex("#3498db"),
                            VerticalTextAlignment = TextAlignment.Center,
                            HorizontalOptions     = LayoutOptions.FillAndExpand
                        },
                        refreshView
                    }
                };
            }
            else
            {
                Content = refreshView;
            }
        }
Exemplo n.º 43
0
        public void CollectionManipulation()
        {
            var viewModel = new TestViewModel();

            Assert.IsNotNull(viewModel.Children);
            Assert.AreEqual(0, viewModel.Children !.Count);

            NotifyCollectionChangedEventArgs?args = null;
            int notifyCount = 0;

            viewModel.Children.CollectionChanged += (s, e) =>
            {
                Assert.AreEqual(viewModel.Children, s);
                Assert.IsNotNull(e);
                args = e;
                notifyCount++;
            };

            var child = new TestViewModel();

            viewModel.Children.Add(child);
            Assert.AreEqual(1, viewModel.Children.Count);
            Assert.AreSame(child, viewModel.Children[0]);
            CheckCollectionChangedArgs(ref args, ref notifyCount, NotifyCollectionChangedAction.Add, -1, 0, null, new List <TestViewModel> {
                child
            });

            var child2 = new TestViewModel();

            viewModel.Children.Add(child2);
            Assert.AreEqual(2, viewModel.Children.Count);
            Assert.AreSame(child2, viewModel.Children[1]);
            CheckCollectionChangedArgs(ref args, ref notifyCount, NotifyCollectionChangedAction.Add, -1, 1, null, new List <TestViewModel> {
                child2
            });

            viewModel.Children.Remove(child);
            Assert.AreEqual(1, viewModel.Children.Count);
            Assert.AreSame(child2, viewModel.Children[0]);
            CheckCollectionChangedArgs(ref args, ref notifyCount, NotifyCollectionChangedAction.Remove, 0, -1, new List <TestViewModel> {
                child
            }, null);

            viewModel.Children.Add(child);
            viewModel.Children.RemoveAt(0);
            Assert.AreEqual(1, viewModel.Children.Count);
            Assert.AreSame(child, viewModel.Children[0]);
            Assert.IsTrue(viewModel.Children.Contains(child));
            Assert.IsFalse(viewModel.Children.Contains(child2));
            CheckCollectionChangedArgs(ref args, ref notifyCount, NotifyCollectionChangedAction.Remove, 0, -1, new List <TestViewModel> {
                child2
            }, null, 2);

            var vm1 = new TestViewModel();
            var vm2 = new TestViewModel();
            var vm3 = new TestViewModel();

            viewModel.Children.AddRange(new List <TestViewModel> {
                vm1, vm2, vm3
            });
            Assert.AreEqual(4, viewModel.Children.Count);
            Assert.AreSame(child, viewModel.Children[0]);
            CheckCollectionChangedArgs(ref args, ref notifyCount, NotifyCollectionChangedAction.Add, -1, 3, null, new List <TestViewModel> {
                vm3
            }, 3);

            viewModel.Children.Insert(1, vm3);
            Assert.AreEqual(5, viewModel.Children.Count);
            Assert.AreSame(child, viewModel.Children[0]);
            Assert.AreSame(vm3, viewModel.Children[1]);
            CheckCollectionChangedArgs(ref args, ref notifyCount, NotifyCollectionChangedAction.Add, -1, 1, null, new List <TestViewModel> {
                vm3
            });

            viewModel.Children.Replace(vm3, vm2, vm1);
            Assert.AreEqual(3, viewModel.Children.Count);
            Assert.AreSame(vm3, viewModel.Children[0]);
            Assert.AreSame(vm2, viewModel.Children[1]);
            Assert.AreSame(vm1, viewModel.Children[2]);
            CheckCollectionChangedArgs(ref args, ref notifyCount, NotifyCollectionChangedAction.Add, -1, 2, null, new List <TestViewModel> {
                vm1
            }, 4);

            viewModel.Children.Clear();
            Assert.AreEqual(0, viewModel.Children.Count);
            Assert.IsFalse(viewModel.Children.Contains(vm3));
            Assert.IsFalse(viewModel.Children.Contains(vm2));
            Assert.IsFalse(viewModel.Children.Contains(vm1));
            CheckCollectionChangedArgs(ref args, ref notifyCount, NotifyCollectionChangedAction.Reset, -1, -1, (IEnumerable <TestViewModel>?)null, null);
        }
Exemplo n.º 44
0
        public void UpdateTest(string testGuid, TestViewModel test)
        {
            var testFromDomain = _advancedMapper.MapTestViewModel(test);

            _highLevelTestManagementService.UpdateTest(testGuid, testFromDomain);
        }
Exemplo n.º 45
0
 public ActionResult Test(TestViewModel model)
 {
     return(View());
 }
Exemplo n.º 46
0
 public PreviousCommand(TestViewModel viewmodel)
 {
     _viewmodel = viewmodel;
 }
Exemplo n.º 47
0
        public StackLayoutPage(bool insideLayout)
        {
            var random = new Random();

            Title = "StackLayout (Pull to Refresh)";

            BindingContext = new TestViewModel(this);

            var stack = new StackLayout
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Spacing           = 0
            };

            for (int i = 0; i < 20; i++)
            {
                stack.Children.Add(new BoxView
                {
                    HeightRequest     = 150,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    BackgroundColor   = Color.FromRgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255))
                });
            }

            var refreshView = new PullToRefreshLayout {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Content           = stack,
                RefreshColor      = Color.FromHex("#3498db")
            };

            refreshView.SetBinding <TestViewModel> (PullToRefreshLayout.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay);
            refreshView.SetBinding <TestViewModel>(PullToRefreshLayout.RefreshCommandProperty, vm => vm.RefreshCommand);


            if (insideLayout)
            {
                var activity = new ActivityIndicator();
                activity.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
                Content = new StackLayout
                {
                    Spacing  = 0,
                    Children =
                    {
                        activity,
                        new Label
                        {
                            TextColor         = Color.White,
                            Text              = "In a StackLayout",
                            FontSize          = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                            BackgroundColor   = Color.FromHex("#3498db"),
                            XAlign            = TextAlignment.Center,
                            HorizontalOptions = LayoutOptions.FillAndExpand
                        },
                        refreshView
                    }
                };
            }
            else
            {
                Content = refreshView;
            }
        }
 public IActionResult CreateTest([FromForm] TestViewModel test)
 {
     uof.Test.CreateTest(test);
     uof.Save();
     return(RedirectToAction("Index"));
 }
Exemplo n.º 49
0
 public TestView()
 {
     InitializeComponent();
     testModel      = new TestViewModel();
     BindingContext = testModel;
 }
Exemplo n.º 50
0
 public TestWindow(TestViewModel viewModel)
 {
     InitializeComponent();
     DataContext = viewModel;
 }
 public IActionResult Index(TestViewModel vm)
 {
     return(View(vm));
 }
Exemplo n.º 52
0
        public ActionResult TestView()
        {
            var viewModel = new TestViewModel(this.viewModelFactory.GetViewModel());

            return(this.View(viewModel));
        }
        //  List<Keyvalue> tempList = new List<Keyvalue>();



        public MainWindow()
        {
            InitializeComponent();


            // GroupBoxDynamicChart


            //  testViewModel.TestModel.DataList = tempList;

            //Chart dynamicChart = new Chart();
            //LineSeries lineseries = new LineSeries();
            //// lineseries.ItemsSource = tempList;

            //lineseries.DependentValuePath = "Value";
            //lineseries.IndependentValuePath = "Key";
            //dynamicChart.Series.Add(lineseries);
            //GroupBoxDynamicChart.Content = dynamicChart;


            Timer = new System.Timers.Timer();

            // Timer.Interval = 5000;
            //// Timer.Elapsed += Async;
            // Timer.AutoReset = true;
            // Timer.Enabled = true;


            _timer = new System.Timers.Timer
            {
                // Interval set to 1 millisecond.
                Interval  = 5000,
                AutoReset = true,
            };

            _timer.Elapsed += _timer_Elapsed;
            _timer.Enabled  = true;
            _timer.Start();

            _timerMemory = new System.Timers.Timer
            {
                Interval  = 2000,
                AutoReset = true,
            };
            _timerMemory.Elapsed += _timer_Memory;
            _timerMemory.Enabled  = true;
            _timerMemory.Start();


            _memory = new System.Timers.Timer
            {
                Interval  = 5000,
                AutoReset = true
            };
            _memory.Elapsed += M1;
            _memory.Enabled  = true;
            _memory.Start();


            _cleatmemory = new System.Timers.Timer
            {
                Interval  = 60000,
                AutoReset = true
            };
            _cleatmemory.Elapsed += Clear;
            _cleatmemory.Enabled  = true;
            _cleatmemory.Start();


            processesThreds = new ProcessesThreds();
            // List<ProcessesThreds> processesThredslist =

            //var res = from p in processesThreds.GetActiveProcesses() orderby p.ProcessName select p;
            GridView myGridView = new GridView();

            myGridView.AllowsColumnReorder = true;
            myGridView.Columns.Add(new GridViewColumn()
            {
                Header = "Id", Width = 50, DisplayMemberBinding = new Binding("Id")
            });
            myGridView.Columns.Add(new GridViewColumn()
            {
                Header = "Name", Width = 200, DisplayMemberBinding = new Binding("ProcessName")
            });
            myGridView.Columns.Add(new GridViewColumn()
            {
                Header = "Threads", Width = 100, DisplayMemberBinding = new Binding("Threads.Count")
            });
            myGridView.Columns.Add(new GridViewColumn()
            {
                Header = "HandleCount", Width = 100, DisplayMemberBinding = new Binding("HandleCount")
            });
            myGridView.Columns.Add(new GridViewColumn()
            {
                Header = "PrivateMemorySize64", Width = 200, DisplayMemberBinding = new Binding("PrivateMemorySize64")
            });


            ProcessesListView.View = myGridView;

            ProcessesListView.ItemsSource = from p in processesThreds.GetActiveProcesses() orderby p.ProcessName select p;



            ManagementObjectSearcher ramMonitor =    //запрос к WMI для получения памяти ПК
                                                  new ManagementObjectSearcher("SELECT TotalVisibleMemorySize,FreePhysicalMemory FROM Win32_OperatingSystem");

            ulong res = 0;

            foreach (ManagementObject objram in ramMonitor.Get())
            {
                ulong totalRam = Convert.ToUInt64(objram["TotalVisibleMemorySize"]);        //общая память ОЗУ
                ulong busyRam  = totalRam - Convert.ToUInt64(objram["FreePhysicalMemory"]); //занятная память = (total-free)
                res = ((busyRam * 100) / totalRam);
                Console.WriteLine(((busyRam * 100) / totalRam));                            //вычисляем проценты занятой памяти
            }

            List <Keyvalue> list = new List <Keyvalue>()
            {
                new Keyvalue()
                {
                    Key = DateTime.Now.ToString("h:mm:ss tt"), Value = res
                }
            };


            testViewModel = new TestViewModel(GroupBoxDynamicChart, list); //TestViewModel

            //  testViewModel.Add(GroupBoxDynamicChart,new Keyvalue() { Key = DateTime.Now.ToString("h:mm:ss tt"), Value = 89 });
            //  testViewModel.Add(GroupBoxDynamicChart, new Keyvalue() { Key = DateTime.Now.ToString("h:mm:ss tt"), Value = 90 });
            //  this.DataContext = testViewModel;



            //Memory();
        }
Exemplo n.º 54
0
        public ActionResult EditTest(int testId)
        {
            TestViewModel test = testService.GetTestByTestId(testId);

            return(View(test));
        }
Exemplo n.º 55
0
 public TestView()
 {
     this.InitializeComponent();
     ViewModel = new ViewModel.TestViewModel();
 }
Exemplo n.º 56
0
 public void PopulateScriptSnippets(TestViewModel model)
 {
     model.BeforeExecuteScriptSnippets = _configurationService.GetScriptSnippetFilenames(ScriptSnippetType.BeforeExecute);
 }
Exemplo n.º 57
0
        public void CreateTest(TestViewModel test)
        {
            var testFromDomain = _advancedMapper.MapTestViewModel(test);

            _highLevelTestManagementService.CreateTest(testFromDomain);
        }
 public TestPullToRefreshPage()
 {
     InitializeComponent();
     BindingContext = new TestViewModel(this);
 }
Exemplo n.º 59
0
 internal TestView(TestViewModel model)
 {
     BindingContext = model;
     InitializeComponent();
 }
Exemplo n.º 60
0
 public TestView(TestViewModel viewModel = null)
 {
     InitializeComponent();
     BindingContext = viewModel;
 }