public void Write_Steps_With_Screen_Annotations()
        {
            // arrange
            var usecase = new UseCase
            {
                Name = "Screen Annotations",
                Description = "Usecase to show the screen annotations",
                Status = "failed",
            };

            writer.SaveUseCase(usecase);

            var scenario = new Scenario
            {
                Name = "All screen annotations on one page",
                Description = "this is a typical scenario with a decription",
                Status = "failed",
            };

            writer.SaveScenario(usecase.Name, scenario);
            writer.Flush();

            // act
            var step = new Step();
            var stepDescription = new StepDescription { Index = StepIndex, Title = "Test Step", Status = "success" };
            step.StepDescription = stepDescription;

            step.StepHtml = new StepHtml { HtmlSource = "<html>just some page text</html>" };
            step.Page = new Page { Name = "Sample Screen Annotation Page" };
            step.StepDescription.ScreenshotFileName = "000.png";
            step.StepDescription.Index = 0;

            step.ScreenAnnotations.Add(DataGenerator.CreateScreenAnnotation(10, 50, ScreenAnnotationStyle.Highlight));
            step.ScreenAnnotations.Add(DataGenerator.CreateScreenAnnotation(10, 150, ScreenAnnotationStyle.Click, ScreenAnnotationClickAction.ToUrl, "next-url"));
            step.ScreenAnnotations.Add(DataGenerator.CreateScreenAnnotation(10, 250, ScreenAnnotationStyle.Error));
            step.ScreenAnnotations.Add(DataGenerator.CreateScreenAnnotation(10, 350, ScreenAnnotationStyle.Expected));
            step.ScreenAnnotations.Add(DataGenerator.CreateScreenAnnotation(10, 450, ScreenAnnotationStyle.Info));
            step.ScreenAnnotations.Add(DataGenerator.CreateScreenAnnotation(400, 50, ScreenAnnotationStyle.Keyboard));
            step.ScreenAnnotations.Add(DataGenerator.CreateScreenAnnotation(400, 150, ScreenAnnotationStyle.Warn));
            step.ScreenAnnotations.Add(DataGenerator.CreateScreenAnnotation(400, 250, ScreenAnnotationStyle.Default));
            step.ScreenAnnotations.Add(DataGenerator.CreateScreenAnnotation(400, 350, ScreenAnnotationStyle.NavigateToUrl, ScreenAnnotationClickAction.ToUrl, "blabla"));

            var details = new Details();
            details.AddDetail("details-key", "details-value");
            step.ScreenAnnotations.Last().Details = details;

            writer.SaveStep(usecase.Name, scenario.Name, step);
            writer.Flush();

            writer.SaveScreenshot(usecase.Name, scenario.Name, step, File.ReadAllBytes("data/screenshot.png"));
            writer.Flush();

            usecase.Status = "success";
            scenario.Status = "success";

            writer.SaveUseCase(usecase);
            writer.SaveScenario(usecase.Name, scenario);

            var stepAsString = File.ReadAllText(docuFiles.GetScenarioStepFile(BranchName, BuildName, usecase.Name, scenario.Name, 0));

            // well this is a really sloppy assertion. BUT: we don't have to test the whole serialization because this is done by .NET framework.
            // we have to do some little things that the java deserializer likes our xml. So we do just some checks on "problem zones". the whole
            // import should still be checked with an api call on the scenarioo backend.
            StringAssert.Contains("<style>HIGHLIGHT</style>", stepAsString);
            StringAssert.Contains("<style>CLICK</style>", stepAsString);
            StringAssert.Contains("<style>ERROR</style>", stepAsString);
            StringAssert.Contains("<style>INFO</style>", stepAsString);
            StringAssert.Contains("<style>EXPECTED</style>", stepAsString);
        }
        public void Serialize_Scenario_Name_Description_And_Status()
        {
            // arrange
            var scenario = new Scenario
                               {
                                   Name = TestContext.CurrentContext.Test.Name,
                                   Description = "Serialize a scenario name, description and status",
                                   Status = "success",
                               };

            // act
            scenario.AddDetail("userRole", "customer");
            writer.SaveScenario(SerializationUseCase, scenario);
            writer.Flush();

            // assert
            var scenarioXml = File.ReadAllText(docuFiles.GetScenarioFile(BranchName, BuildName, SerializationUseCase, TestContext.CurrentContext.Test.Name));

            StringAssert.Contains(string.Format("<name>{0}</name>", scenario.Name), scenarioXml);
            StringAssert.Contains(string.Format("<description>{0}</description>", scenario.Description), scenarioXml);
            StringAssert.Contains("<status>success</status>", scenarioXml);
        }
        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);
        }
        public void Serialized_Details_Object_With_ObjectList_Exists()
        {
            // arrange
            var scenario = new Scenario
                               {
                                   Name = TestContext.CurrentContext.Test.Name,
                                   Description = "a scenario for testing collectionps in details"
                               };

            // act
            var detailsMap = new Details();
            detailsMap.AddDetail("anyGenericObjectReference", new ObjectReference("serviceCall", "MainDB.getUsers"));
            detailsMap.AddDetail(
                "anyGenericObject",
                new ObjectDescription("configuration", "my_dummy_mocks_configuration.properties"));
            detailsMap.AddDetail("key1", "value1");
            detailsMap.AddDetail("key2", "value2");

            scenario.AddDetail("map", detailsMap);

            var objList = new ObjectList<string> { "item1", "item2", "item3" };
            scenario.Details.AddDetail("list", objList);
            writer.SaveScenario(SerializationUseCase, scenario);
            writer.Flush();

            // assert (there is no way to deserialize the details atm :()
            Assert.IsTrue(File.Exists(docuFiles.GetScenarioFile(BranchName, BuildName, SerializationUseCase, TestContext.CurrentContext.Test.Name)));

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