public void TestLdapAnalyzerConditionIsAdded() 
 {
     MockDataSource1 dataSource = new MockDataSource1();
     NxObjectWriter pow = new NxObjectWriter();
     XmlDocument objectsXml = pow.Objects;
     XmlNode objectNode = objectsXml.SelectSingleNode("/PolicyObjects/Conditions/Object");
     Assert.AreEqual("LDAPAnalyzer", objectNode.Attributes["ref"].Value);
     Assert.AreEqual("Workshare.DirectorySearcher.dll", objectNode.Attributes["assembly"].Value);
     Assert.AreEqual("Workshare.DirectorySearcher.DirectoryAnalyzer", objectNode.Attributes["class"].Value);
 }
        public void TestDoesntAddDuplicateCondtion()
        {
            MockDataSource1 dataSource1 = new MockDataSource1();
            MockDataSource1 dataSource2 = new MockDataSource1();

            string parentId = "0D31D126-D23F-4e55-85D9-55504BE53160";

            NxObjectWriter pow = new NxObjectWriter();
            pow.AddCondition(dataSource1,parentId);
            pow.AddCondition(dataSource2, parentId);

            XmlDocument objectsXml = pow.Objects;

            string xpath = string.Format("/PolicyObjects/Conditions/Object[@ref='{0}']", parentId);
            XmlNode objectNode = objectsXml.SelectSingleNode(xpath);
            XmlNodeList nodes = objectsXml.SelectNodes("/PolicyObjects/Conditions/Object");

            // The NxBre writer adding the LDAPAnalyzer and InternalExternalResolver condition objects
            Assert.AreEqual(3, nodes.Count);

            Assert.AreEqual(parentId, objectNode.Attributes["ref"].Value);
            Assert.AreEqual("MockDataSourceAssembly1", objectNode.Attributes["assembly"].Value);
            Assert.AreEqual("MockClass1", objectNode.Attributes["class"].Value);
            Assert.AreEqual("purple", objectNode.Attributes["colour"].Value);
            Assert.AreEqual("true", objectNode.Attributes["allowoverride"].Value);
        }
        public void TestMultipleConditions()
        {
            MockDataSource1 dataSource1 = new MockDataSource1();
            MockDataSource2 dataSource2 = new MockDataSource2();
            
            string parentId1 = "0D31D126-D23F-4e55-85D9-55504BE53160";
            string parentId2 = "FB66A86F-38E8-49aa-9675-4A30E6EB7EF8";

            NxObjectWriter pow = new NxObjectWriter();
            pow.AddCondition(dataSource1, parentId1);
            pow.AddCondition(dataSource2, parentId2);

            XmlDocument objectsXml = pow.Objects;
            XmlNodeList nodes = objectsXml.SelectNodes("/PolicyObjects/Conditions/Object");

            // The NxBre writer adding the LDAPAnalyzer and InternalExternalResolver condition objects
            Assert.AreEqual(4, nodes.Count);

            Assert.AreEqual(parentId1, nodes[2].Attributes["ref"].Value);
            Assert.AreEqual("MockDataSourceAssembly1", nodes[2].Attributes["assembly"].Value);
            Assert.AreEqual("MockClass1", nodes[2].Attributes["class"].Value);
            Assert.AreEqual("purple", nodes[2].Attributes["colour"].Value);
            Assert.AreEqual("true", nodes[2].Attributes["allowoverride"].Value);
            Assert.AreEqual(parentId2, nodes[3].Attributes["ref"].Value);
            Assert.AreEqual("MockDataSourceAssembly2", nodes[3].Attributes["assembly"].Value);
            Assert.AreEqual("MockClass2", nodes[3].Attributes["class"].Value);
            Assert.AreEqual("green", nodes[3].Attributes["colour"].Value);
            Assert.AreEqual("false", nodes[3].Attributes["allowoverride"].Value);
        }
        public void TestCondtions()
        {
            MockDataSource1 dataSource = new MockDataSource1();
            NxObjectWriter pow = new NxObjectWriter();
            string parentId = "0D31D126-D23F-4e55-85D9-55504BE53160";
            pow.AddCondition(dataSource, parentId);

            XmlDocument objectsXml = pow.Objects;
            string xpath = string.Format("/PolicyObjects/Conditions/Object[@ref='{0}']", parentId);
            XmlNode objectNode = objectsXml.SelectSingleNode(xpath);
            Assert.AreEqual(parentId, objectNode.Attributes["ref"].Value);
            Assert.AreEqual("MockDataSourceAssembly1", objectNode.Attributes["assembly"].Value);
            Assert.AreEqual("MockClass1", objectNode.Attributes["class"].Value);
            Assert.AreEqual("purple", objectNode.Attributes["colour"].Value);
            Assert.AreEqual("true", objectNode.Attributes["allowoverride"].Value);
        }