Пример #1
0
        public Issue2270()
        {
            BindingContext = new TestListViewModel();

            Padding = new Thickness(0, 40, 0, 0);

            var btn = new Button {
                Text        = "Load Data",
                BorderWidth = 1,
                BorderColor = Color.Gray,
            };

            btn.SetBinding(Button.CommandProperty, "LoadDataCommand");

            var lv = new ListView();            // { IsGroupingEnabled = true };

            var dt = new DataTemplate(typeof(TextCell));

            dt.SetBinding(TextCell.TextProperty, "Name");

            lv.ItemTemplate = dt;
            lv.SetBinding(ListView.ItemsSourceProperty, "Rows");

            Content = new StackLayout {
                Children =
                {
                    btn,
                    lv
                }
            };
        }
Пример #2
0
        public List <TestListViewModel> GetAllAthleteTest()
        {
            List <TestListViewModel> lstTests = new List <TestListViewModel>();

            //lstTests = _context.TblAthleteTestMaster.Where(a => a.IsActive).ToList();

            using (SqlConnection con = new SqlConnection(ApplicationSettings.ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("GetAllAthleteTest", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    con.Open();
                    using (IDataReader idr = cmd.ExecuteReader())
                    {
                        while (idr.Read())
                        {
                            TestListViewModel objTests = new TestListViewModel();
                            objTests.Id            = Convert.ToInt32(idr["Id"]);
                            objTests.TestTypeId    = Convert.ToInt64(idr["TestTypeId"]);
                            objTests.TestDate      = Convert.ToDateTime(idr["TestDate"]);
                            objTests.TestType      = Convert.ToString(idr["TestType"]);
                            objTests.NumOfAttendee = idr["NumOfAttendee"] != null?Convert.ToInt32(idr["NumOfAttendee"]) : 0;

                            lstTests.Add(objTests);
                        }
                    }

                    con.Close();
                }
            }


            return(lstTests);
        }
Пример #3
0
        public void Setup()
        {
            TestCase = new TestCase("TestCase", "testcase.pmlobj");
            TestCase.Tests.Add("one").Result   = new TestResult(TimeSpan.FromSeconds(1));
            TestCase.Tests.Add("two").Result   = new TestResult(TimeSpan.FromSeconds(1), new PmlError("error"));
            TestCase.Tests.Add("three").Result = new TestResult(TimeSpan.FromSeconds(1));
            TestCase.Tests.Add("four");

            RunnerMock = new Mock <AsyncTestRunner>();
            RunnerMock
            .Setup(runner => runner.RunAsync(It.IsAny <IEnumerable <Test> >()))
            .Callback((IEnumerable <Test> tests) => Tests = tests);

            RunnerControl = new TestRunnerControl(Mock.Of <TestCaseProvider>(), RunnerMock.Object, Mock.Of <SettingsProvider>());
            TestSummary   = RunnerControl.FindControl <TestSummaryView>("TestSummary");
            TestList      = RunnerControl.FindControl <TestListView>("TestList");
            TestList.TestCases.Add(TestCase);

            Model = TestList.GetModel();

            foreach (var entry in Model.Entries)
            {
                var testEntry = entry as TestListTestEntry;
                if (testEntry != null)
                {
                    testEntry.IsSelected = testEntry.Test.Name == "two" || testEntry.Test.Name == "four";
                }
            }
        }
Пример #4
0
        public void AddingTestCaseAddsEntries()
        {
            // Arrange
            var testCase   = new TestCase("Test", "test.pmlobj");
            var firstTest  = testCase.Tests.Add("first");
            var secondTest = testCase.Tests.Add("second");
            var model      = new TestListViewModel();

            // Act
            model.TestCases.Add(testCase);
            // Assert
            Assert.Multiple(() =>
            {
                Assert.That(model.Entries.Count, Is.EqualTo(3));
                var group  = model.Entries[0] as TestListGroupEntry;
                var first  = model.Entries[1] as TestListTestEntry;
                var second = model.Entries[2] as TestListTestEntry;
                Assert.That(group.Entries, Is.EquivalentTo(new List <TestListTestEntry>()
                {
                    first, second
                }));
                Assert.That(first.Test, Is.SameAs(firstTest));
                Assert.That(first.Group, Is.SameAs(group));
                Assert.That(second.Test, Is.SameAs(secondTest));
                Assert.That(second.Group, Is.SameAs(group));
            });
        }
Пример #5
0
        public void VisibileEntriesAreEmptyByDefault()
        {
            // Arrange
            var model = new TestListViewModel();

            // Assert
            Assert.That(model.VisibleEntries, Is.Empty);
        }
Пример #6
0
 public ActionResult List()
 {
     TestListViewModel viewModel = new TestListViewModel
     {
         AreaTestDateList = DCTestService.QueryTestDateInfos().ToList(),
         TownList = towns
     };
     return View(viewModel);
 }
Пример #7
0
        // GET: TestBlock
        public ActionResult Index()
        {
            TestListViewModel testlistviewModel = new TestListViewModel()
            {
                rollersampleinfos = samplerepo.RollerSampleInfos.Where(x => x.State == true).Include(x => x.RollerBaseStation).Include(x => x.RollerProjectInfo)
            };

            return(View(testlistviewModel));
        }
Пример #8
0
        public ActionResult List()
        {
            TestListViewModel viewModel = new TestListViewModel
            {
                AreaTestDateList = DCTestService.QueryTestDateInfos().ToList(),
                TownList         = towns
            };

            return(View(viewModel));
        }
Пример #9
0
        protected override void Init()
        {
            Title = "Test Command Binding";
            _list = new ListView()
            {
                ClassId = "SampleList",
                // Note: Turning on and off row height does not effect the issue,
                // but with row heights on there is a visual glitch with the recyclyed row spacing
                //RowHeight = SampleViewCell.RowHeight,
                HasUnevenRows     = true,
                ItemTemplate      = new DataTemplate(typeof(SampleViewCell)),
                BackgroundColor   = Color.FromHex("E0E0E0"),
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            _list.SetBinding(ListView.ItemsSourceProperty, "Items");
            _list.SetBinding(ListView.RefreshCommandProperty, "RefreshCommand");
            _list.SetBinding(ListView.IsRefreshingProperty, "IsRefreshing");

            var listViewModel = new TestListViewModel();

            listViewModel.AddTestData();
            BindingContext = listViewModel;


            _list.ItemTapped += (sender, e) =>
            {
                DisplayAlert("hello", "You tapped " + e.Item.ToString(), "OK", "Cancel");
            };

            var btnDisable = new Button()
            {
                Text = "Disable ListView",
            };

            btnDisable.Clicked += (object sender, EventArgs e) =>
            {
                if (_list.IsEnabled == true)
                {
                    _list.IsEnabled = false;
                    btnDisable.Text = "Enable ListView";
                }
                else
                {
                    _list.IsEnabled = true;
                    btnDisable.Text = "Disable ListView";
                }
            };

            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        = { btnDisable, _list }
            };
        }
Пример #10
0
        public IActionResult Index(int?page)
        {
            var pageNumber = page == null || page <= 0 ? 1 : page.Value;
            var pageSize   = 10;

            var viewModel = new TestListViewModel();

            viewModel.Tests = this.testService.GetTests(pageNumber, pageSize);

            return(View(viewModel));
        }
Пример #11
0
 public void Setup()
 {
     TestCase = new TestCase("Test", "test.pmlobj");
     TestCase.Tests.Add("one");
     TestCase.Tests.Add("two");
     TestCase.Tests.Add("three");
     RunnerControl = new TestRunnerControl(Mock.Of <TestCaseProvider>(), Mock.Of <AsyncTestRunner>(), Mock.Of <SettingsProvider>());
     TestSummary   = RunnerControl.FindControl <TestSummaryView>("TestSummary");
     TestDetails   = RunnerControl.FindControl <TestDetailsView>("TestDetails");
     TestList      = RunnerControl.FindControl <TestListView>("TestList");
     TestList.TestCases.Add(TestCase);
     Model = TestList.GetModel();
 }
Пример #12
0
        public void Setup()
        {
            var testCase = new TestCase("Test", "test.pmlobj");

            testCase.Tests.Add("first");
            testCase.Tests.Add("second");
            Model = new TestListViewModel();
            Model.TestCases.Add(testCase);

            TestCase = new TestCase("TestCase", "testcase.pmlobj");
            TestCase.Tests.Add("third");
            TestCase.Tests.Add("fourth");
        }
Пример #13
0
		protected override void Init ()
		{
			Title = "Test Command Binding";
			_list = new ListView () { 
				ClassId = "SampleList",
				// Note: Turning on and off row height does not effect the issue, 
				// but with row heights on there is a visual glitch with the recyclyed row spacing
				//RowHeight = SampleViewCell.RowHeight,
				HasUnevenRows = true,
				ItemTemplate = new DataTemplate (typeof(SampleViewCell)),
				BackgroundColor = Color.FromHex ("E0E0E0"),
				VerticalOptions = LayoutOptions.FillAndExpand,
				HorizontalOptions = LayoutOptions.FillAndExpand,
			};
			_list.SetBinding (ListView.ItemsSourceProperty, Binding.Create<TestListViewModel> (r => r.Items));
			_list.SetBinding (ListView.RefreshCommandProperty, Binding.Create<TestListViewModel> (r => r.RefreshCommand));
			_list.SetBinding (ListView.IsRefreshingProperty, Binding.Create<TestListViewModel> (r => r.IsRefreshing));

			var listViewModel = new TestListViewModel ();
			listViewModel.AddTestData ();
			BindingContext = listViewModel;


			_list.ItemTapped += (sender, e) =>
			{
				DisplayAlert("hello", "You tapped " + e.Item.ToString(), "OK", "Cancel");
			};

			var btnDisable = new Button () {
				Text = "Disable ListView",
			};

			btnDisable.Clicked += (object sender, EventArgs e) => {
				if (_list.IsEnabled == true){
					_list.IsEnabled = false;
					btnDisable.Text = "Enable ListView";
				}
				else {
					_list.IsEnabled = true;
					btnDisable.Text = "Disable ListView";
				}
			};

			Content = new StackLayout
			{
				VerticalOptions = LayoutOptions.FillAndExpand,
				Children = { btnDisable, _list }
			};
		}
Пример #14
0
        public void ListContainsCorrectNumberOfSpellTests()
        {
            //Mock<IConnectedRepository> repo = new Mock<IConnectedRepository>();
            IConnectedRepository repo = new MockConectedRepository();
            var sut = new TestListViewModel(repo);

            var testList = sut.Tests;

            Assert.Equal(2, testList.Count);

            var test = sut.Tests.SingleOrDefault(f => f.Id == 1);

            Assert.Equal("Test 1", test.Description);
            Assert.Equal(new DateTime(2017, 1, 1), test.DateCreated);
        }
Пример #15
0
        public void SpellingsContainsCorrectMembersForCurrentTest()
        {
            IConnectedRepository repo = new MockConectedRepository();
            var sut      = new TestListViewModel(repo);
            var testList = sut.Tests;
            var test     = sut.Tests.SingleOrDefault(f => f.Id == 2);

            // Act
            sut.CurrentTest = test;

            // Assert
            Assert.Equal(3, sut.Spellings.Count);

            Assert.Contains(sut.Spellings, s => s.Word == "Five");
        }
Пример #16
0
        public void Setup()
        {
            TestList        = new TestListView();
            Model           = TestList.GetModel();
            VisibleEntries  = Model.VisibleEntries;
            SelectedEntries = Model.SelectedEntries;
            Controller      = TestList.GetController();

            First = new TestCase("First", "first.pmlobj");
            First.Tests.Add("a1");
            First.Tests.Add("a2");
            First.Tests.Add("a3");
            TestList.TestCases.Add(First);
            Second = new TestCase("Second", "second.pmlobj");
            Second.Tests.Add("b1");
            Second.Tests.Add("b2");
            Second.Tests.Add("b3");
            TestList.TestCases.Add(Second);
        }
Пример #17
0
        public void Can_Send_Pagination_View_Model()
        {
            // Организация (arrange)
            Mock <ITestRepository> mock = new Mock <ITestRepository>();

            mock.Setup(m => m.Tests).Returns(new List <TestPreview>
            {
                new TestPreview {
                    Id = 1, Name = "Тест1"
                },
                new TestPreview {
                    Id = 2, Name = "Тест2"
                },
                new TestPreview {
                    Id = 3, Name = "Тест3"
                },
                new TestPreview {
                    Id = 4, Name = "Тест4"
                },
                new TestPreview {
                    Id = 5, Name = "Тест5"
                }
            });
            TestController controller = new TestController(mock.Object);

            controller.pageSize = 3;

            // Act
            TestListViewModel result
                = (TestListViewModel)controller.List(null, 2).Model;

            // Assert
            PagingInfo pageInfo = result.PagingInfo;

            Assert.AreEqual(pageInfo.CurrentPage, 2);
            Assert.AreEqual(pageInfo.ItemsPerPage, 3);
            Assert.AreEqual(pageInfo.TotalItems, 5);
            Assert.AreEqual(pageInfo.TotalPages, 2);
        }
Пример #18
0
        public ViewResult List(string category, int page = 1)
        {
            TestListViewModel model = new TestListViewModel
            {
                Tests = repository.TestPreview
                        .Where(p => category == null || p.Category == category)
                        .OrderBy(TestPreview => TestPreview.Id)
                        .Skip((page - 1) * pageSize)
                        .Take(pageSize),
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = pageSize,
                    TotalItems   = category == null?
                                   repository.TestPreview.Count() :
                                       repository.TestPreview.Where(TestPreview => TestPreview.Category == category).Count()
                },
                CurrentCategory = category
            };

            return(View(model));
        }
