public void Test_Period_DateTimePeriodIndexSetter_BadHighStringFormat() { //Arrange var Period = new Period(); var LowDateTimeOffSet = new DateTimeOffset(1974, 12, 25, 10, 35, 45, new TimeSpan(-5, 00, 00)); var HighDateTimeOffSet = new DateTimeOffset(1974, 12, 25, 11, 35, 45, new TimeSpan(-5, 00, 00)); Period.Start = "1974-12-25T10:35:45-05:00"; Period.End = "1974-12-25T11XXX:35:45-05:00"; DateTimePeriodIndex Index = new DateTimePeriodIndex(); //Act ActualValueDelegate <DateTimePeriodIndex> testDelegate = () => IndexSetterFactory.Create(typeof(DateTimePeriodIndex)).Set(Period, Index) as DateTimePeriodIndex; //Assert Assert.That(testDelegate, Throws.TypeOf <FormatException>()); }
public void Test_ResourceReference_Referance_IndexSetter_Uri_Is_RelativeUri() { //Info: This is a Uri that is not a Fhir resource reference, it is actually a GUID expressed as a Uri. //In this case as it is not a FhirUriReferance we want to return null as it is not searchable as a //Search parameter type of Reference. //Arrange string ServiceRootUrlString = "http://SomeWhere.net.au/FhirApi/Patient"; string ReferanceUrlString = "Encounter/10"; IFhirUri ReferanceFhirUri = Common.CommonFactory.GetFhirUri(ReferanceUrlString); var ResourceReference = new ResourceReference(); ResourceReference.Reference = ReferanceUrlString; //Mok the inbound Request Url, this contains the service root url from the db. Mock <IDtoFhirRequestUri> MockIDtoFhirRequestUri = new Mock <IDtoFhirRequestUri>(); var ServiceRootUrl = new Uri(ServiceRootUrlString); IFhirUri RequestFhirUri = Common.CommonFactory.GetFhirUri(ServiceRootUrl); MockIDtoFhirRequestUri.Setup(x => x.FhirUri).Returns(RequestFhirUri); var ServiceDtoRootUrlStore = new Pyro.Common.BusinessEntities.Dto.DtoRootUrlStore(); ServiceDtoRootUrlStore.Id = 1; ServiceDtoRootUrlStore.IsServersPrimaryUrlRoot = true; ServiceDtoRootUrlStore.Url = ServiceRootUrlString; MockIDtoFhirRequestUri.Setup(x => x.PrimaryRootUrlStore).Returns(ServiceDtoRootUrlStore); //Mok the response from the db from the Common repository, this if request Url does not match service root url Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository> MockICommonRepository = new Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository>(); ReferenceIndex Index = new ReferenceIndex(); //Act Index = IndexSetterFactory.Create(typeof(ReferenceIndex)).Set(ResourceReference, Index, MockIDtoFhirRequestUri.Object, MockICommonRepository.Object) as ReferenceIndex; //Assert Assert.AreEqual(Index.FhirId, ReferanceFhirUri.Id); Assert.AreEqual(Index.Type, ReferanceFhirUri.ResourseType); Assert.IsNull(Index.Url); Assert.IsNull(Index.VersionId); Assert.AreEqual(Index.ServiceRootURL_StoreID, 1); Assert.DoesNotThrow(() => MockICommonRepository.Verify(x => x.GetAndOrAddService_RootUrlStore(ReferanceFhirUri.ServiceRootUrlForComparison), Times.Never)); }
public void Test_FhirBoolean_TokenIndexSetter_GoodFormatFalse() { //Arrange bool TheCode = false; var Code = new FhirBoolean(); Code.Value = TheCode; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(Code, Index) as TokenIndex; //Assert Assert.AreEqual(Index.Code, "false"); Assert.IsNull(Index.System); }
public void Test_Id_TokenIndexSetter_GoodFormat() { //Arrange string TheCode = "4d09741b-e407-4a1f-808a-4b9bf864d956"; var Id = new Id(); Id.Value = TheCode; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(Id, Index) as TokenIndex; //Assert Assert.AreEqual(Index.Code, TheCode); Assert.IsNull(Index.System); }
public void Test_Period_DateTimePeriodIndexSetter_GoodFormat() { //Arrange var Period = new Period(); var LowDateTimeOffSet = new DateTimeOffset(1974, 12, 25, 10, 35, 45, new TimeSpan(-5, 00, 00)); var HighDateTimeOffSet = new DateTimeOffset(1974, 12, 25, 11, 35, 45, new TimeSpan(-5, 00, 00)); Period.Start = "1974-12-25T10:35:45-05:00"; Period.End = "1974-12-25T11:35:45-05:00"; DateTimePeriodIndex Index = new DateTimePeriodIndex(); //Act Index = IndexSetterFactory.Create(typeof(DateTimePeriodIndex)).Set(Period, Index) as DateTimePeriodIndex; //Assert Assert.AreEqual(Index.DateTimeOffsetLow, LowDateTimeOffSet); Assert.AreEqual(Index.DateTimeOffsetHigh, HighDateTimeOffSet); }
public void Test_Code_TokenIndexSetter_GoodFormat() { //Arrange string CodeString = "SomeCode"; var Code = new Code(); Code.Value = CodeString; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(Code, Index) as TokenIndex; //Assert Assert.AreEqual(Index.Code, CodeString); Assert.IsNull(Index.System); }
public void Test_Duration_NumberIndexSetter_GoodFormat() { //Arrange decimal Value = 10.5M; var Comparator = Quantity.QuantityComparator.GreaterOrEqual; var Duration = new Duration(); Duration.Value = Value; Duration.Comparator = Comparator; NumberIndex Index = new NumberIndex(); //Act Index = IndexSetterFactory.Create(typeof(NumberIndex)).Set(Duration, Index) as NumberIndex; //Assert Assert.AreEqual(Index.Quantity, Value); Assert.AreEqual(Index.Comparator, Comparator); }
public void Test_FhirString_DateTimePeriodIndexSetter_GoodFormat_WithRange_FormatTwo() { //Arrange var FhirString = new FhirString(); var DateTimeOffSetLow = new DateTimeOffset(1974, 12, 25, 10, 35, 45, new TimeSpan(-5, 00, 00)); var DateTimeOffSetHigh = new DateTimeOffset(1974, 12, 25, 11, 00, 45, new TimeSpan(-5, 00, 00)); FhirString.Value = "1974-12-25T10:35:45-05:00 1974-12-25T11:00:45-05:00"; DateTimePeriodIndex Index = new DateTimePeriodIndex(); //Act Index = IndexSetterFactory.Create(typeof(DateTimePeriodIndex)).Set(FhirString, Index) as DateTimePeriodIndex; //Assert Assert.AreEqual(Index.DateTimeOffsetLow, DateTimeOffSetLow); Assert.AreEqual(Index.DateTimeOffsetHigh, DateTimeOffSetHigh); }
public void Test_Timing_DateTimePeriodIndexSetter_NoLowDate() { //Arrange var Timing = new Timing(); DateTimePeriodIndex Index = new DateTimePeriodIndex(); Timing.EventElement = new System.Collections.Generic.List <FhirDateTime>(); Timing.Repeat = new Timing.RepeatComponent(); Timing.Repeat.Duration = new decimal(10.0); Timing.Repeat.DurationUnit = Timing.UnitsOfTime.Min; //Act Index = IndexSetterFactory.Create(typeof(DateTimePeriodIndex)).Set(Timing, Index) as DateTimePeriodIndex; //Assert Assert.IsNull(Index); }
public void Test_FhirString_TokenIndexSetter_GoodFormat() { //Arrange string TheCode = "Some string stuff"; var FhirDateTime = new FhirString(); FhirDateTime.Value = TheCode; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(FhirDateTime, Index) as TokenIndex; //Assert Assert.AreEqual(Index.Code, TheCode); Assert.IsNull(Index.System); }
public void AAATest_Address_TokenIndexSetter_GoodFormat() { //Arrange string CodeString = "Bla"; var Code = new Coding(); Code.Code = CodeString; Pyro.DataModel.DatabaseModel.Res_Account_Index__security Index = new Pyro.DataModel.DatabaseModel.Res_Account_Index__security(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(Code, Index) as Pyro.DataModel.DatabaseModel.Res_Account_Index__security; //Assert Assert.AreEqual(Index.Code, CodeString); Assert.IsNull(Index.System); }
public void Test_ContactPoint_TokenIndexSetter_OnlySystem() { //Arrange ContactPoint.ContactPointSystem TheSystem = Hl7.Fhir.Model.ContactPoint.ContactPointSystem.Email; string TheSystemString = TheSystem.GetLiteral(); //string TheSystemString = Hl7.Fhir.Introspection.EnumMapping.Create(typeof(Hl7.Fhir.Model.ContactPoint.ContactPointSystem)).GetLiteral(TheSystem); var ContactPoint = new ContactPoint(); ContactPoint.System = TheSystem; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(ContactPoint, Index) as TokenIndex; //Assert Assert.IsNull(Index.Code); Assert.AreEqual(Index.System, TheSystemString); }
public void Test_Coding_TokenIndexSetter_GoodFormat() { //Arrange string TheCode = "SomeCode"; string TheSystem = "SomeCodeSystem"; var Coding = new Coding(); Coding.Code = TheCode; Coding.System = TheSystem; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(Coding, Index) as TokenIndex; //Assert Assert.AreEqual(Index.Code, TheCode); Assert.AreEqual(Index.System, TheSystem); }
public void Test_Identifier_TokenIndexSetter_System_IsNull() { //Arrange string TheCode = "1234567890"; var Identifier = new Identifier(); Identifier.Value = TheCode; Identifier.System = null; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(Identifier, Index) as TokenIndex; //Assert Assert.AreEqual(Index.Code, TheCode); Assert.IsNull(Index.System); }
public void Test_Range_TokenIndexSetter_GoodFormat_ISNull() { //Arrange var Range = new Range(); Range.Low = new SimpleQuantity(); Range.Low.Value = 10.0M; Range.High = new SimpleQuantity(); Range.High.Value = 10.0M; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(Range, Index) as TokenIndex; //Assert Assert.IsNull(Index); }
public void Test_PositiveInt_TokenIndexSetter_GoodFormat() { //Arrange int TheCode = 12345; string TheCodeString = "12345"; var PositiveInt = new PositiveInt(); PositiveInt.Value = TheCode; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(PositiveInt, Index) as TokenIndex; //Assert Assert.AreEqual(Index.Code, TheCodeString); Assert.IsNull(Index.System); }
public void Test_Identifier_TokenIndexSetter_Value_IsNull() { //Arrange string TheSystem = "http://ns.electronichealth.net.au/id/hi/ihi/1.0"; var Identifier = new Identifier(); Identifier.Value = null; Identifier.System = TheSystem; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(Identifier, Index) as TokenIndex; //Assert Assert.IsNull(Index.Code); Assert.AreEqual(Index.System, TheSystem); }
public void Test_Quantity_NumberIndexSetter_Value_IsNull() { //Arrange var Comparator = Hl7.Fhir.Model.Quantity.QuantityComparator.GreaterOrEqual; var Code = "ABC"; var System = "www.SomeCodeSystem.com"; var Quantity = new Quantity(); Quantity.Value = null; Quantity.Comparator = Comparator; Quantity.Code = Code; Quantity.System = System; QuantityIndex Index = new QuantityIndex(); //Act Index = IndexSetterFactory.Create(typeof(QuantityIndex)).Set(Quantity, Index) as QuantityIndex; //Assert Assert.IsNull(Index); }
public void Test_Address_TokenIndexSetter_GoodFormat() { //Arrange Bundle.BundleType TheCode = Bundle.BundleType.Document; string CodeString = TheCode.GetLiteral(); //string CodeString = Hl7.Fhir.Introspection.EnumMapping.Create(typeof(Hl7.Fhir.Model.Bundle.BundleType)).GetLiteral(TheCode); var Code = new Code <Bundle.BundleType>(); Code.Value = TheCode; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(Code, Index) as TokenIndex; //Assert Assert.AreEqual(Index.Code, CodeString); Assert.IsNull(Index.System); }
public void Test_Quantity_TokenIndexSetter_GoodFormat() { //Arrange decimal TheCode = 001123.5500M; string TheCodeString = "1123.5500"; string TheSystem = "mg/L"; var Quantity = new Quantity(); Quantity.Value = TheCode; Quantity.Unit = TheSystem; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(Quantity, Index) as TokenIndex; //Assert Assert.AreEqual(Index.Code, TheCodeString); Assert.AreEqual(Index.System, TheSystem); }
public void Test_CodableConcept_TokenIndexSetter_UnsupportedCodeType() { //Arrange var CodeableConcept = new CodeableConcept(); CodeableConcept.Coding = new System.Collections.Generic.List <Coding>() { new Coding() { Code = "SomeCode", System = "SomeSystem" } }; TokenIndex Index = new TokenIndex(); //Act ActualValueDelegate <TokenIndex> testDelegate = () => IndexSetterFactory.Create(typeof(TokenIndex)).Set(CodeableConcept, Index) as TokenIndex; //Assert Assert.That(testDelegate, Throws.TypeOf <Pyro.Common.BusinessEntities.Dto.DtoPyroException>()); }
public void Test_Range_NumberIndexSetter_GoodFormat() { //Arrange decimal ValueLow = 10.5M; decimal ValueHigh = 20.5M; var Code = "ABC"; var System = "www.SomeCodeSystem.com"; var QuantityLow = new SimpleQuantity(); QuantityLow.Value = ValueLow; QuantityLow.Code = Code; QuantityLow.System = System; var QuantityHigh = new SimpleQuantity(); QuantityHigh.Value = ValueHigh; QuantityHigh.Code = Code; QuantityHigh.System = System; var Range = new Range(); Range.Low = QuantityLow; Range.High = QuantityHigh; QuantityRangeIndex Index = new QuantityRangeIndex(); //Act Index = IndexSetterFactory.Create(typeof(QuantityRangeIndex)).Set(Range, Index) as QuantityRangeIndex; //Assert Assert.AreEqual(Index.QuantityLow, ValueLow); Assert.AreEqual(Index.QuantityHigh, ValueHigh); Assert.IsNull(Index.ComparatorLow); Assert.IsNull(Index.ComparatorHigh); Assert.AreEqual(Index.CodeLow, Code); Assert.AreEqual(Index.CodeHigh, Code); Assert.AreEqual(Index.SystemLow, System); Assert.AreEqual(Index.SystemHigh, System); }
public void Test_FhirUri_Referance_IndexSetter_Uri_Is_Not_A_Fhir_Referance_Uri() { //Info: This is a Uri that is not a Fhir resource reference, it is actually a GUID expressed as a Uri. //In this case as it is not a FhirUriReferance we want to return null as it is not searchable as a //Search parameter type of Reference. //Arrange string ServiceRootUrlString = "http://SomeWhere.net.au/FhirApi/Patient"; string ReferanceUrlString = "urn:uuid:53fefa32-fcbb-4ff8-8a92-55ee120877b7"; var FhirUri = new FhirUri(); FhirUri.Value = ReferanceUrlString; //Mok the inbound Request Url, this contains the service root url from the db. Mock <IDtoFhirRequestUri> MockIDtoFhirRequestUri = new Mock <IDtoFhirRequestUri>(); var ServiceRootUrl = new Uri(ServiceRootUrlString); IFhirUri RequestFhirUri = Pyro.Common.CommonFactory.GetFhirUri(ServiceRootUrl); MockIDtoFhirRequestUri.Setup(x => x.FhirUri).Returns(RequestFhirUri); var ServiceDtoRootUrlStore = new Pyro.Common.BusinessEntities.Dto.DtoRootUrlStore(); ServiceDtoRootUrlStore.Id = 1; ServiceDtoRootUrlStore.IsServersPrimaryUrlRoot = true; ServiceDtoRootUrlStore.Url = ServiceRootUrlString; MockIDtoFhirRequestUri.Setup(x => x.PrimaryRootUrlStore).Returns(ServiceDtoRootUrlStore); //Mok the response from the db from the Common repository, this if request Url does not match service root url Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository> MockICommonRepository = new Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository>(); ReferenceIndex Index = new ReferenceIndex(); //Act Index = IndexSetterFactory.Create(typeof(ReferenceIndex)).Set(FhirUri, Index, MockIDtoFhirRequestUri.Object, MockICommonRepository.Object) as ReferenceIndex; //Assert Assert.IsNull(Index); Assert.DoesNotThrow(() => MockICommonRepository.Verify(x => x.GetAndOrAddService_RootUrlStore(ReferanceUrlString), Times.Never)); }
public void Test_Quantity_NumberIndexSetter_System_IsNull() { //Arrange decimal Value = 10.5M; var Comparator = Hl7.Fhir.Model.Quantity.QuantityComparator.GreaterOrEqual; var Quantity = new Quantity(); Quantity.Value = Value; Quantity.Comparator = Comparator; Quantity.Code = null; Quantity.System = null; QuantityIndex Index = new QuantityIndex(); //Act Index = IndexSetterFactory.Create(typeof(QuantityIndex)).Set(Quantity, Index) as QuantityIndex; //Assert Assert.AreEqual(Index.Quantity, Value); Assert.AreEqual(Index.Comparator, Comparator); Assert.IsNull(Index.Code); Assert.IsNull(Index.System); }
public void Test_Money_NumberIndexSetter_Comparator_System_IsNull() { //Arrange decimal Value = 145.523M; var Code = "ABC"; var Money = new Money(); Money.Value = Value; Money.Code = Code; Money.System = null; QuantityIndex Index = new QuantityIndex(); //Act Index = IndexSetterFactory.Create(typeof(QuantityIndex)).Set(Money, Index) as QuantityIndex; //Assert Assert.AreEqual(Index.Quantity, Value); Assert.IsNull(Index.Comparator); Assert.AreEqual(Index.Code, Code); Assert.IsNull(Index.System); }
public void Test_Money_NumberIndexSetter_GoodFormat() { //Arrange decimal Value = 110.35M; var Code = "ABC"; var System = "www.SomeCodeSystem.com"; var Money = new Money(); Money.Value = Value; Money.Code = Code; Money.System = System; QuantityIndex Index = new QuantityIndex(); //Act Index = IndexSetterFactory.Create(typeof(QuantityIndex)).Set(Money, Index) as QuantityIndex; //Assert Assert.AreEqual(Index.Quantity, Value); Assert.IsNull(Index.Comparator); Assert.AreEqual(Index.Code, Code); Assert.AreEqual(Index.System, System); }
public void Test_SimpleQuantity_NumberIndexSetter_Comparator_Code_IsNull() { //Arrange decimal Value = 145.523M; var System = "www.SomeCodeSystem.com"; var Quantity = new SimpleQuantity(); Quantity.Value = Value; Quantity.Code = null; Quantity.System = System; QuantityIndex Index = new QuantityIndex(); //Act Index = IndexSetterFactory.Create(typeof(QuantityIndex)).Set(Quantity, Index) as QuantityIndex; //Assert Assert.AreEqual(Index.Quantity, Value); Assert.IsNull(Index.Comparator); Assert.IsNull(Index.Code); Assert.AreEqual(Index.System, System); }
public void Test_Address_TokenIndexSetter_UnsupportedCodeType() { //Arrange var TheCode = Hl7.Fhir.Model.Bundle.SearchEntryMode.Include; string CodeString = TheCode.GetLiteral(); //string CodeString = Hl7.Fhir.Introspection.EnumMapping.Create(typeof(Hl7.Fhir.Model.Bundle.SearchEntryMode)).GetLiteral(TheCode); var Code = new Code <Bundle.SearchEntryMode>(); Code.Value = TheCode; TokenIndex Index = new TokenIndex(); //Act ActualValueDelegate <TokenIndex> testDelegate = () => IndexSetterFactory.Create(typeof(TokenIndex)).Set(Code, Index) as TokenIndex; //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(Code, Index) as TokenIndex; //Assert Assert.IsNull(Index); }
public void Test_ContactPoint_TokenIndexSetter_GoodFormat() { //Arrange string TheValue = "*****@*****.**"; ContactPoint.ContactPointSystem TheSystem = Hl7.Fhir.Model.ContactPoint.ContactPointSystem.Email; string TheSystemString = TheSystem.GetLiteral(); //string TheSystemString = Hl7.Fhir.Introspection.EnumMapping.Create(typeof(Hl7.Fhir.Model.ContactPoint.ContactPointSystem)).GetLiteral(TheSystem); var ContactPoint = new ContactPoint(); ContactPoint.Value = TheValue; ContactPoint.System = TheSystem; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(ContactPoint, Index) as TokenIndex; //Assert Assert.AreEqual(Index.Code, TheValue); Assert.AreEqual(Index.System, TheSystemString); }
public void Test_HumanName_StringIndexSetter_GoodFormat() { //Arrange string Given1 = "Bob"; string Given2 = "John"; string Family1 = "Smith"; //string Family2 = "Johnston"; var HumanName = new HumanName(); HumanName.Given = new string[] { Given1, Given2 }; HumanName.Family = Family1; StringIndex Index = new StringIndex(); //Act Index = IndexSetterFactory.Create(typeof(StringIndex)).Set(HumanName, Index) as StringIndex; //Assert string HumanNameString = string.Format("{0} {1} {2} {3}", Given1, Given2, Family1); Assert.AreEqual(Index.String, Pyro.Common.Tools.StringSupport.ToLowerAndRemoveDiacritics(HumanNameString)); }