public void Serilazed_Details_Object_With_ObjectTreeNode_Exists()
        {
            // arrange
            var scenario = new Scenario { Name = ScenarioName, Description = "a scenario for testing trees in details", Status = "failed" };

            // A tree containing most important item types that need to be supported
            // (same types are allowed for items in tree nodes as for values in Details --> reuse code from
            // SerializableDictionary!).

            // Root node with string as item
            var rootNode = new ObjectTreeNode<object> { Item = "Root" };
            rootNode.AddDetail(
                "detailKey",
                "Tree nodes can have again details, use same serialization as already tested!");

            // node one with object description as item
            var childWithObject = new ObjectTreeNode<object>();
            var objDescription = new ObjectDescription("serviceCall", "AddressWebService.getAdress");
            objDescription.AddDetail("justADetail", "just an example");
            childWithObject.Item = objDescription;
            rootNode.AddChild(childWithObject);

            // node two with object reference as item
            var childWithObjectRef = new ObjectTreeNode<object>();
            var objRef = new ObjectReference("serviceCall", "AddressWebService.getAdress");
            childWithObjectRef.Item = objRef;
            rootNode.AddChild(childWithObjectRef);

            // node three with List of Strings as item
            var childWithList = new ObjectTreeNode<IObjectTreeNode<object>>();
            var list = new ObjectList<object> { "item1", "item2", "item3" };
            childWithList.Item = list;
            rootNode.AddChild(childWithList);

            // node four with details as item
            var childWithDetails = new ObjectTreeNode<object>();
            var detailsMap = new Details();
            detailsMap.AddDetail("key1", "value1");
            detailsMap.AddDetail("key2", "value2");
            detailsMap.AddDetail("anyGenericObjectReference", new ObjectReference("serviceCall", "MainDB.getUsers"));
            detailsMap.AddDetail(
                "anyGenericObject",
                new ObjectDescription("configuration", "my_dummy_mocks_configuration.properties"));
            childWithDetails.Item = detailsMap;
            rootNode.AddChild(childWithDetails);

            scenario.AddDetail("exampleTree", rootNode);

            // act
            writer.SaveScenario(SerializationUseCase, scenario);
            writer.Flush();

            // assert
            Assert.IsTrue(File.Exists(docuFiles.GetScenarioFile(BranchName, BuildName, SerializationUseCase, ScenarioName)));

            scenario.Status = "success";
            writer.SaveScenario(SerializationUseCase, scenario);
        }
Ejemplo n.º 2
0
        public void Serilazed_Details_Object_With_ObjectTreeNode_Exists()
        {
            // arrange
            var scenario = new Scenario {
                Name = ScenarioName, Description = "a scenario for testing trees in details", Status = "failed"
            };

            // A tree containing most important item types that need to be supported
            // (same types are allowed for items in tree nodes as for values in Details --> reuse code from
            // SerializableDictionary!).

            // Root node with string as item
            var rootNode = new ObjectTreeNode <object> {
                Item = "Root"
            };

            rootNode.AddDetail(
                "detailKey",
                "Tree nodes can have again details, use same serialization as already tested!");

            // node one with object description as item
            var childWithObject = new ObjectTreeNode <object>();
            var objDescription  = new ObjectDescription("serviceCall", "AddressWebService.getAdress");

            objDescription.AddDetail("justADetail", "just an example");
            childWithObject.Item = objDescription;
            rootNode.AddChild(childWithObject);

            // node two with object reference as item
            var childWithObjectRef = new ObjectTreeNode <object>();
            var objRef             = new ObjectReference("serviceCall", "AddressWebService.getAdress");

            childWithObjectRef.Item = objRef;
            rootNode.AddChild(childWithObjectRef);

            // node three with List of Strings as item
            var childWithList = new ObjectTreeNode <IObjectTreeNode <object> >();
            var list          = new ObjectList <object> {
                "item1", "item2", "item3"
            };

            childWithList.Item = list;
            rootNode.AddChild(childWithList);

            // node four with details as item
            var childWithDetails = new ObjectTreeNode <object>();
            var detailsMap       = new Details();

            detailsMap.AddDetail("key1", "value1");
            detailsMap.AddDetail("key2", "value2");
            detailsMap.AddDetail("anyGenericObjectReference", new ObjectReference("serviceCall", "MainDB.getUsers"));
            detailsMap.AddDetail(
                "anyGenericObject",
                new ObjectDescription("configuration", "my_dummy_mocks_configuration.properties"));
            childWithDetails.Item = detailsMap;
            rootNode.AddChild(childWithDetails);

            scenario.AddDetail("exampleTree", rootNode);

            // act
            writer.SaveScenario(SerializationUseCase, scenario);
            writer.Flush();

            // assert
            Assert.IsTrue(File.Exists(docuFiles.GetScenarioFile(BranchName, BuildName, SerializationUseCase, ScenarioName)));

            scenario.Status = "success";
            writer.SaveScenario(SerializationUseCase, scenario);
        }