public void ReturnJsonResultWithCorrectModelInstance_WhenGetToBrands_Update() { //Arrange var brandsService = new Mock <IBrandsService>(); var brandViewModel = DataHelper.GetAdminBrandViewModel(); var kendoDataRequest = new DataSourceRequest(); brandsService.Setup(x => x.Update(It.IsAny <Brand>())).Verifiable(); var controller = new BrandsController(brandsService.Object); //Act var controllerResult = controller.Brands_Update(kendoDataRequest, brandViewModel); var jsonResult = controllerResult as JsonResult; dynamic kendoResultData = jsonResult.Data; var results = kendoResultData.Data as IEnumerable <BrandViewModel>; //Assert Assert.IsInstanceOf <IEnumerable <BrandViewModel> >(results); }
public void ReturnJsonResultWithCorrectModel_WhenGetToBrands_Update() { //Arrange var brandsService = new Mock <IBrandsService>(); var brandViewModel = DataHelper.GetAdminBrandViewModel(); var kendoDataRequest = new DataSourceRequest(); brandsService.Setup(x => x.Update(It.IsAny <Brand>())).Verifiable(); var controller = new BrandsController(brandsService.Object); //Act var controllerResult = controller.Brands_Update(kendoDataRequest, brandViewModel); var jsonResult = controllerResult as JsonResult; dynamic kendoResultData = jsonResult.Data; var results = kendoResultData.Data as IEnumerable <BrandViewModel>; //Assert Assert.AreEqual(brandViewModel, results.FirstOrDefault()); Assert.AreEqual(brandViewModel.Id, results.FirstOrDefault().Id); Assert.AreEqual(brandViewModel.Name, results.FirstOrDefault().Name); Assert.AreEqual(brandViewModel.WebSite, results.FirstOrDefault().WebSite); }