public void MostPopularPhotoShown()
        {
            var cafe = new Cafe
                {
                    Photos = new[]
                        {
                            new Photo
                            {
                                SubmittedBy = "Tom",
                                NumberOfVotes = 2
                            },
                            new Photo
                            {
                                SubmittedBy = "Dick",
                                NumberOfVotes = 5
                            },
                            new Photo
                            {
                                SubmittedBy = "Harry",
                                NumberOfVotes = 3
                            }
                        }
                };

            var result = new CafeSummaryViewModel(cafe, new MockNavigationService());

            Assert.IsNotNull(result.Photo);
            Assert.AreEqual("Dick", result.Photo.SubmittedBy);
        }
        public void NavigateToCafeDetails()
        {
            var navigationService = new MockNavigationService();
            var cafe = new Cafe { Id = "1" };
            var item = new CafeSummaryViewModel(cafe, navigationService);

            item.Navigate.Execute(null);

            Assert.AreEqual("CafeDetails", navigationService.Current.Location);
            Assert.AreEqual("1", navigationService.Current.Parameters["Id"]);
        }
Ejemplo n.º 3
0
        private async Task PopulateCafes(string selectCafeId)
        {
            this.Cafes.Clear();
            foreach (var cafe in await this.dataService.GetAllCafes())
            {
                var cafeViewModel = new CafeSummaryViewModel(cafe, this.navigationService);
                this.Cafes.Add(cafeViewModel);

                if (selectCafeId != null && cafe.Id == selectCafeId)
                {
                    this.SelectedCafe = cafeViewModel;
                }
            }
        }
        public void PropertiesPopulatedFromModel()
        {
            var cafe = new Cafe
                {
                    Name = "Coffee Shop",
                    Address = "1 Main Street",
                    PostCode = "A1",
                    Longitude = 45,
                    Latitude = -12,
                    CoffeeRating = 3.5,
                    AtmosphereRating = 4.5,
                    NumberOfVotes = 12
                };

            var result = new CafeSummaryViewModel(cafe, new MockNavigationService());

            Assert.AreEqual("Coffee Shop", result.Name, "Name");
            Assert.AreEqual("1 Main Street", result.Address, "Address");
            Assert.AreEqual(45, result.Longitude, "Longitude");
            Assert.AreEqual(-12, result.Latitude, "Latitude");
            Assert.AreEqual(4, result.Rating, "Rating");
            Assert.AreEqual(12, result.NumberOfVotes, "NumberOfVotes");
        }
Ejemplo n.º 5
0
        private async Task PopulateCafes(string selectCafeId)
        {
            this.Cafes.Clear();
            foreach (var cafe in await this.dataService.GetAllCafes())
            {
                var cafeViewModel = new CafeSummaryViewModel(cafe, this.navigationService);
                this.Cafes.Add(cafeViewModel);

                if (selectCafeId != null && cafe.Id == selectCafeId)
                {
                    this.SelectedCafe = cafeViewModel;
                }
            }
        }
Ejemplo n.º 6
0
        private void AddCafeToMap(CafeSummaryViewModel cafe)
        {
            var position = new BasicGeoposition
                {
                    Latitude = cafe.Latitude,
                    Longitude = cafe.Longitude
                };
            var icon = new MapIcon
                {
                    Location = new Geopoint(position),
                    NormalizedAnchorPoint = new Point(1.0, 0.5),
                    Title = cafe.Name
                };

            this.Map.MapElements.Add(icon);

            this.cafeMapIcons.Add(icon, cafe);
        }