コード例 #1
0
        public void CanAddRecipeWithLongRecipeName()
        {
            var navaMock = new Mock <INavigationService>();

            var recipeServiceMock = new Mock <IRecipeService>();
            var dbMock            = new Mock <ILocalDataService>();
            var pageMock          = new Mock <IPageDialogService>();



            var editViewModel = new Diabetes.ViewModels.EditRecipePageViewModel(navaMock.Object, recipeServiceMock.Object, pageMock.Object, dbMock.Object);

            editViewModel.RecipeName     = "something long";
            editViewModel.IngredientName = "sugar";



            var addViewModel = new Diabetes.ViewModels.AddRecipePageViewModel(navaMock.Object, recipeServiceMock.Object, pageMock.Object, dbMock.Object);

            addViewModel.RecipeName         = "something long";
            addViewModel.IngredientName     = "sugar";
            addViewModel.IngredientQuantity = 4;



            Assert.IsTrue(editViewModel.SaveRecipe.CanExecute(this), "Edit Failed");
            Assert.IsTrue(addViewModel.SubmitRecipe.CanExecute(this), "Add Failed");
        }
コード例 #2
0
        public void CanNotAddRecipeWithOutIngredient()
        {
            var navaMock = new Mock <INavigationService>();



            var recipServiceMock = new Mock <IRecipeService>();
            var dbMock           = new Mock <ILocalDataService>();
            var pageMock         = new Mock <IPageDialogService>();



            var editViewModel = new Diabetes.ViewModels.EditRecipePageViewModel(navaMock.Object, recipServiceMock.Object, pageMock.Object, dbMock.Object);

            editViewModel.IngredientName = "";



            var addViewModel = new Diabetes.ViewModels.AddRecipePageViewModel(navaMock.Object, recipServiceMock.Object, pageMock.Object, dbMock.Object);

            addViewModel.IngredientName     = "";
            addViewModel.IngredientQuantity = 0;



            Assert.IsFalse(editViewModel.SaveRecipe.CanExecute(this), "Edit Failed");
            Assert.IsFalse(addViewModel.SubmitRecipe.CanExecute(this), "Add Failed");
        }
コード例 #3
0
        public void CanNotAddRecipeWithShortRecipeName()
        {
            // A mock test behavior in a view model and it requires an interface like inavigation and since we dont want to give it the real one mock makes it think that it does have an implementation of that interface.
            var navaMock = new Mock <INavigationService>();



            var recipeServiceMock = new Mock <IRecipeService>();
            var dbMock            = new Mock <ILocalDataService>();
            var pageMock          = new Mock <IPageDialogService>();



            var editViewModel = new Diabetes.ViewModels.EditRecipePageViewModel(navaMock.Object, recipeServiceMock.Object, pageMock.Object, dbMock.Object);

            editViewModel.RecipeName = "short";



            var addViewModel = new Diabetes.ViewModels.AddRecipePageViewModel(navaMock.Object, recipeServiceMock.Object, pageMock.Object, dbMock.Object);

            addViewModel.RecipeName = "short";



            //Assert.IsFalse(editViewModel.SubmitRecipe.CanExecute(this));
            Assert.IsFalse(addViewModel.SubmitRecipe.CanExecute(this));
        }