예제 #1
0
 public void _02_InsertDocumentWithSameIdTest()
 {
     try
     {
         Print.Started("_02_InsertDocumentWithSameIdTest");
         string rootNameA     = "TestA";
         string rootNameB     = "TestB";
         string rootNamespace = "http://oio.dk/test";
         XPathDiscriminatorConfig           identifierDiscriminatorA = new XPathDiscriminatorConfig("//Test/Key", "A");
         XPathDiscriminatorConfig           identifierDiscriminatorB = new XPathDiscriminatorConfig("//Test/Key", "B");
         XpathDiscriminatorConfigCollection identifierDiscriminators = new XpathDiscriminatorConfigCollection();
         identifierDiscriminators.Add(identifierDiscriminatorA);
         identifierDiscriminators.Add(identifierDiscriminatorB);
         DocumentTypeConfig           documentTypeA          = new DocumentTypeConfig(rootNameA, rootNamespace, identifierDiscriminators);
         DocumentTypeConfig           documentTypeB          = new DocumentTypeConfig(rootNameB, rootNamespace, identifierDiscriminators);
         DocumentTypeCollectionConfig documentTypeCollection = new DocumentTypeCollectionConfig();
         documentTypeCollection.AddDocumentType(documentTypeA);
         documentTypeB.Id = documentTypeA.Id;
         Assert.Throws <DocumentAllreadyAddedException>(() => documentTypeCollection.AddDocumentType(documentTypeB));
     }
     finally
     {
         Print.Completed("_02_InsertDocumentWithSameIdTest");
     }
 }
예제 #2
0
 public void _04_GetNonExistingDocumentTypeFromIdTest()
 {
     try
     {
         Print.Started("_04_GetNonExistingDocumentTypeFromIdTest");
         string rootName      = "Test";
         string rootNamespace = "http://oio.dk/test";
         XPathDiscriminatorConfig           identifierDiscriminatorA = new XPathDiscriminatorConfig("//Test/Key", "A");
         XPathDiscriminatorConfig           identifierDiscriminatorB = new XPathDiscriminatorConfig("//Test/Key", "B");
         XpathDiscriminatorConfigCollection identifierDiscriminators = new XpathDiscriminatorConfigCollection();
         identifierDiscriminators.Add(identifierDiscriminatorA);
         identifierDiscriminators.Add(identifierDiscriminatorB);
         DocumentTypeConfig           documentType           = new DocumentTypeConfig(rootName, rootNamespace, identifierDiscriminators);
         DocumentTypeCollectionConfig documentTypeCollection = new DocumentTypeCollectionConfig();
         documentTypeCollection.AddDocumentType(documentType);
         DocumentTypeConfig documentTypeFromCollection = null;
         bool any = documentTypeCollection.TryGetDocumentType(Guid.NewGuid(), out documentTypeFromCollection);
         Assert.IsFalse(any);
         Assert.IsNull(documentTypeFromCollection);
     }
     finally
     {
         Print.Completed("_04_GetNonExistingDocumentTypeFromIdTest");
     }
 }
예제 #3
0
 public void _01_AddRemoveDocumentTypeTest()
 {
     try
     {
         Print.Started("_01_AddRemoveDocumentTypeTest");
         string rootName      = "Test";
         string rootNamespace = "http://oio.dk/test";
         XPathDiscriminatorConfig           identifierDiscriminatorA = new XPathDiscriminatorConfig("//Test/Key", "A");
         XPathDiscriminatorConfig           identifierDiscriminatorB = new XPathDiscriminatorConfig("//Test/Key", "B");
         XpathDiscriminatorConfigCollection identifierDiscriminators = new XpathDiscriminatorConfigCollection();
         identifierDiscriminators.Add(identifierDiscriminatorA);
         identifierDiscriminators.Add(identifierDiscriminatorB);
         DocumentTypeConfig           documentType           = new DocumentTypeConfig(rootName, rootNamespace, identifierDiscriminators);
         DocumentTypeCollectionConfig documentTypeCollection = new DocumentTypeCollectionConfig();
         documentTypeCollection.AddDocumentType(documentType);
         DocumentTypeConfig documentTypeFromCollection = documentTypeCollection.GetDocumentType(rootName, rootNamespace, identifierDiscriminators);
         Assert.IsTrue(documentTypeFromCollection.Equals(documentType));
         documentTypeCollection.RemoveDocumentType(documentTypeFromCollection);
         documentTypeFromCollection = null;
         bool anyDocument = documentTypeCollection.TryGetDocumentType(rootName, rootNamespace, identifierDiscriminators, out documentTypeFromCollection);
         Assert.IsFalse(anyDocument);
     }
     catch (Exception)
     {
         // easy debug
     }
     finally
     {
         Print.Completed("_01_AddRemoveDocumentTypeTest");
     }
 }
