Example #1
0
 public Window1VM(int width, int height)
 {
     TitleName    = "В изображении " + Convert.ToString(width * height) + " пикселей. (" + Convert.ToString(width) + "x" + Convert.ToString(height) + ")";
     ArealPage    = new ArealPage();
     RandomPage   = new RandomPage();
     CurrentPage  = ArealPage;
     FrameOpacity = 1;
 }
Example #2
0
        public void should_redirect_to_home_when_no_pages_exist()
        {
            // Arrange
            RandomPage randomPage = new RandomPage(new RandomMock());

            randomPage.PageService = _container.PageService;

            // Act
            RedirectToRouteResult redirectResult = randomPage.GetResult(_controller) as RedirectToRouteResult;

            // Assert
            Assert.That(redirectResult, Is.Not.Null);
            Assert.That(redirectResult.RouteValues["controller"], Is.EqualTo("Home"));
            Assert.That(redirectResult.RouteValues["action"], Is.EqualTo("Index"));
        }
Example #3
0
        async void RandomBtnClicked(object sender, System.EventArgs e)
        {
            await _connection.CreateTableAsync <Doggo>();                  // create a table in the databasefile. (if it already exist it won't create it)

            var doggoss = await _connection.Table <Doggo>().ToListAsync(); //put everything of the database in a list

            _doggos = new List <Doggo>(doggoss);                           // make a new list of "Doggo" and put the "doggoss" as the values for the new list
            var random      = new Random();
            var randomdoggo = random.Next(_doggos.Count);                  // get a random dog breed

            if (_doggos[randomdoggo] != null)                              // check if the random number is not null
            {
                string targetPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
                var    dbPath     = Path.Combine(targetPath, "DogDBFive.db");
                var    page       = new RandomPage(dbPath, _doggos[randomdoggo]); // navigate to the "DoggoDetailpage" and give the dbPath and the data of the random dog with it
                page.BindingContext = _doggos[randomdoggo];                       // set the bindingcontext to the data of the random dog
                await Navigation.PushAsync(page);
            }
        }
Example #4
0
        public void should_redirect_to_correct_controller_using_random()
        {
            // Arrange
            _container.PageRepository.AddNewPage(new Page()
            {
                Id = 1, Title = "1"
            }, "text", "", DateTime.Now);
            _container.PageRepository.AddNewPage(new Page()
            {
                Id = 2, Title = "2"
            }, "text", "", DateTime.Now);
            _container.PageRepository.AddNewPage(new Page()
            {
                Id = 3, Title = "3"
            }, "text", "", DateTime.Now);
            _container.PageRepository.AddNewPage(new Page()
            {
                Id = 4, Title = "4"
            }, "text", "", DateTime.Now);
            _container.PageRepository.AddNewPage(new Page()
            {
                Id = 5, Title = "5"
            }, "text", "", DateTime.Now);


            RandomPage randomPage = new RandomPage(new RandomMock());

            randomPage.PageService = _container.PageService;

            // Act
            RedirectToRouteResult redirectResult = randomPage.GetResult(_controller) as RedirectToRouteResult;

            // Assert
            Assert.That(redirectResult, Is.Not.Null);
            Assert.That(redirectResult.RouteValues["controller"], Is.EqualTo("Wiki"));
            Assert.That(redirectResult.RouteValues["action"], Is.EqualTo("Index"));
            Assert.That(redirectResult.RouteValues["id"], Is.EqualTo(4));             // 4 as it's zero based
        }