public void Test_Period_DateTimePeriodIndexSetter_BadStringFormat() { //Arrange var Period = new Period(); Period.Start = "1974-12-25XXXT10: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_FhirBoolean_TokenIndexSetter_No_Code_Set_As_Null() { //Arrange var FhirBoolean = new FhirBoolean(); FhirBoolean.Value = null; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(FhirBoolean, Index) as TokenIndex; //Assert Assert.IsNull(Index); }
public void Test_PositiveInt_TokenIndexSetter_Value_IsNull() { //Arrange var PositiveInt = new PositiveInt(); PositiveInt.Value = null; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(PositiveInt, Index) as TokenIndex; //Assert Assert.IsNull(Index); }
public void Test_FhirDateTime_DateTimePeriodIndexSetter_GoodFormat_NoRange() { //Arrange var DateTimeOffSet = new DateTimeOffset(1974, 12, 25, 10, 35, 45, new TimeSpan(-5, 00, 00)); var FhirDateTime = new FhirDateTime(DateTimeOffSet); DateTimePeriodIndex Index = new DateTimePeriodIndex(); //Act Index = IndexSetterFactory.Create(typeof(DateTimePeriodIndex)).Set(FhirDateTime, Index) as DateTimePeriodIndex; //Assert Assert.AreEqual(Index.DateTimeOffsetLow, DateTimeOffSet); Assert.AreEqual(Index.DateTimeOffsetHigh, DateTimeOffSet); }
public void Test_Coding_TokenIndexSetter_OnlySystem() { //Arrange string TheSystem = "SomeCodeSystem"; var Coding = new Coding(); Coding.System = TheSystem; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(Coding, Index) as TokenIndex; //Assert Assert.IsNull(Index.Code); Assert.AreEqual(Index.System, TheSystem); }
public void Test_PositiveInt_NumberIndexSetter_BadFormat() { //Arrange int Value = -13; var PositiveInt = new PositiveInt(); PositiveInt.Value = Value; NumberIndex Index = new NumberIndex(); //Act ActualValueDelegate <NumberIndex> testDelegate = () => IndexSetterFactory.Create(typeof(NumberIndex)).Set(PositiveInt, Index) as NumberIndex; //Assert Assert.That(testDelegate, Throws.TypeOf <FormatException>()); }
public void Test_Period_DateTimePeriodIndexSetter_LowAndHighAreNull() { //Arrange var Period = new Period(); var LowDateTimeOffSet = new DateTimeOffset(1974, 12, 25, 10, 35, 45, new TimeSpan(-5, 00, 00)); Period.StartElement = null; Period.EndElement = null; DateTimePeriodIndex Index = new DateTimePeriodIndex(); //Act Index = IndexSetterFactory.Create(typeof(DateTimePeriodIndex)).Set(Period, Index) as DateTimePeriodIndex; //Assert Assert.IsNull(Index); }
public void Test_FhirString_DateTimePeriodIndexSetter_BadFormat() { //Arrange var FhirString = new FhirString(); var DateTimeOffSet = new DateTimeOffset(1974, 12, 25, 10, 35, 45, new TimeSpan(-5, 00, 00)); FhirString.Value = "1974-12-25T25:35:45-05:00"; DateTimePeriodIndex Index = new DateTimePeriodIndex(); //Act Index = IndexSetterFactory.Create(typeof(DateTimePeriodIndex)).Set(FhirString, Index) as DateTimePeriodIndex; //Assert Assert.IsNull(Index); }
public void Test_FhirDate_TokenIndexSetter_BadFormat() { //Arrange string TheCode = "2012-12-28T09:03:04+11:90"; var FhirDateTime = new FhirDateTime(); FhirDateTime.Value = TheCode; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(FhirDateTime, Index) as TokenIndex; //Assert Assert.IsNull(Index); }
public void Test_ContactPoint_TokenIndexSetter_OnlyCode() { //Arrange string TheValue = "*****@*****.**"; var ContactPoint = new ContactPoint(); ContactPoint.Value = TheValue; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(ContactPoint, Index) as TokenIndex; //Assert Assert.AreEqual(Index.Code, TheValue); Assert.IsNull(Index.System); }
public void Test_Code_TokenIndexSetter_No_Code_Set() { //Arrange string CodeString = ""; var Code = new Code(); Code.Value = CodeString; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(Code, Index) as TokenIndex; //Assert Assert.IsNull(Index); }
public void Test_FhirUri_UriIndexSetter_GoodFormat() { //Arrange Uri TheUri = new Uri("http://acme.org/fhir/ValueSet/123"); var FhirUri = new FhirUri(); FhirUri.Value = TheUri.OriginalString; UriIndex Index = new UriIndex(); //Act Index = IndexSetterFactory.Create(typeof(UriIndex)).Set(FhirUri, Index) as UriIndex; //Assert Assert.AreEqual(Index.Uri, TheUri.OriginalString); }
public void Test_Period_DateTimePeriodIndexSetter_HighIsNull() { //Arrange var Period = new Period(); var LowDateTimeOffSet = new DateTimeOffset(1974, 12, 25, 10, 35, 45, new TimeSpan(-5, 00, 00)); Period.Start = "1974-12-25T10:35:45-05:00"; Period.EndElement = null; DateTimePeriodIndex Index = new DateTimePeriodIndex(); //Act Index = IndexSetterFactory.Create(typeof(DateTimePeriodIndex)).Set(Period, Index) as DateTimePeriodIndex; //Assert Assert.AreEqual(Index.DateTimeOffsetLow, LowDateTimeOffSet); Assert.IsNull(Index.DateTimeOffsetHigh); }
public void Test_FhirString_DateTimePeriodIndexSetter_GoodFormat_NoRange() { //Arrange var FhirString = new FhirString(); var DateTimeOffSet = new DateTimeOffset(1974, 12, 25, 10, 35, 45, new TimeSpan(-5, 00, 00)); FhirString.Value = "1974-12-25T10:35:45-05:00"; DateTimePeriodIndex Index = new DateTimePeriodIndex(); //Act Index = IndexSetterFactory.Create(typeof(DateTimePeriodIndex)).Set(FhirString, Index) as DateTimePeriodIndex; //Assert Assert.AreEqual(Index.DateTimeOffsetLow, DateTimeOffSet); Assert.AreEqual(Index.DateTimeOffsetHigh, DateTimeOffSet); }
public void Test_FhirString_TokenIndexSetter_EmptyString() { //Arrange string TheCode = string.Empty; var FhirDateTime = new FhirString(); FhirDateTime.Value = TheCode; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(FhirDateTime, Index) as TokenIndex; //Assert Assert.IsNull(Index); }
public void Test_Annotation_StringIndexSetter_GoodFormat() { //Arrange string Text = "This is the Annotation Text"; var Annotation = new Annotation(); Annotation.Text = Text; StringIndex Index = new StringIndex(); //Act Index = IndexSetterFactory.Create(typeof(StringIndex)).Set(Annotation, Index) as StringIndex; //Assert Assert.AreEqual(Index.String, Pyro.Common.Tools.StringSupport.ToLowerAndRemoveDiacritics(Text)); }
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_Markdown_StringIndexSetter_GoodFormat() { //Arrange string Text = "This is the Markdown string Text"; var Markdown = new Markdown(); Markdown.Value = Text; StringIndex Index = new StringIndex(); //Act Index = IndexSetterFactory.Create(typeof(StringIndex)).Set(Markdown, Index) as StringIndex; //Assert Assert.AreEqual(Index.String, Pyro.Common.Tools.StringSupport.ToLowerAndRemoveDiacritics(Text)); }
public void Test_Integer_NumberIndexSetter_GoodFormat() { //Arrange int Value = 13; var Integer = new Integer(); Integer.Value = Value; NumberIndex Index = new NumberIndex(); //Act Index = IndexSetterFactory.Create(typeof(NumberIndex)).Set(Integer, Index) as NumberIndex; //Assert Assert.AreEqual(Index.Quantity, Value); Assert.IsNull(Index.Comparator); }
public void Test_FhirString_StringIndexSetter_GoodFormat() { //Arrange string Text = "This is the Fhir string Text"; var FhirString = new FhirString(); FhirString.Value = Text; StringIndex Index = new StringIndex(); //Act Index = IndexSetterFactory.Create(typeof(StringIndex)).Set(FhirString, Index) as StringIndex; //Assert Assert.AreEqual(Index.String, Pyro.Common.Tools.StringSupport.ToLowerAndRemoveDiacritics(Text)); }
public void Test_PositiveInt_NumberIndexSetter_GoodFormat() { //Arrange int Value = 13; var PositiveInt = new PositiveInt(); PositiveInt.Value = Value; NumberIndex Index = new NumberIndex(); //Act Index = IndexSetterFactory.Create(typeof(NumberIndex)).Set(PositiveInt, Index) as NumberIndex; //Assert Assert.AreEqual(Index.Quantity, Value); Assert.IsNull(Index.Comparator); }
public void Test_Duration_NumberIndexSetter_GoodFormatNoComparator() { //Arrange decimal Value = 123.500M; var Duration = new Duration(); Duration.Value = Value; NumberIndex Index = new NumberIndex(); //Act Index = IndexSetterFactory.Create(typeof(NumberIndex)).Set(Duration, Index) as NumberIndex; //Assert Assert.AreEqual(Index.Quantity, Value); Assert.IsNull(Index.Comparator); }
public void Test_FhirUri_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); //IFhirUri ReferanceFhirUri = new Pyro.Common.BusinessEntities.UriSupport.DtoFhirUri(ReferanceUrlString); FhirUri 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.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_Address_TokenIndexSetter_CodeT_IsNull() { //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); Code <Bundle.BundleType> Code = null; TokenIndex Index = new TokenIndex(); //Act ActualValueDelegate <TokenIndex> testDelegate = () => IndexSetterFactory.Create(typeof(TokenIndex)).Set(Code, Index) as TokenIndex; //Assert Assert.That(testDelegate, Throws.TypeOf <ArgumentNullException>()); }
public void Test_Id_TokenIndexSetter_EmptyString() { //Arrange string TheCode = string.Empty; var Id = new Id(); Id.Value = TheCode; TokenIndex Index = new TokenIndex(); //Act Index = IndexSetterFactory.Create(typeof(TokenIndex)).Set(Id, Index) as TokenIndex; //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 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_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); }