public void MapEntityToModelList() { var mapper = new DALTestAllFieldTypesNullableMapper(); TestAllFieldTypesNullable item = new TestAllFieldTypesNullable(); item.SetProperties(1, 1, BitConverter.GetBytes(1), true, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), 1m, 1, BitConverter.GetBytes(1), 1m, "A", "A", 1m, "A", 1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, "A", TimeSpan.Parse("01:00:00"), BitConverter.GetBytes(1), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), BitConverter.GetBytes(1), "A", "A"); List <ApiTestAllFieldTypesNullableServerResponseModel> response = mapper.MapEntityToModel(new List <TestAllFieldTypesNullable>() { { item } }); response.Count.Should().Be(1); }
public virtual async Task <ApiTestAllFieldTypesNullableServerResponseModel> Get(int id) { TestAllFieldTypesNullable record = await this.TestAllFieldTypesNullableRepository.Get(id); if (record == null) { return(null); } else { return(this.DalTestAllFieldTypesNullableMapper.MapEntityToModel(record)); } }
public void MapEFToBOList() { var mapper = new DALTestAllFieldTypesNullableMapper(); TestAllFieldTypesNullable entity = new TestAllFieldTypesNullable(); entity.SetProperties(1, BitConverter.GetBytes(1), true, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), 1m, 1m, BitConverter.GetBytes(1), 1m, "A", "A", 1m, "A", 1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, "A", TimeSpan.Parse("0"), BitConverter.GetBytes(1), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), BitConverter.GetBytes(1), "A", "A", 1); List <BOTestAllFieldTypesNullable> response = mapper.MapEFToBO(new List <TestAllFieldTypesNullable>() { entity }); response.Count.Should().Be(1); }
public virtual async Task <CreateResponse <ApiTestAllFieldTypesNullableServerResponseModel> > Create( ApiTestAllFieldTypesNullableServerRequestModel model) { CreateResponse <ApiTestAllFieldTypesNullableServerResponseModel> response = ValidationResponseFactory <ApiTestAllFieldTypesNullableServerResponseModel> .CreateResponse(await this.TestAllFieldTypesNullableModelValidator.ValidateCreateAsync(model)); if (response.Success) { TestAllFieldTypesNullable record = this.DalTestAllFieldTypesNullableMapper.MapModelToEntity(default(int), model); record = await this.TestAllFieldTypesNullableRepository.Create(record); response.SetRecord(this.DalTestAllFieldTypesNullableMapper.MapEntityToModel(record)); await this.mediator.Publish(new TestAllFieldTypesNullableCreatedNotification(response.Record)); } return(response); }
public async void Get() { var mock = new ServiceMockFacade <ITestAllFieldTypesNullableRepository>(); var record = new TestAllFieldTypesNullable(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record)); var service = new TestAllFieldTypesNullableService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.TestAllFieldTypesNullableModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLTestAllFieldTypesNullableMapperMock, mock.DALMapperMockFactory.DALTestAllFieldTypesNullableMapperMock); ApiTestAllFieldTypesNullableResponseModel response = await service.Get(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public void MapEFToBO() { var mapper = new DALTestAllFieldTypesNullableMapper(); TestAllFieldTypesNullable entity = new TestAllFieldTypesNullable(); entity.SetProperties(1, BitConverter.GetBytes(1), true, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), 1m, 1m, BitConverter.GetBytes(1), 1m, "A", "A", 1m, "A", 1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, "A", TimeSpan.Parse("0"), BitConverter.GetBytes(1), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), BitConverter.GetBytes(1), "A", "A", 1); BOTestAllFieldTypesNullable response = mapper.MapEFToBO(entity); response.FieldBigInt.Should().Be(1); response.FieldBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1)); response.FieldBit.Should().Be(true); response.FieldChar.Should().Be("A"); response.FieldDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.FieldDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.FieldDateTime2.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.FieldDateTimeOffset.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM")); response.FieldDecimal.Should().Be(1m); response.FieldFloat.Should().Be(1m); response.FieldImage.Should().BeEquivalentTo(BitConverter.GetBytes(1)); response.FieldMoney.Should().Be(1m); response.FieldNChar.Should().Be("A"); response.FieldNText.Should().Be("A"); response.FieldNumeric.Should().Be(1m); response.FieldNVarchar.Should().Be("A"); response.FieldReal.Should().Be(1m); response.FieldSmallDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.FieldSmallInt.Should().Be(1); response.FieldSmallMoney.Should().Be(1m); response.FieldText.Should().Be("A"); response.FieldTime.Should().Be(TimeSpan.Parse("0")); response.FieldTimestamp.Should().BeEquivalentTo(BitConverter.GetBytes(1)); response.FieldTinyInt.Should().Be(1); response.FieldUniqueIdentifier.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); response.FieldVarBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1)); response.FieldVarchar.Should().Be("A"); response.FieldXML.Should().Be("A"); response.Id.Should().Be(1); }
public virtual TestAllFieldTypesNullable MapModelToEntity( int id, ApiTestAllFieldTypesNullableServerRequestModel model ) { TestAllFieldTypesNullable item = new TestAllFieldTypesNullable(); item.SetProperties( id, model.FieldBigInt, model.FieldBinary, model.FieldBit, model.FieldChar, model.FieldDate, model.FieldDateTime, model.FieldDateTime2, model.FieldDateTimeOffset, model.FieldDecimal, model.FieldFloat, model.FieldImage, model.FieldMoney, model.FieldNChar, model.FieldNText, model.FieldNumeric, model.FieldNVarchar, model.FieldReal, model.FieldSmallDateTime, model.FieldSmallInt, model.FieldSmallMoney, model.FieldText, model.FieldTime, model.FieldTimestamp, model.FieldTinyInt, model.FieldUniqueIdentifier, model.FieldVarBinary, model.FieldVarchar, model.FieldXML); return(item); }
public virtual async Task <UpdateResponse <ApiTestAllFieldTypesNullableServerResponseModel> > Update( int id, ApiTestAllFieldTypesNullableServerRequestModel model) { var validationResult = await this.TestAllFieldTypesNullableModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { TestAllFieldTypesNullable record = this.DalTestAllFieldTypesNullableMapper.MapModelToEntity(id, model); await this.TestAllFieldTypesNullableRepository.Update(record); record = await this.TestAllFieldTypesNullableRepository.Get(id); ApiTestAllFieldTypesNullableServerResponseModel apiModel = this.DalTestAllFieldTypesNullableMapper.MapEntityToModel(record); await this.mediator.Publish(new TestAllFieldTypesNullableUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiTestAllFieldTypesNullableServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiTestAllFieldTypesNullableServerResponseModel> .UpdateResponse(validationResult)); } }
public virtual BOTestAllFieldTypesNullable MapEFToBO( TestAllFieldTypesNullable ef) { var bo = new BOTestAllFieldTypesNullable(); bo.SetProperties( ef.Id, ef.FieldBigInt, ef.FieldBinary, ef.FieldBit, ef.FieldChar, ef.FieldDate, ef.FieldDateTime, ef.FieldDateTime2, ef.FieldDateTimeOffset, ef.FieldDecimal, ef.FieldFloat, ef.FieldImage, ef.FieldMoney, ef.FieldNChar, ef.FieldNText, ef.FieldNumeric, ef.FieldNVarchar, ef.FieldReal, ef.FieldSmallDateTime, ef.FieldSmallInt, ef.FieldSmallMoney, ef.FieldText, ef.FieldTime, ef.FieldTimestamp, ef.FieldTinyInt, ef.FieldUniqueIdentifier, ef.FieldVarBinary, ef.FieldVarchar, ef.FieldXML); return(bo); }
public virtual TestAllFieldTypesNullable MapBOToEF( BOTestAllFieldTypesNullable bo) { TestAllFieldTypesNullable efTestAllFieldTypesNullable = new TestAllFieldTypesNullable(); efTestAllFieldTypesNullable.SetProperties( bo.FieldBigInt, bo.FieldBinary, bo.FieldBit, bo.FieldChar, bo.FieldDate, bo.FieldDateTime, bo.FieldDateTime2, bo.FieldDateTimeOffset, bo.FieldDecimal, bo.FieldFloat, bo.FieldImage, bo.FieldMoney, bo.FieldNChar, bo.FieldNText, bo.FieldNumeric, bo.FieldNVarchar, bo.FieldReal, bo.FieldSmallDateTime, bo.FieldSmallInt, bo.FieldSmallMoney, bo.FieldText, bo.FieldTime, bo.FieldTimestamp, bo.FieldTinyInt, bo.FieldUniqueIdentifier, bo.FieldVarBinary, bo.FieldVarchar, bo.FieldXML, bo.Id); return(efTestAllFieldTypesNullable); }
public virtual ApiTestAllFieldTypesNullableServerResponseModel MapEntityToModel( TestAllFieldTypesNullable item) { var model = new ApiTestAllFieldTypesNullableServerResponseModel(); model.SetProperties(item.Id, item.FieldBigInt, item.FieldBinary, item.FieldBit, item.FieldChar, item.FieldDate, item.FieldDateTime, item.FieldDateTime2, item.FieldDateTimeOffset, item.FieldDecimal, item.FieldFloat, item.FieldImage, item.FieldMoney, item.FieldNChar, item.FieldNText, item.FieldNumeric, item.FieldNVarchar, item.FieldReal, item.FieldSmallDateTime, item.FieldSmallInt, item.FieldSmallMoney, item.FieldText, item.FieldTime, item.FieldTimestamp, item.FieldTinyInt, item.FieldUniqueIdentifier, item.FieldVarBinary, item.FieldVarchar, item.FieldXML); return(model); }