public async void Get_null_record() { var mock = new ServiceMockFacade <IStateProvinceRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <StateProvince>(null)); var service = new StateProvinceService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.StateProvinceModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLStateProvinceMapperMock, mock.DALMapperMockFactory.DALStateProvinceMapperMock, mock.BOLMapperMockFactory.BOLAddressMapperMock, mock.DALMapperMockFactory.DALAddressMapperMock); ApiStateProvinceResponseModel response = await service.Get(default(int)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public async void Addresses_Not_Exists() { var mock = new ServiceMockFacade <IStateProvinceRepository>(); mock.RepositoryMock.Setup(x => x.Addresses(default(int), It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult <List <Address> >(new List <Address>())); var service = new StateProvinceService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.StateProvinceModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLStateProvinceMapperMock, mock.DALMapperMockFactory.DALStateProvinceMapperMock, mock.BOLMapperMockFactory.BOLAddressMapperMock, mock.DALMapperMockFactory.DALAddressMapperMock); List <ApiAddressResponseModel> response = await service.Addresses(default(int)); response.Should().BeEmpty(); mock.RepositoryMock.Verify(x => x.Addresses(default(int), It.IsAny <int>(), It.IsAny <int>())); }
public async void ByStateProvinceCodeCountryRegionCode_Not_Exists() { var mock = new ServiceMockFacade <IStateProvinceRepository>(); mock.RepositoryMock.Setup(x => x.ByStateProvinceCodeCountryRegionCode(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult <StateProvince>(null)); var service = new StateProvinceService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.StateProvinceModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLStateProvinceMapperMock, mock.DALMapperMockFactory.DALStateProvinceMapperMock, mock.BOLMapperMockFactory.BOLAddressMapperMock, mock.DALMapperMockFactory.DALAddressMapperMock); ApiStateProvinceResponseModel response = await service.ByStateProvinceCodeCountryRegionCode(default(string), default(string)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.ByStateProvinceCodeCountryRegionCode(It.IsAny <string>(), It.IsAny <string>())); }
public async void Create() { var mock = new ServiceMockFacade <IStateProvinceRepository>(); var model = new ApiStateProvinceRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <StateProvince>())).Returns(Task.FromResult(new StateProvince())); var service = new StateProvinceService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.StateProvinceModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLStateProvinceMapperMock, mock.DALMapperMockFactory.DALStateProvinceMapperMock, mock.BOLMapperMockFactory.BOLAddressMapperMock, mock.DALMapperMockFactory.DALAddressMapperMock); CreateResponse <ApiStateProvinceResponseModel> response = await service.Create(model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.StateProvinceModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiStateProvinceRequestModel>())); mock.RepositoryMock.Verify(x => x.Create(It.IsAny <StateProvince>())); }
public async void All() { var mock = new ServiceMockFacade <IStateProvinceRepository>(); var records = new List <StateProvince>(); records.Add(new StateProvince()); mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records)); var service = new StateProvinceService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.StateProvinceModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLStateProvinceMapperMock, mock.DALMapperMockFactory.DALStateProvinceMapperMock, mock.BOLMapperMockFactory.BOLAddressMapperMock, mock.DALMapperMockFactory.DALAddressMapperMock); List <ApiStateProvinceResponseModel> response = await service.All(); response.Should().HaveCount(1); mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>())); }
public async void Delete() { var mock = new ServiceMockFacade <IStateProvinceRepository>(); var model = new ApiStateProvinceRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new StateProvinceService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.StateProvinceModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLStateProvinceMapperMock, mock.DALMapperMockFactory.DALStateProvinceMapperMock, mock.BOLMapperMockFactory.BOLAddressMapperMock, mock.DALMapperMockFactory.DALAddressMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.StateProvinceModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); }