예제 #4
0
        private void AddNoNamespaceTestDocumentType()
        {
            Console.WriteLine("ConfigurationHandler.Version=" + ConfigurationHandler.Version);
            Console.WriteLine("ConfigurationHandler.ConfigFilePath=" + ConfigurationHandler.ConfigFilePath);
            DocumentTypeCollectionConfig configuration = ConfigurationHandler.GetConfigurationSection <DocumentTypeCollectionConfig>();
            DocumentTypeConfig           documentType  = new DocumentTypeConfig();

            documentType.FriendlyName  = friendlyName;
            documentType.RootName      = "NoNamespace";
            documentType.RootNamespace = "";
            configuration.AddDocumentType(documentType);
        }
예제 #5
0
        public void Setup()
        {
            var configFile = Settings.CreateRandomPath("RaspConfig.xml");

            Directory.CreateDirectory(configFile.Directory.FullName);

            ConfigurationHandler.ConfigFilePath = configFile.FullName;
            ConfigurationHandler.Reset();

            ConfigurationHandler.RegisterConfigurationSection <DocumentTypeCollectionConfig>();
            ConfigurationHandler.RegisterConfigurationSection <OcesX509CertificateConfig>();
            ConfigurationHandler.PreloadRegisteredConfigurationSections();

            DocumentTypeCollectionConfig documentTypeCollectionConfig = ConfigurationHandler.GetConfigurationSection <DocumentTypeCollectionConfig>();

            documentTypeCollectionConfig.AddDocumentType(new DefaultDocumentTypes().GetOioUblInvoice());
            new DefaultOcesCertificate().SetIfNotExistsOcesCertificateConfig();

            ConfigurationHandler.SaveToFile();
        }
예제 #6
0
 public void _07_GetNonExistingDocumentTypeFromParameters()
 {
     try
     {
         Print.Started("_07_GetNonExistingDocumentTypeFromParameters");
         string rootName      = "TestA";
         string rootNamespace = "http://oio.dk/test";
         XPathDiscriminatorConfig           identifierDiscriminatorA = new XPathDiscriminatorConfig("//Test/Key", "A");
         XPathDiscriminatorConfig           identifierDiscriminatorB = new XPathDiscriminatorConfig("//Test/Key", "B");
         XpathDiscriminatorConfigCollection identifierDiscriminators = new XpathDiscriminatorConfigCollection();
         identifierDiscriminators.Add(identifierDiscriminatorA);
         identifierDiscriminators.Add(identifierDiscriminatorB);
         DocumentTypeConfig           documentType           = new DocumentTypeConfig(rootName, rootNamespace, identifierDiscriminators);
         DocumentTypeCollectionConfig documentTypeCollection = new DocumentTypeCollectionConfig();
         documentTypeCollection.AddDocumentType(documentType);
         Assert.Throws <NoDocumentTypeFoundFromParametersException>(() => documentTypeCollection.GetDocumentType("TestB", rootNamespace, identifierDiscriminators));
     }
     finally
     {
         Print.Completed("_07_GetNonExistingDocumentTypeFromParameters");
     }
 }
예제 #7
0
        public void ConfigurationFileCanBeCreatedByRegisteringConfigurationSectionsUpFront()
        {
            var configFile = Settings.CreateRandomPath("RaspConfig.xml");

            Directory.CreateDirectory(configFile.Directory.FullName);

            ConfigurationHandler.ConfigFilePath = configFile.FullName;
            ConfigurationHandler.Reset();

            ConfigurationHandler.RegisterConfigurationSection <DocumentTypeCollectionConfig>();
            ConfigurationHandler.RegisterConfigurationSection <ProfileMappingCollectionConfig>();
            ConfigurationHandler.PreloadRegisteredConfigurationSections();

            DocumentTypeCollectionConfig documentTypeCollectionConfig = ConfigurationHandler.GetConfigurationSection <DocumentTypeCollectionConfig>();

            documentTypeCollectionConfig.AddDocumentType(new DefaultDocumentTypes().GetOioUblCatalogue());

            ConfigurationHandler.SaveToFile();

            var rootNode = GetRaspConfigurationNode(configFile);

            AssertNodeHasConfigurationSectionWithName(rootNode, "DocumentTypeCollectionConfig");
        }