Example #1
0
        public void ReturnJsonArrayWithTheEditedCountry_WhenPassedModelParamIsNotNull()
        {
            // arrange
            var countryService   = new Mock <ICountryService>();
            var countryViewModel = new GridCountryViewModel()
            {
                Name = "someName"
            };

            var mapService = new Mock <IMappingService>();

            var countryDataModel = new Country()
            {
                Name = "someName"
            };

            mapService.Setup(c => c.Map <Country>(It.IsAny <Object>()))
            .Returns(countryDataModel);

            MappingService.MappingProvider = mapService.Object;
            var controller = new CountriesGridController(countryService.Object);

            // act
            controller.EditCountry(countryViewModel);

            // assert
            controller.WithCallTo(c => c.EditCountry(countryViewModel))
            .ShouldReturnJson((data) => Assert.AreSame(data[0], countryViewModel));
        }
Example #2
0
        public void RenderDefaultView_WhenInvoked()
        {
            // arrange
            var countryService = new Mock <ICountryService>();
            var controller     = new CountriesGridController(countryService.Object);

            // act & assert
            controller.WithCallTo(c => c.Index())
            .ShouldRenderDefaultView();
        }
        public void ReturnJsonAsResult_WhenInvoked()
        {
            // arrange
            var countryService = new Mock <ICountryService>();
            var controller     = new CountriesGridController(countryService.Object);

            var countryViewModel = new GridCountryViewModel()
            {
                Name = "someName"
            };

            // act
            controller.DeleteCountry(countryViewModel);

            // assert
            controller.WithCallTo(c => c.DeleteCountry(countryViewModel))
            .ShouldReturnJson(data =>
            {
                Assert.That(data[0].Name, Is.EqualTo("someName"));
            });
        }