public void GetUserCodeTemplatesPaths_Should()
        {
            //Arange
            string currentPath    = AppDomain.CurrentDomain.BaseDirectory;
            string configFilePath = Path.Combine(currentPath, @"Configurations\TestData\config.xml");

            MockConfigFilePath(configFilePath);
            this.iOWrapper.FileExists(configFilePath).Returns(File.Exists(configFilePath));

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(configFilePath);
            this.iOWrapper.XmlDocumentLoad(configFilePath).Returns(xmlDocument);
            GlobalConfigurationTestProxy globalConfigurationTest = new GlobalConfigurationTestProxy(this.iOWrapper);

            //Act
            List <string> actualUserCodeTemlates = globalConfigurationTest.GetUserCodeTemplatesPaths();

            //Assert
            Assert.AreEqual(2, actualUserCodeTemlates.Count);
            foreach (var actualUserCodeTemlate in actualUserCodeTemlates)
            {
                XmlNode userCodeTemlate = xmlDocument.SelectSingleNode($"//userCodeTemplate[text()=\"{actualUserCodeTemlate}\"]");
                Assert.IsNotNull(userCodeTemlate);
            }
        }
 public void Ctor_ShouldThrowException()
 {
     //Assert
     Assert.Throws <ArgumentNullException>(() =>
     {
         GlobalConfigurationTestProxy globalConfigurationTest = new GlobalConfigurationTestProxy(null);
     });
 }
        public void Ctor_ShouldInitXmlDocument()
        {
            //Arange
            string configFilePath = @"UserDocuments\Aras Innovator Method Plugin\configFile.xml";

            MockConfigFilePath(configFilePath);
            this.iOWrapper.FileExists(configFilePath).Returns(false);

            //Act
            GlobalConfigurationTestProxy globalConfigurationTest = new GlobalConfigurationTestProxy(this.iOWrapper);

            //Assert
            Assert.AreEqual("<configuration><userCodeTemplates /></configuration>", globalConfigurationTest.ConfigXmlDocument.InnerXml);
        }
        public void Save_ShouldReceivedIOWrapperSave()
        {
            //Arange
            string configFilePath = @"UserDocuments\Aras Innovator Method Plugin\configFile.xml";

            this.iOWrapper.FileExists(configFilePath).Returns(false);
            MockConfigFilePath(configFilePath);

            GlobalConfigurationTestProxy globalConfigurationTest = new GlobalConfigurationTestProxy(this.iOWrapper);

            //Act
            globalConfigurationTest.Save();

            //Assert
            this.iOWrapper.Received().XmlDocumentSave(Arg.Is <XmlDocument>(x => x.InnerXml == "<configuration><userCodeTemplates /></configuration>"), configFilePath);
        }
        public void Ctor_ShouldLoadExistedXmlDocument()
        {
            //Arange
            string currentPath    = AppDomain.CurrentDomain.BaseDirectory;
            string configFilePath = Path.Combine(currentPath, @"Configurations\TestData\config.xml");

            MockConfigFilePath(configFilePath);
            this.iOWrapper.FileExists(configFilePath).Returns(File.Exists(configFilePath));

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(configFilePath);
            this.iOWrapper.XmlDocumentLoad(configFilePath).Returns(xmlDocument);

            //Act
            GlobalConfigurationTestProxy globalConfigurationTest = new GlobalConfigurationTestProxy(this.iOWrapper);

            //Assert
            Assert.AreEqual(xmlDocument.InnerXml, globalConfigurationTest.ConfigXmlDocument.InnerXml);
        }
        public void RemoveUserCodeTemplatePath_Should()
        {
            //Arange
            string currentPath    = AppDomain.CurrentDomain.BaseDirectory;
            string configFilePath = Path.Combine(currentPath, @"Configurations\TestData\config.xml");

            MockConfigFilePath(configFilePath);
            this.iOWrapper.FileExists(configFilePath).Returns(File.Exists(configFilePath));

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(configFilePath);
            this.iOWrapper.XmlDocumentLoad(configFilePath).Returns(xmlDocument);

            GlobalConfigurationTestProxy globalConfigurationTest = new GlobalConfigurationTestProxy(this.iOWrapper);

            //Act
            globalConfigurationTest.RemoveUserCodeTemplatePath("testUserCodeTemplatePath2");

            //Assert
            Assert.AreEqual(1, globalConfigurationTest.ConfigXmlDocument.SelectNodes("//userCodeTemplate").Count);
        }
        public void AddUserCodeTemplatePath_Should()
        {
            //Arange
            string currentPath    = AppDomain.CurrentDomain.BaseDirectory;
            string configFilePath = Path.Combine(currentPath, @"Configurations\TestData\config.xml");

            MockConfigFilePath(configFilePath);
            this.iOWrapper.FileExists(configFilePath).Returns(File.Exists(configFilePath));

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(configFilePath);
            this.iOWrapper.XmlDocumentLoad(configFilePath).Returns(xmlDocument);

            GlobalConfigurationTestProxy globalConfigurationTest = new GlobalConfigurationTestProxy(this.iOWrapper);

            //Act
            globalConfigurationTest.AddUserCodeTemplatePath("testUserCodeTemplatePath3");

            //Assert
            Assert.NotNull(globalConfigurationTest.ConfigXmlDocument.SelectSingleNode("//userCodeTemplate[text()=\"testUserCodeTemplatePath3\"]"));
        }