public void LinesViewModel_ThrowsException2()
        {
            var lineVM = new LinesViewModel();

            lineVM.LineFromType = LineFromTypes.BearingAndDistance;

            lineVM.AzimuthString = "esri";
        }
        public void LineViewModel()
        {
            var lineVM = new LinesViewModel();

            // can we create an element
            Assert.IsFalse(lineVM.CanCreateElement);
            lineVM.LineAzimuthType = DistanceAndDirectionLibrary.AzimuthTypes.Degrees;
            lineVM.Azimuth         = 90.1;
            Assert.AreEqual("90.1", lineVM.AzimuthString);
            lineVM.Azimuth = 90.0;
            Assert.AreEqual("90", lineVM.AzimuthString);
            lineVM.LineAzimuthType = DistanceAndDirectionLibrary.AzimuthTypes.Mils;
            Assert.AreEqual(1600.00000002, lineVM.Azimuth);

            // test points
            lineVM.Point1 = new Point()
            {
                X = -119.8, Y = 34.4
            };
            lineVM.Point2 = new Point()
            {
                X = -74.1, Y = 41.8
            };
            // can we create an element
            Assert.IsTrue(lineVM.CanCreateElement);

            // can't test manual input of of starting and ending points
            // they call methods that reference the ArcMap Application/Document objects
            // which is not available in unit testing

            // test Distance and Bearing mode

            // manual input of azimuth
            lineVM.LineAzimuthType = DistanceAndDirectionLibrary.AzimuthTypes.Degrees;
            lineVM.LineFromType    = DistanceAndDirectionLibrary.LineFromTypes.BearingAndDistance;
            lineVM.AzimuthString   = "90.1";
            Assert.AreEqual(90.1, lineVM.Azimuth);
            // manual input of distance
            lineVM.LineDistanceType = DistanceAndDirectionLibrary.DistanceTypes.Meters;
            lineVM.DistanceString   = "50.5";
            Assert.AreEqual(50.5, lineVM.Distance);
            lineVM.LineDistanceType = DistanceAndDirectionLibrary.DistanceTypes.Miles;
            Assert.AreEqual(50.5, lineVM.Distance);

            // Check TrimPrecision is trimming correctly according to LineDistanceType
            lineVM.LineDistanceType = DistanceTypes.Kilometers;
            lineVM.Distance         = 1.012345;
            Assert.AreEqual(1.0123, lineVM.Distance);

            lineVM.LineDistanceType = DistanceTypes.Meters;
            lineVM.Distance         = 1.12;
            Assert.AreEqual(1.1, lineVM.Distance);
        }
コード例 #3
0
 public LinesView(LinesViewModel viewModel)
     : base(viewModel)
 {
     InitializeComponent();
 }
