Exemple #1
0
        public void ReturnJsonResultWithCorrectModelInstance_WhenGetToBrands_Destroy()
        {
            //Arrange
            var brandsService    = new Mock <IBrandsService>();
            var brandViewModel   = DataHelper.GetAdminBrandViewModel();
            var kendoDataRequest = new DataSourceRequest();

            brandsService.Setup(x => x.Delete(It.IsAny <Brand>())).Verifiable();

            var controller = new BrandsController(brandsService.Object);

            //Act
            var     controllerResult = controller.Brands_Destroy(kendoDataRequest, brandViewModel);
            var     jsonResult       = controllerResult as JsonResult;
            dynamic kendoResultData  = jsonResult.Data;
            var     results          = kendoResultData.Data as IEnumerable <BrandViewModel>;

            //Assert
            Assert.IsInstanceOf <IEnumerable <BrandViewModel> >(results);
        }
Exemple #2
0
        public void ReturnJsonResultWithCorrectModel_WhenGetToBrands_Destroy()
        {
            //Arrange
            var brandsService    = new Mock <IBrandsService>();
            var brandViewModel   = DataHelper.GetAdminBrandViewModel();
            var kendoDataRequest = new DataSourceRequest();

            brandsService.Setup(x => x.Delete(It.IsAny <Brand>())).Verifiable();

            var controller = new BrandsController(brandsService.Object);

            //Act
            var     controllerResult = controller.Brands_Destroy(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);
        }