Пример #19
0
        public void Can_Paginate()
        {
            // Организация (arrange)
            Mock <ITestRepository> mock = new Mock <ITestRepository>();

            mock.Setup(m => m.Tests).Returns(new List <TestPreview>
            {
                new TestPreview {
                    Id = 1, Name = "Тест1"
                },
                new TestPreview {
                    Id = 2, Name = "Тест2"
                },
                new TestPreview {
                    Id = 3, Name = "Тест3"
                },
                new TestPreview {
                    Id = 4, Name = "Тест4"
                },
                new TestPreview {
                    Id = 5, Name = "Тест5"
                }
            });
            TestController controller = new TestController(mock.Object);

            controller.pageSize = 3;

            // Действие (act)
            TestListViewModel result = (TestListViewModel)controller.List(null, 2).Model;

            // Утверждение (assert)
            List <TestPreview> testPreviews = result.ToList();

            Assert.IsTrue(testPreviews.Count == 2);
            Assert.AreEqual(testPreviews[0].Name, "Тест4");
            Assert.AreEqual(testPreviews[1].Name, "Тест5");
        }
Пример #20
0
        public ViewResult List(string category, int page = 1)
        {
            Database.SetInitializer(new DropCreateDatabaseIfModelChanges <EFTestDbContext>());
            TestListViewModel model = new TestListViewModel
            {
                Tests = repository.Tests
                        .Where(p => category == null || p.Category == category)
                        .OrderBy(TestPreview => TestPreview.Id)
                        .Skip((page - 1) * pageSize)
                        .Take(pageSize),
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = pageSize,
                    TotalItems   = category == null?
                                   repository.Tests.Count() :
                                       repository.Tests.Where(TestPreview => TestPreview.Category == category).Count()
                },
                CurrentCategory = category,
                questions       = questionRepository.Question
            };

            return(View(model));
        }
Пример #21
0
 public TestListController() : base("TestListController", null)
 {
     ViewModel = new TestListViewModel();
     SetupNavigationBar();
 }
Пример #22
0
 public TestListDelegate(TestListController listController, TestListViewModel viewModel)
 {
     ListController = new WeakReference(listController);
     ViewModel      = viewModel;
 }