Exemplo n.º 1
0
        private static FhirUriFactory GetFhirUriFactory(string ServersBaseServiceRoot, string[] validResourceNameList)
        {
            Mock <IServiceBaseUrlConfi>         IServiceBaseUrlMock              = IServiceBaseUrl_MockFactory.Get(ServersBaseServiceRoot, ServersBaseServiceRoot);
            Mock <IR4ValidateResourceName>      IR4ValidateResourceNameMock      = IR4ValidateResourceName_MockFactory.Get(validResourceNameList);
            Mock <IStu3ValidateResourceName>    IStu3ValidateResourceNameMock    = IStu3ValidateResourceName_MockFactory.Get(validResourceNameList);
            Mock <IValidateResourceNameFactory> IValidateResourceNameFactoryMock = IValidateResourceNameFactory_MockFactory.Get(IStu3ValidateResourceNameMock.Object, IR4ValidateResourceNameMock.Object);

            FhirUriFactory FhirUriFactory = new FhirUriFactory(IServiceBaseUrlMock.Object, IValidateResourceNameFactoryMock.Object);

            return(FhirUriFactory);
        }
        private static FhirUriFactory GetFhirUriFactory(string resourceName)
        {
            var ValidResourceNames = new string[] { resourceName };
            Mock <IServiceBaseUrlConfi>         IServiceBaseUrlMock              = IServiceBaseUrl_MockFactory.Get(TestData.BaseUrlServer, TestData.BaseUrlServer);
            Mock <IR4ValidateResourceName>      IR4ValidateResourceNameMock      = IR4ValidateResourceName_MockFactory.Get(ValidResourceNames);
            Mock <IStu3ValidateResourceName>    IStu3ValidateResourceNameMock    = IStu3ValidateResourceName_MockFactory.Get(ValidResourceNames);
            Mock <IValidateResourceNameFactory> IValidateResourceNameFactoryMock = IValidateResourceNameFactory_MockFactory.Get(IStu3ValidateResourceNameMock.Object, IR4ValidateResourceNameMock.Object);
            FhirUriFactory FhirUriFactory = new FhirUriFactory(IServiceBaseUrlMock.Object, IValidateResourceNameFactoryMock.Object);

            return(FhirUriFactory);
        }
Exemplo n.º 3
0
        public void TestFhirUri_ResourceNameValidForFhirVersion(FhirVersion fhirVersion, string serversBase, string resourceNameR4, string resourceNameStu3, string resourceId)
        {
            // Prepare
            Mock <IServiceBaseUrlConfi>         IServiceBaseUrlMock              = IServiceBaseUrl_MockFactory.Get(serversBase, serversBase);
            Mock <IR4ValidateResourceName>      IR4ValidateResourceNameMock      = IR4ValidateResourceName_MockFactory.Get(new string[] { resourceNameR4 });
            Mock <IStu3ValidateResourceName>    IStu3ValidateResourceNameMock    = IStu3ValidateResourceName_MockFactory.Get(new string[] { resourceNameStu3 });
            Mock <IValidateResourceNameFactory> IValidateResourceNameFactoryMock = IValidateResourceNameFactory_MockFactory.Get(IStu3ValidateResourceNameMock.Object, IR4ValidateResourceNameMock.Object);

            FhirUriFactory FhirUriFactory = new FhirUriFactory(IServiceBaseUrlMock.Object, IValidateResourceNameFactoryMock.Object);

            string RequestUrl;

            if (fhirVersion == FhirVersion.Stu3)
            {
                RequestUrl = $"{resourceNameStu3}/{resourceId}";
            }
            else
            {
                RequestUrl = $"{resourceNameR4}/{resourceId}";
            }


            //Act
            if (FhirUriFactory.TryParse(RequestUrl, fhirVersion, out IFhirUri? IFhirUri, out string ErrorMessage))
            {
                //Assert
                if (IFhirUri is object)
                {
                    if (fhirVersion == FhirVersion.Stu3)
                    {
                        Assert.Equal(resourceNameStu3, IFhirUri.ResourseName);
                    }
                    else
                    {
                        Assert.Equal(resourceNameR4, IFhirUri.ResourseName);
                    }
                    Assert.Equal(fhirVersion, IFhirUri.FhirVersion);
                    Assert.False(IFhirUri.IsContained);
                    Assert.Equal(resourceId.TrimStart('#'), IFhirUri.ResourceId);
                    Assert.True(IFhirUri.IsRelativeToServer);
                    Assert.Equal(new Uri(serversBase), IFhirUri.UriPrimaryServiceRoot);
                    Assert.False(IFhirUri.IsHistoryReferance);
                    Assert.Equal(string.Empty, IFhirUri.VersionId);
                    Assert.Null(IFhirUri.PrimaryServiceRootRemote);
                    Assert.Equal(new Uri(serversBase), IFhirUri.PrimaryServiceRootServers);
                    Assert.False(IFhirUri.IsCompartment);
                    Assert.False(IFhirUri.ErrorInParseing);
                    Assert.False(IFhirUri.IsMetaData);
                    Assert.False(IFhirUri.IsOperation);
                    Assert.False(IFhirUri.IsCompartment);
                    Assert.False(IFhirUri.IsUrn);
                    Assert.False(IFhirUri.IsFormDataSearch);
                    Assert.Equal(RequestUrl, IFhirUri.OriginalString);
                    Assert.Equal(string.Empty, IFhirUri.CompartmentalisedResourseName);

                    Assert.Equal(string.Empty, IFhirUri.OperationName);
                    Assert.Null(IFhirUri.OperationType);
                    Assert.Equal(string.Empty, IFhirUri.Query);
                    Assert.Equal(string.Empty, IFhirUri.Urn);
                    Assert.Null(IFhirUri.UrnType);
                    Assert.Equal(string.Empty, IFhirUri.ParseErrorMessage);
                }
                else
                {
                    Assert.Equal("some error message", ErrorMessage);
                }
            }
        }