public void SSG_Identifier_should_map_to_PersonalIdentifier_correctly() { SSG_Identifier sSG_Identifier = new SSG_Identifier() { Identification = "testIdentification", Date1 = new DateTime(2001, 1, 1), Date1Label = "effectiveDate", Date2 = new DateTime(2001, 1, 1), Date2Label = "expiredDate", IdentifierType = IdentificationType.SocialInsuranceNumber.Value, InformationSource = InformationSourceType.ICBC.Value, IssuedBy = "BC", SupplierTypeCode = "TypeCode", Description = "description", Notes = "note" }; PersonalIdentifier identifier = _mapper.Map <PersonalIdentifier>(sSG_Identifier); Assert.AreEqual("testIdentification", identifier.Value); Assert.AreEqual("note", identifier.Notes); Assert.AreEqual("description", identifier.Description); Assert.AreEqual("BC", identifier.IssuedBy); Assert.AreEqual("TypeCode", identifier.TypeCode); Assert.AreEqual(2, identifier.ReferenceDates.Count()); Assert.AreEqual(PersonalIdentifierType.SocialInsuranceNumber, identifier.Type); }
public void SSG_Identifier_should_map_to_PersonalIdentifier_correctly() { SSG_Identifier sSG_Identifier = new SSG_Identifier() { Identification = "testIdentification", IdentificationEffectiveDate = new DateTime(2001, 1, 1), IdentificationExpirationDate = new DateTime(2001, 1, 1), IdentifierType = IdentificationType.SocialInsuranceNumber.Value, InformationSource = InformationSourceType.Employer.Value }; PersonalIdentifier identifier = _mapper.Map <PersonalIdentifier>(sSG_Identifier); Assert.AreEqual("testIdentification", identifier.Value); Assert.AreEqual(new DateTimeOffset(new DateTime(2001, 1, 1)), identifier.EffectiveDate); Assert.AreEqual(new DateTimeOffset(new DateTime(2001, 1, 1)), identifier.ExpirationDate); Assert.AreEqual(PersonalIdentifierType.SocialInsuranceNumber, identifier.Type); }
public ICollection <ReferenceDate> Resolve(IdentifierEntity source, PersonalIdentifier destination, ICollection <ReferenceDate> destMember, ResolutionContext context) { List <ReferenceDate> referDates = new List <ReferenceDate>(); if (source.Date1 != null) { referDates.Add(new ReferenceDate() { Index = 0, Key = source.Date1Label, Value = new DateTimeOffset((DateTime)source.Date1) }); } if (source.Date2 != null) { referDates.Add(new ReferenceDate() { Index = 1, Key = source.Date2Label, Value = new DateTimeOffset((DateTime)source.Date2) }); } return(referDates); }
public void SSG_Identifier_should_map_to_Person_Identifier_correctly() { var id = new SSG_Identifier { Identification = "1234455", IssuedBy = "ICBC", Date1Label = "label", Date1 = new DateTime(2000, 1, 1), ResponseComments = "identifierComments", IdentifierType = IdentificationType.BCDriverLicense.Value, }; PersonalIdentifier personalIdentifier = _mapper.Map <PersonalIdentifier>(id); Assert.AreEqual("ICBC", personalIdentifier.IssuedBy); Assert.AreEqual("1234455", personalIdentifier.Value); Assert.AreEqual("identifierComments", personalIdentifier.ResponseComments); Assert.AreEqual(PersonalIdentifierType.BCDriverLicense, personalIdentifier.Type); Assert.AreEqual(1, personalIdentifier.ReferenceDates.Count); }
public async Task <SSG_Identifier> GetMatchedSourceIdentifier(PersonalIdentifier identifer, string searchRequestKey) { SSG_SearchApiRequest searchApiReqeust = await GetSearchApiRequest(searchRequestKey); if (searchApiReqeust == null) { _logger.LogError("Cannot find the searchApiRequest in Redis Cache."); return(null); } if (identifer == null) { _logger.LogDebug("source identifier from personfound is null"); return(null); } int?type = IDType.IDTypeDictionary.FirstOrDefault(m => m.Value == identifer.Type).Key; return(searchApiReqeust.Identifiers.FirstOrDefault( m => m.Identification == identifer.Value && m.IdentifierType == type)); }
public void PersonalIdentifierActual_should_map_to_SSG_Identifier_correctly() { PersonalIdentifier identifier = new PersonalIdentifier() { Value = "1111111", Type = PersonalIdentifierType.BCDriverLicense, IssuedBy = "BC", Description = "description", Notes = "notes", TypeCode = "BCDL", ReferenceDates = new List <ReferenceDate>() { new ReferenceDate() { Index = 0, Key = "startDate", Value = new DateTime(2012, 1, 1) }, new ReferenceDate() { Index = 1, Key = "endDate", Value = new DateTime(2014, 1, 1) }, } }; SSG_Identifier sSG_Identifier = _mapper.Map <SSG_Identifier>(identifier); Assert.AreEqual("1111111", sSG_Identifier.Identification); Assert.AreEqual("description", sSG_Identifier.Description); Assert.AreEqual("notes", sSG_Identifier.Notes); Assert.AreEqual("BCDL", sSG_Identifier.SupplierTypeCode); Assert.AreEqual("BC", sSG_Identifier.IssuedBy); Assert.AreEqual(new DateTime(2012, 1, 1), sSG_Identifier.Date1); Assert.AreEqual(new DateTime(2014, 1, 1), sSG_Identifier.Date2); Assert.AreEqual("startDate", sSG_Identifier.Date1Label); Assert.AreEqual("endDate", sSG_Identifier.Date2Label); Assert.AreEqual(IdentificationType.BCDriverLicense.Value, sSG_Identifier.IdentifierType); Assert.AreEqual(1, sSG_Identifier.StatusCode); Assert.AreEqual(0, sSG_Identifier.StateCode); }
public void Init() { _validSearchApiRequestGuid = Guid.NewGuid(); _validSouceIdentifierGuid = Guid.NewGuid(); _wrongSearchApiRequestGuid = Guid.NewGuid(); _wrongSourceIdentifierGuid = Guid.NewGuid(); _validSearchRequestKey = "1234_0000"; _invalidSearchRequestKey = "1234_7777"; dataProviderMock.Setup(x => x.GetAllDataProviders(It.IsAny <CancellationToken>())) .Returns(Task.FromResult <IEnumerable <SSG_DataProvider> >( new List <SSG_DataProvider>() { new SSG_DataProvider() { AdaptorName = adaptorName, NumberOfDaysToRetry = retries, SearchSpeed = AutoSearchSpeedType.Fast.Value, TimeBetweenRetries = 60, NumberOfRetries = 3 } } )); _fakeRequest = new SSG_SearchApiRequest { SearchRequest = new SSG_SearchRequest() { FileId = "111111" }, Identifiers = new List <SSG_Identifier>() { new SSG_Identifier() { Identification = "1234567", IdentifierType = IdentificationType.BirthCertificate.Value, IdentifierId = _validSouceIdentifierGuid } }.ToArray() }; _fakeIdentifier = new PersonalIdentifier { Value = "1234567", Type = PersonalIdentifierType.BirthCertificate }; _wrongIdentifier = new PersonalIdentifier { Value = "7654321", Type = PersonalIdentifierType.BCDriverLicense }; _cacheServiceMock.Setup(x => x.Save(It.IsAny <string>(), It.IsAny <object>())) .Returns(Task.FromResult(true)); _cacheServiceMock.Setup(x => x.Get(It.Is <string>(m => m.ToString() == Keys.REDIS_KEY_PREFIX + _validSearchApiRequestGuid.ToString()))) .Returns(Task.FromResult(JsonConvert.SerializeObject(_fakeRequest))); _cacheServiceMock.Setup(x => x.Get(It.Is <string>(m => m.ToString() == Keys.REDIS_KEY_PREFIX + Keys.DATA_PROVIDER_KEY))) .Returns(Task.FromResult(JsonConvert.SerializeObject(new List <SSG_DataProvider>() { new SSG_DataProvider() { AdaptorName = adaptorName, NumberOfDaysToRetry = retries, SearchSpeed = AutoSearchSpeedType.Fast.Value, TimeBetweenRetries = 60, NumberOfRetries = 3 } }.ToArray()))); _cacheServiceMock.Setup(x => x.Get(It.Is <string>(m => m == $"{Keys.REDIS_KEY_PREFIX}{_validSearchRequestKey}"))) .Returns(Task.FromResult(JsonConvert.SerializeObject(_fakeRequest))); _cacheServiceMock.Setup(x => x.Delete(It.Is <string>(m => m.ToString() == Keys.REDIS_KEY_PREFIX + _validSearchApiRequestGuid.ToString()))) .Returns(Task.FromResult(true)); _cacheServiceMock.Setup(x => x.Delete(It.Is <string>(m => m.ToString() == $"{Keys.REDIS_KEY_PREFIX}{_validSearchRequestKey}"))) .Returns(Task.FromResult(true)); _cacheServiceMock.Setup(x => x.Get(It.Is <string>(m => m.ToString() == Keys.REDIS_KEY_PREFIX + _wrongSearchApiRequestGuid.ToString()))) .Returns(Task.FromResult("")); _cacheServiceMock.Setup(x => x.Get(It.Is <string>(m => m.ToString() == $"{Keys.REDIS_KEY_PREFIX}{_invalidSearchRequestKey}"))) .Returns(Task.FromResult("")); _loggerMock = new Mock <ILogger <SearchRequestRegister> >(); _sut = new SearchRequestRegister(_cacheServiceMock.Object, _loggerMock.Object, dataProviderMock.Object); }
public void SetUp() { _expectedProviderDescription = new Mock <IProviderDescription>().Object; _sut = new PersonalIdentifier(ExpectedIdentifierType, ExpectedValue, _expectedProviderDescription); }