Esempio n. 1
0
        public async void HRCountriesController_On_GetByID_With_Null_Service_Expect_Status500_InternalServerError()
        {
            IHRCommonForkerUtils util = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = true
            };
            HRCountriesControllersForker forker = new HRCountriesControllersForker(util);

            using (Task <(int, HRCountry)> resultService = forker.GetFromIDAsync("xx", null))
            {
                await resultService;
                Assert.True(resultService.Result.Item1 == StatusCodes.Status500InternalServerError);
                Assert.True(resultService.Result.Item2 == null);
            }
        }
Esempio n. 2
0
        public async void HRCountriesController_On_GetByID_With_Existing_Item_Expect_Item_And_CodeStatus_200()
        {
            List <String> list = new List <String>()
            {
                "FR", "US"
            };
            IHRCommonForkerUtils util = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = true
            };
            HRCountriesControllersForker forker = new HRCountriesControllersForker(util);

            using (Task <(int, HRCountry)> resultService = forker.GetFromIDAsync("FR", new CoreCountriesServiceStub(list)))
            {
                await resultService;
                Assert.True(resultService.Result.Item1 == StatusCodes.Status200OK);
                Assert.True(resultService.Result.Item2 != null && resultService.Result.Item2.Alpha2Code.Equals("FR"));
            }
        }
Esempio n. 3
0
        public async void HRCountriesController_On_GetByID_Unknown_Expect_StatusCode_404()
        {
            List <String> list = new List <String>()
            {
                "FR",
                "US"
            };
            IHRCommonForkerUtils util = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = true
            };
            HRCountriesControllersForker forker = new HRCountriesControllersForker(util);

            using (Task <(int, HRCountry)> resultService = forker.GetFromIDAsync("AA", new CoreCountriesServiceStub(list)))
            {
                await resultService;
                Assert.True(resultService.Result.Item1 == StatusCodes.Status404NotFound);
                Assert.True(resultService.Result.Item2 == null);
            }
        }
Esempio n. 4
0
        public async void HRCountriesController_On_GetByID_Null_Expect_Status400_BadRequest()
        {
            List <String> list = new List <String>()
            {
                "FR",
                "US"
            };
            CoreCountriesServiceStub service = new CoreCountriesServiceStub(list);
            IHRCommonForkerUtils     util    = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = true
            };
            HRCountriesControllersForker forker = new HRCountriesControllersForker(util);

            using (Task <(int, HRCountry)> resultService = forker.GetFromIDAsync(null, service))
            {
                await resultService;
                Assert.True(resultService.Result.Item1 == StatusCodes.Status400BadRequest);
                Assert.True(resultService.Result.Item2 == null);
            }
        }
Esempio n. 5
0
        public async void HRCountriesController_On_GetByID_With_Exception_Thrown_By_Service_Expect_Status500_InternalServerError()
        {
            List <String> list = new List <String>()
            {
                "FR",
                "US"
            };
            IHRCommonForkerUtils util = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = true
            };
            HRCountriesControllersForker forker = new HRCountriesControllersForker(util);

            using (Task <(int, HRCountry)> resultService = forker.GetFromIDAsync("xx", new CoreCountriesServiceStub(list)
            {
                ThrowException = true
            }))
            {
                await resultService;
                Assert.True(resultService.Result.Item1 == StatusCodes.Status500InternalServerError);
                Assert.True(resultService.Result.Item2 == null);
            }
        }