public void Should_be_to_generate_xmlfilecontent_items_from_an_simple_object()
        {
            var fakeOvalObject = ProbeHelper.GetDefinitionObjectTypeByID("definitionsSimple", "2300");
            var mocks = new MockRepository();
            var fakeFileProvider = mocks.DynamicMock<IFileProvider>();
            var pathOperator = new PathOperatorEvaluator(fakeFileProvider, FamilyEnumeration.windows);
            Expect.Call(fakeFileProvider.FileExists(null)).IgnoreArguments().Return(true);
            mocks.ReplayAll();

            var itemsToCollect = new XmlFileContentItemTypeGenerator(pathOperator).GetItemsToCollect(fakeOvalObject, null).ToArray();

            DoBasicAssert(itemsToCollect, 1, typeof(xmlfilecontent_item));
            AssertXmlFileItem(itemsToCollect.Single(), @"c:\temp\definitions\bookstore.xml", @"//bookstore/book/title/text()");
        }
        public void Should_be_to_generate_xmlfilecontent_items_from_an_object_with_referenced_variable_on_filepath_entity()
        {
            MockRepository mocks = new MockRepository();
            var fakeFileProvider = mocks.DynamicMock<IFileProvider>();
            Expect.Call(fakeFileProvider.FileExists(null)).IgnoreArguments().Return(true);
            var pathOperator = new PathOperatorEvaluator(fakeFileProvider, FamilyEnumeration.windows);
            var itemTypeGenerator = new XmlFileContentItemTypeGenerator(pathOperator);
            var expectedFilepath = @"c:\temp\definitions\bookstore.xml";
            var fakeOvalObject = ProbeHelper.GetDefinitionObjectTypeByID("definitionsSimple", "2310");
            var fakeEvaluatedVariables = VariableHelper.CreateVariableWithOneValue(fakeOvalObject.id, "oval:modulo:var:2310", expectedFilepath);
            mocks.ReplayAll();

            var itemsToCollect = itemTypeGenerator.GetItemsToCollect(fakeOvalObject, fakeEvaluatedVariables);

            DoBasicAssert(itemsToCollect.ToArray(), 1, typeof(xmlfilecontent_item));
            AssertXmlFileItem(itemsToCollect.Single(), expectedFilepath, "//bookstore/book/price/text()");
        }
        public void Should_be_possible_to_create_xmlfilecontent_items_for_unix_platform()
        {
            var mocks = new MockRepository();
            var pathOperator = mocks.DynamicMock<PathOperatorEvaluator>(new object[] { null, FamilyEnumeration.unix });
            pathOperator.FileProvider = mocks.DynamicMock<IFileProvider>();
            Expect.Call(pathOperator.FileProvider.FileExists(null)).IgnoreArguments().Return(true);
            Expect.Call(pathOperator.ProcessOperationsPaths(null)).IgnoreArguments().Return(new[] { "/etc/webapps" });
            Expect.Call(pathOperator.ProcessOperationFileName(null, null, false)).IgnoreArguments().Return(new[] { "server.xml" });
            mocks.ReplayAll();
            var sampleObject = new LoadOvalDocument().GetFakeOvalDefinitions("definitions_all_unix.xml").objects.Single(obj => obj.id == "oval:modulo:obj:333");
            var itemtypeGenerator = new XmlFileContentItemTypeGenerator(null) { PathOperatorEvaluator = pathOperator };

            var itemsToCollect = itemtypeGenerator.GetItemsToCollect(sampleObject, null);

            var xmlFileContentItem = (xmlfilecontent_item)itemsToCollect.Single();
            Assert.AreEqual("/etc/webapps/server.xml", xmlFileContentItem.filepath.Value);

        }
Example #4
0
        protected override void ConfigureObjectCollector()
        {
            if (base.ObjectCollector == null)
            {
                var newXPathOperator = new XPathOperator()
                {
                    FileContentProvider = CustomFileProvider
                };
                var objCollector = new XmlFileContentObjectCollector()
                {
                    XPathOperator = newXPathOperator, Platform = this.Platform
                };

                base.ObjectCollector = objCollector;
            }

            if (base.ItemTypeGenerator == null)
            {
                var pathOperatorEvaluator = new PathOperatorEvaluator(CustomFileProvider, Platform);
                var itemTypeGenerator     = new XmlFileContentItemTypeGenerator(pathOperatorEvaluator);

                base.ItemTypeGenerator = itemTypeGenerator;
            }
        }