コード例 #4
0
ファイル: MainViewModel.cs プロジェクト: holydk/Farming
        public MainViewModel(User user, INavigation navigation, string title, ISnackbarMessageQueue snackbarMessageQueue)
            : base(navigation, title, snackbarMessageQueue)
        {
            _user = user ?? throw new ArgumentNullException(nameof(user));

            var homeVm = new HomeViewModel(snackbarMessageQueue);

            Navigation.Add(() => new Home(homeVm));

            var bloodyVm = new BloodTypesViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new BloodTypesView(bloodyVm));

            var breedsVm = new BreedsViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new BreedsView(breedsVm));

            var categoriesVm = new CategoriesViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new CategoriesView(categoriesVm));

            var linesVm = new LinesViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new LinesView(linesVm));

            var familiesVm = new FamiliesViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new FamiliesView(familiesVm));

            var gendersVm = new GendersViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new GendersView(gendersVm));

            var msVm = new MethodsSluchkiViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new MethodsSluchkiView(msVm));

            var bullsVm = new BullsViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new BullsView(bullsVm));

            var cowsVm = new CowsViewModel(snackbarMessageQueue, _user, bullsVm, bloodyVm, categoriesVm, linesVm, breedsVm, familiesVm);

            Navigation.Add(() => new CowsView(cowsVm));

            var repsVm = new ReproductionsViewModel(snackbarMessageQueue, _user, cowsVm, msVm);

            Navigation.Add(() => new ReproductionsView(repsVm));

            var usersTypesVm = new UsersTypesViewModel(snackbarMessageQueue, _user);

            var usersVm = new UsersViewModel(snackbarMessageQueue, _user, usersTypesVm);

            Navigation.Add(() => new UsersView(usersVm));

            var prodVm = new ProductivitiesViewModel(snackbarMessageQueue, _user, cowsVm);

            Navigation.Add(() => new ProductivitiesView(prodVm));

            var retVm = new RetirementsViewModel(snackbarMessageQueue, _user, cowsVm);

            Navigation.Add(() => new RetirementsView(retVm));

            var priplodsVm = new PriplodsViewModel(snackbarMessageQueue, _user, cowsVm, gendersVm);

            Navigation.Add(() => new PriplodsView(priplodsVm));

            _pagesViewModels = new IPageViewModel[]
            {
                homeVm, bloodyVm, breedsVm, categoriesVm, linesVm, familiesVm, gendersVm, msVm, bullsVm, prodVm, cowsVm, usersTypesVm, usersVm, retVm, priplodsVm
            };

            Navigation.Navigating += (obj, e) =>
            {
                if (e.Content != null && e.Content.DataContext is IDatabaseTableViewModel dbVm)
                {
                    dbVm.ClearData();
                }
            };

            _navigationItems = new INavigationItem[]
            {
                new NavigationItem(bloodyVm.Title, typeof(BloodTypesView), PackIconKind.Fire),
                new NavigationItem(breedsVm.Title, typeof(BreedsView), PackIconKind.Eraser),
                new NavigationItem(categoriesVm.Title, typeof(CategoriesView), PackIconKind.CardsOutline),
                new NavigationItem(linesVm.Title, typeof(LinesView), PackIconKind.SourceBranch),
                new NavigationItem(familiesVm.Title, typeof(FamiliesView), PackIconKind.CardsVariant),
                new NavigationItem(gendersVm.Title, typeof(GendersView), PackIconKind.GenderMaleFemale),
                new NavigationItem(msVm.Title, typeof(MethodsSluchkiView), PackIconKind.SourceFork),
                new NavigationItem(bullsVm.Title, typeof(BullsView), PackIconKind.Cow),
                new NavigationItem(prodVm.Title, typeof(ProductivitiesView), PackIconKind.ChartBar),
                new NavigationItem(usersVm.Title, typeof(UsersView), PackIconKind.AccountMultiple),
                new NavigationItem(cowsVm.Title, typeof(CowsView), PackIconKind.Cow),
                new NavigationItem(repsVm.Title, typeof(ReproductionsView), PackIconKind.HeartHalfFull),
                new NavigationItem(retVm.Title, typeof(RetirementsView), PackIconKind.Logout),
                new NavigationItem(priplodsVm.Title, typeof(PriplodsView), PackIconKind.Cow)
            }.OrderBy(i => i.Title).Prepend(new NavigationItem(homeVm.Title, typeof(Home), PackIconKind.Home));

            Links = new ILink[]
            {
                new Link("GitHub", "https://github.com/holydk/Farming", PackIconKind.GithubCircle, "Исходный код")
            };
        }
        public void LinesViewModel_ThrowsException5()
        {
            var lineVM = new LinesViewModel();

            lineVM.Distance = -1;
        }
        public void LinesViewModel_ThrowsException4()
        {
            var lineVM = new LinesViewModel();

            lineVM.Point2Formatted = "esri";
        }
        public void LinesViewModel_ThrowsException()
        {
            var lineVM = new LinesViewModel();

            lineVM.DistanceString = "esri";
        }
        public void LinesViewModel_ThrowsException7()
        {
            var lineVM = new LinesViewModel();

            lineVM.Azimuth = 361;
        }