コード例 #1
0
        public void DeleteCountry_Action_Fails()
        {
            // Arrange
            var countryDto = TestHelper.CountryDto();

            GenericServiceResponse <bool> fakeResponse = null;

            mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable();
            mockClientServicesProvider.Setup(x => x.CountryService.DeleteCountry(countryDto)).Returns(fakeResponse).Verifiable();

            var viewModel = new GenericViewModel();

            var action = new DeleteCountry <GenericViewModel>(mockClientServicesProvider.Object)
            {
                OnComplete = model => viewModel = model
            };

            // Act
            var result = action.Invoke(countryDto);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(GenericViewModel));
            Assert.IsNotNull(result.Notifications);
            Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection));
            Assert.IsTrue(result.Notifications.Count() == 1);
            Assert.IsTrue(result.HasErrors);
            Assert.IsNotNull(result.Success);
            Assert.IsInstanceOfType(result.Success, typeof(bool));
            Assert.IsFalse(result.Success);
        }
コード例 #2
0
 public Task Handle(object command)
 {
     return(command switch
     {
         Create cmd => HandleCreate(cmd),
         SetCountryName cmd
         => HandleUpdate(cmd.Id, c => c.UpdateCountryName(cmd.Name)),
         DeleteCountry cmd => HandleUpdateAsync(cmd.Id, _ => this._repository.RemoveAsync(cmd.Id)),
         _ => Task.CompletedTask
     });
コード例 #3
0
        public int DeleteCountry(DeleteCountry deleteCountry)
        {
            int result = 0;

            using (TestingSample1Entities testingSample1Entities = new TestingSample1Entities())
            {
                ObjectParameter opResult = new ObjectParameter("Result", typeof(int));
                testingSample1Entities.CountryDelete(deleteCountry.CountryId, deleteCountry.ModifiedBy, opResult);
                result = Convert.ToInt32(opResult.Value);
            }
            return(result);
        }
コード例 #4
0
 public ActionResult DeleteCountry(int id)
 {
     try
     {
         DeleteCountry deleteCountry = new DeleteCountry();
         deleteCountry.CountryId = id;
         int result = iCountry.DeleteCountry(deleteCountry);
         return(Json(result));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #5
0
        public IApiResult Delete(DeleteCountry operation)
        {
            var result = operation.ExecuteAsync().Result;

            if (result is ValidationsOutput)
            {
                return(new ApiResult <List <ValidationItem> >()
                {
                    Data = ((ValidationsOutput)result).Errors
                });
            }
            else
            {
                return(new ApiResult <object>()
                {
                    Status = ApiResult <object> .ApiStatus.Success
                });
            }
        }