Exemple #1
0
        public void ReturnJsonResultWithCorrectModel_WhenGetToSupplementViewModels_Update()
        {
            //Arrange
            var supplementsService    = new Mock <ISupplementsService>();
            var dropDownListPopulator = new Mock <IDropDownListPopulator>();
            var repoUser            = new Mock <IEfGenericRepository <ApplicationUser> >();
            var supplementViewModel = DataHelper.GetAdminSupplementViewModel();
            var kendoDataRequest    = new DataSourceRequest();

            supplementsService.Setup(x => x.Update(It.IsAny <Supplement>())).Verifiable();

            var controller = new SupplementsController(supplementsService.Object, dropDownListPopulator.Object, repoUser.Object);

            //Act
            var     controllerResult = controller.SupplementViewModels_Update(kendoDataRequest, supplementViewModel);
            var     jsonResult       = controllerResult as JsonResult;
            dynamic kendoResultData  = jsonResult.Data;
            var     results          = kendoResultData.Data as IEnumerable <SupplementViewModel>;

            //Assert
            Assert.AreEqual(supplementViewModel, results.FirstOrDefault());
            Assert.AreEqual(supplementViewModel.Id, results.FirstOrDefault().Id);
            Assert.AreEqual(supplementViewModel.Name, results.FirstOrDefault().Name);
            Assert.AreEqual(supplementViewModel.ImageUrl, results.FirstOrDefault().ImageUrl);
            Assert.AreEqual(supplementViewModel.Ingredients, results.FirstOrDefault().Ingredients);
            Assert.AreEqual(supplementViewModel.Use, results.FirstOrDefault().Use);
            Assert.AreEqual(supplementViewModel.Description, results.FirstOrDefault().Description);
        }
Exemple #2
0
        public void ReturnJsonResultWithCorrectModelInstance_WhenGetToSupplementViewModels_Update()
        {
            //Arrange
            var supplementsService    = new Mock <ISupplementsService>();
            var dropDownListPopulator = new Mock <IDropDownListPopulator>();
            var repoUser            = new Mock <IEfGenericRepository <ApplicationUser> >();
            var supplementViewModel = DataHelper.GetAdminSupplementViewModel();
            var kendoDataRequest    = new DataSourceRequest();

            supplementsService.Setup(x => x.Update(It.IsAny <Supplement>())).Verifiable();

            var controller = new SupplementsController(supplementsService.Object, dropDownListPopulator.Object, repoUser.Object);

            //Act
            var     controllerResult = controller.SupplementViewModels_Update(kendoDataRequest, supplementViewModel);
            var     jsonResult       = controllerResult as JsonResult;
            dynamic kendoResultData  = jsonResult.Data;
            var     results          = kendoResultData.Data as IEnumerable <SupplementViewModel>;

            //Assert
            Assert.IsInstanceOf <IEnumerable <SupplementViewModel> >(results);
        }