Example #1
0
        private async Task StoreMetadataAsync(ReportableObject obj, IMongoCollection <EntityDefinition> entityDefinitions, IMongoCollection <ReportableObject> objects)
        {
            List <Task> tasks = new List <Task>();
            var         entityDefinitionMatches = await entityDefinitions.FindAsync(x => x.EntityType == obj.Type);

            var ed = entityDefinitionMatches.FirstOrDefault();

            if (ed == null)
            {
                ed = new EntityDefinition
                {
                    EntityType = obj.Type,
                    Links      = new List <LinkDescription>(),
                    Properties = new HashSet <string>()
                }
            }
            ;
            if (ed.Links == null)
            {
                ed.Links = new List <LinkDescription>();
            }
            if (ed.Properties == null)
            {
                ed.Properties = new HashSet <string>();
            }
            if (ed.ReferencedBy == null)
            {
                ed.ReferencedBy = new List <LinkDescription>();
            }


            foreach (var prop in obj.Properties ?? new List <Property>())
            {
                ed.Properties.Add(prop.Name);
            }
            foreach (var link in obj.Links ?? new List <Link>())
            {
                var existingLink = ed.Links.FirstOrDefault(x => x.Description == link.LinkDescription.Description);
                if (existingLink == null)
                {
                    ed.Links.Add(link.LinkDescription);
                }
                else
                {
                    existingLink.TargetEntityTypes = existingLink.TargetEntityTypes.Union(link.LinkDescription.TargetEntityTypes).ToArray();
                }
            }
            foreach (var referencingObject in obj.ReferencedFrom)
            {
                ed.ReferencedBy.RemoveAll(x => x.Description == referencingObject.LinkDescription.Description);
                ed.ReferencedBy.Add(referencingObject.LinkDescription);
            }
            var updateTask = entityDefinitions.FindOneAndReplaceAsync <EntityDefinition>(x => x.EntityType == ed.EntityType, ed, new FindOneAndReplaceOptions <EntityDefinition, EntityDefinition> {
                IsUpsert = true
            });

            tasks.Add(updateTask);

            Task.WaitAll(tasks.ToArray());
        }
 protected override void PopulateProperties(ExecutionLog from, ReportableObject to)
 {
     #region Basic Details
     to.ID = from.Surrogate.ToString();
     #endregion
     List <Property> properties = new List <Property>();
     properties.Add(new Property {
         Name = nameof(from.DisplayedName), Value = from.DisplayedName
     });
     properties.Add(new Property {
         Name = nameof(from.NodePath), Value = from.NodePath
     });
     properties.Add(new Property {
         Name = nameof(from.NumberOfTestCases), Value = from.NumberOfTestCases
     });
     properties.Add(new Property {
         Name = nameof(from.NumberOfTestCasesFailed), Value = from.NumberOfTestCasesFailed
     });
     properties.Add(new Property {
         Name = nameof(from.NumberOfTestCasesNotExecuted), Value = from.NumberOfTestCasesNotExecuted
     });
     properties.Add(new Property {
         Name = nameof(from.NumberOfTestCasesPassed), Value = from.NumberOfTestCasesPassed
     });
     properties.Add(new Property {
         Name = nameof(from.NumberOfTestCasesWithUnknownState), Value = from.NumberOfTestCasesWithUnknownState
     });
     foreach (var prop in from.Properties.ToArray())
     {
         properties.Add(new Property {
             Name = prop.Name, Value = prop.Value
         });
     }
     to.Properties = properties;
 }
Example #3
0
        protected override void PopulateLinks(TestCase from, ReportableObject to)
        {
            List <Link> links            = new List <Link>();
            var         referencedBy     = from.ReferencedBy.ToArray();
            var         executionEntries = from.ExecutionEntries.ToArray();
            var         executionLogs    = from.ExecutionLogs.ToArray();
            var         steps            = from.GetAllTestSteps().ToArray();
            var         xSteps           = from.SearchByTQL("=>SUBPARTS:XTestStep").ToArray();

            if (steps.Length > 0 || xSteps.Length > 0)
            {
                links.Add(new Link {
                    LinkDescription = new LinkDescription {
                        Description = "Test Steps", SourceEntity = to.Type, TargetEntityTypes = new string[] { "Test Step" }
                    }, LinkedObjects = steps.Select(x => x.Surrogate.ToString()).ToArray().Union(xSteps.Select(x => x.Surrogate.ToString())).ToArray()
                });
            }
            if (executionEntries.Length > 0)
            {
                links.Add(new Link {
                    LinkDescription = new LinkDescription {
                        Description = "Execution Entries", SourceEntity = to.Type, TargetEntityTypes = new string[] { "Execution Entry" }
                    }, LinkedObjects = executionEntries.Select(x => x.Surrogate.ToString()).ToArray()
                });
            }
            if (executionLogs.Length > 0)
            {
                links.Add(new Link {
                    LinkDescription = new LinkDescription {
                        Description = "Execution Logs", SourceEntity = to.Type, TargetEntityTypes = new string[] { "Execution Test Case Log" }
                    }, LinkedObjects = executionLogs.Select(x => x.Surrogate.ToString()).ToArray()
                });
            }
            to.Links = links;
        }
Example #4
0
        public override ReportableObject Convert(PersistableObject toscaObject)
        {
            ReportableObject obj = base.Convert(toscaObject);

            obj.Type = "Requirement";
            return(obj);
        }
Example #5
0
        public override ReportableObject Convert(PersistableObject toscaObject)
        {
            ReportableObject obj = new ReportableObject();

            obj.Type = "Test Step";
            return(obj);
        }
Example #6
0
        private async Task StoreObjectInDatabase(pe.PersistableObject obj, IMongoDatabase db, Snapshot currentSnapshot)
        {
            var thisAssembly      = System.Reflection.Assembly.GetExecutingAssembly();
            var converterAssembly = System.Reflection.Assembly.GetAssembly(typeof(IConverter));
            var converterTypes    = thisAssembly.GetTypes().Where(x => x.CustomAttributes.Any(attr => attr.AttributeType == typeof(ConvertedTypeAttribute)) &&
                                                                  typeof(IConverter).IsAssignableFrom(x)).ToList();

            converterTypes.AddRange(converterAssembly.GetTypes().Where(x => x.CustomAttributes.Any(attr => attr.AttributeType == typeof(ConvertedTypeAttribute)) &&
                                                                       typeof(IConverter).IsAssignableFrom(x)));
            ReportableObject  ro         = null;
            List <IConverter> converters = new List <IConverter>();

            foreach (var converterType in converterTypes)
            {
                string converterTypeName = converterType.GetCustomAttribute <ConvertedTypeAttribute>().ConvertedType.Name;
                if (converterTypeName == obj.GetType().Name)
                {
                    var converter = (IConverter)Activator.CreateInstance(converterType);
                    ro = converter.Convert(obj);
                    break;
                }
            }
            if (ro == null)
            {
                return;
            }

            var objectCollection = db.GetCollection <ReportableObject>("reportable_object");
            var objectHistory    = db.GetCollection <ObjectHistory>("object_history");

            await InsertObject(ro, objectCollection, objectHistory, currentSnapshot);
            await LinkObject(ro, objectCollection);
        }
        protected override void PopulateLinks(ExecutionTestStepValueLog from, ReportableObject to)
        {
            //issues
            List <Link> links = new List <Link>();

            to.Links = links;
        }
Example #8
0
 protected override void PopulateProperties(XTestStepValue from, ReportableObject to)
 {
     #region Basic Details
     to.ID = from.Surrogate.ToString();
     #endregion
     List <Property> properties = new List <Property>();
     properties.Add(new Property {
         Name = nameof(from.DisplayedName), Value = from.DisplayedName
     });
     properties.Add(new Property {
         Name = nameof(from.NodePath), Value = from.NodePath
     });
     properties.Add(new Property {
         Name = nameof(from.Invalidated), Value = from.Invalidated
     });
     properties.Add(new Property {
         Name = nameof(from.Value), Value = from.Value
     });
     properties.Add(new Property {
         Name = nameof(from.ActionProperty), Value = from.ActionProperty
     });
     properties.Add(new Property {
         Name = nameof(from.Name), Value = from.Name
     });
     foreach (var prop in from.GetAllPropertyNames().ToArray())
     {
         properties.Add(new Property {
             Name = prop, Value = from.GetPropertyValue(prop)
         });
     }
     to.Properties = properties;
 }
Example #9
0
        private async Task LinkObject(ReportableObject objectToLink, IMongoCollection <ReportableObject> objects)
        {
            foreach (var link in objectToLink.Links)
            {
                if (link == null || link.LinkedObjects == null || link.LinkedObjects.Length == 0)
                {
                    continue;
                }
                foreach (var linkedObject in link.LinkedObjects)
                {
                    var matchingObjectCursor = await objects.FindAsync <ReportableObject>(r => r.ID == linkedObject);

                    var matchedObjects = matchingObjectCursor.ToList();
                    if (matchedObjects.Count == 0)
                    {
                        continue;
                    }
                    var match = matchedObjects.First();
                    if (match.ReferencedFrom == null)
                    {
                        match.ReferencedFrom = new List <ReferencingObject>();
                    }
                    match.ReferencedFrom.RemoveAll(x => x.ReferringObject.ID == objectToLink.ID);
                    match.ReferencedFrom.Add(new ReferencingObject {
                        LinkDescription = link.LinkDescription, ReferringObject = objectToLink
                    });
                    await objects.FindOneAndReplaceAsync <ReportableObject>(r => r.ID == match.ID, match);
                }
            }
        }
        public override ReportableObject Convert(PersistableObject toscaObject)
        {
            ReportableObject obj = base.Convert(toscaObject);

            obj.Type = "Execution Log";
            return(obj);
        }
Example #11
0
        public override ReportableObject Convert(PersistableObject toscaObject)
        {
            ReportableObject obj = base.Convert(toscaObject);

            obj.Type = "Test Step Value";
            return(obj);
        }
        protected override void PopulateProperties(XModuleAttribute from, ReportableObject to)
        {
            #region Basic Details
            to.ID = from.Surrogate.ToString();
            #endregion
            List <Property> properties = new List <Property>();
            properties.Add(new Property {
                Name = nameof(from.DisplayedName), Value = from.DisplayedName
            });
            properties.Add(new Property {
                Name = nameof(from.NodePath), Value = from.NodePath
            });

            foreach (var prop in from.GetAllPropertyNames().ToArray())
            {
                properties.Add(new Property {
                    Name = prop, Value = from.GetPropertyValue(prop)
                });
            }
            foreach (var param in from.XParams)
            {
                properties.Add(new Property {
                    Name = param.Name, Value = param.Value
                });
            }
            to.Properties = properties;
        }
        public override ReportableObject Convert(PersistableObject toscaObject)
        {
            ReportableObject obj = base.Convert(toscaObject);

            obj.Type = "Module Attribute";
            return(obj);
        }
        protected override void PopulateLinks(ExecutionList from, ReportableObject to)
        {
            List <Link> links   = new List <Link>();
            var         entries = from.AllExecutionEntries.ToArray();
            var         logs    = from.ExecutionLogs.ToArray();

            if (entries.Length > 0)
            {
                links.Add(new Link {
                    LinkDescription = new LinkDescription {
                        Description = "Entries", SourceEntity = to.Type, TargetEntityTypes = new string[] { "Execution Entry" }
                    },
                    LinkedObjects = entries.Select(x => x.Surrogate.ToString()).ToArray()
                });
            }
            if (logs.Length > 0)
            {
                links.Add(new Link {
                    LinkDescription = new LinkDescription {
                        Description = "Execution Logs", SourceEntity = to.Type, TargetEntityTypes = new string[] { "Execution Log" }
                    }, LinkedObjects = logs.Select(x => x.Surrogate.ToString()).ToArray()
                });
            }
            to.Links = links;
        }
Example #15
0
 protected override void PopulateProperties(Requirement from, ReportableObject to)
 {
     #region Basic Details
     to.ID = from.Surrogate.ToString();
     #endregion
     List <Property> properties = new List <Property>();
     properties.Add(new Property {
         Name = nameof(from.DisplayedName), Value = from.DisplayedName
     });
     properties.Add(new Property {
         Name = nameof(from.NodePath), Value = from.NodePath
     });
     properties.Add(new Property {
         Name = nameof(from.DamageClass), Value = from.DamageClass
     });
     properties.Add(new Property {
         Name = nameof(from.FrequencyClass), Value = from.FrequencyClass
     });
     properties.Add(new Property {
         Name = nameof(from.CoverageExecuted), Value = from.CoverageExecuted
     });
     foreach (var prop in from.GetAllPropertyNames().ToArray())
     {
         properties.Add(new Property {
             Name = prop, Value = from.GetPropertyValue(prop)
         });
     }
     to.Properties = properties;
 }
Example #16
0
        protected byte[] GetHash(ReportableObject obj)
        {
            string objectText = Newtonsoft.Json.JsonConvert.SerializeObject(obj);

            byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(objectText);
            MD5    md5        = System.Security.Cryptography.MD5.Create();

            byte[] hash = md5.ComputeHash(inputBytes);
            return(hash);
        }
        protected override void PopulateLinks(XModuleAttribute from, ReportableObject to)
        {
            List <Link> links = new List <Link>();

            //var attributes = from.SearchByTQL("=>SUBPARTS:XModuleAttribute").Cast<XModuleAttribute>().ToArray();

            //if (attributes.Length > 0)
            //    links.Add(new Link { LinkDescription = "Module Attributes", LinkedObjects = attributes.Select(x => x.Surrogate.ToString()).ToArray() });
            to.Links = links;
        }
Example #18
0
        public virtual ReportableObject Convert(PersistableObject toscaObject)
        {
            T item = (T)toscaObject;
            ReportableObject obj = new ReportableObject();

            obj.Type = typeof(T).Name;
            PopulateLinks(item, obj);
            PopulateProperties(item, obj);
            obj.Hash = GetHash(obj);
            return(obj);
        }
 protected override void PopulateProperties(ExecutionTestStepValueLog from, ReportableObject to)
 {
     #region Basic Details
     to.ID = from.Surrogate.ToString();
     #endregion
     List <Property> properties = new List <Property>();
     properties.Add(new Property {
         Name = nameof(from.DisplayedName), Value = from.DisplayedName
     });
     properties.Add(new Property {
         Name = nameof(from.NodePath), Value = from.NodePath
     });
     properties.Add(new Property {
         Name = nameof(from.Detail), Value = from.Detail
     });
     properties.Add(new Property {
         Name = nameof(from.Duration), Value = from.Duration
     });
     properties.Add(new Property {
         Name = nameof(from.EndTime), Value = from.EndTime
     });
     properties.Add(new Property {
         Name = nameof(from.AggregatedDescription), Value = from.AggregatedDescription
     });
     properties.Add(new Property {
         Name = nameof(from.Invalidated), Value = from.Invalidated
     });
     properties.Add(new Property {
         Name = nameof(from.StartTime), Value = from.StartTime
     });
     properties.Add(new Property {
         Name = nameof(from.Result), Value = from.Result.ToString()
     });
     properties.Add(new Property {
         Name = nameof(from.LogInfo), Value = from.LogInfo
     });
     properties.Add(new Property {
         Name = nameof(from.Used), Value = from.Used
     });
     properties.Add(new Property {
         Name = nameof(from.UsedValue), Value = from.UsedValue
     });
     foreach (var prop in from.GetAllPropertyNames().ToArray())
     {
         properties.Add(new Property {
             Name = prop, Value = from.GetPropertyValue(prop)
         });
     }
     to.Properties = properties;
 }
        protected override void PopulateLinks(ExecutionTestStepLog from, ReportableObject to)
        {
            //issues
            List <Link> links     = new List <Link>();
            var         valueLogs = from.TestStepValueLogsInRightOrder.ToArray();

            if (valueLogs.Length > 0)
            {
                links.Add(new Link {
                    LinkDescription = new LinkDescription {
                        Description = "Test Step Value Logs", SourceEntity = to.Type, TargetEntityTypes = new string[] { "Test Step Value Log" }
                    }, LinkedObjects = valueLogs.Select(x => x.Surrogate.ToString()).ToArray()
                });
            }
            to.Links = links;
        }
Example #21
0
        protected override void PopulateLinks(ExecutionTestCaseLog from, ReportableObject to)
        {
            //issues
            List <Link> links  = new List <Link>();
            var         issues = from.Issues.ToArray();

            if (issues.Length > 0)
            {
                links.Add(new Link {
                    LinkDescription = new LinkDescription {
                        Description = "Issues", SourceEntity = to.Type, TargetEntityTypes = new string[] { "Issue" }
                    }, LinkedObjects = issues.Select(x => x.Surrogate.ToString()).ToArray()
                });
            }
            to.Links = links;
        }
Example #22
0
        protected override void PopulateLinks(Requirement from, ReportableObject to)
        {
            List <Link> links = new List <Link>();

            if (from.TotalTestCaseLinkCount > 0)
            {
                var logs = from?.TestCaseLink.Select(x => x?.TestedBy.Get()).ToArray();
                if (logs != null && logs.Length > 0)
                {
                    links.Add(new Link {
                        LinkDescription = new LinkDescription {
                            Description = "Linked Test Cases", SourceEntity = to.Type, TargetEntityTypes = new string[] { "Test Case" }
                        }, LinkedObjects = logs?.Select(x => x?.Surrogate.ToString()).ToArray()
                    });
                }
            }
            to.Links = links;
        }
Example #23
0
        private async Task <ReportableObject> InsertObject(ReportableObject obj, IMongoCollection <ReportableObject> reportableObjects, IMongoCollection <ObjectHistory> objectHistories, Snapshot currentSnapshot)
        {
            var existingObjectCursor = await reportableObjects.FindAsync(x => x.ID == obj.ID);

            var existingObjects = existingObjectCursor.ToList();

            if (existingObjects.Count == 0)
            {
                objectHistories.InsertOne(new ObjectHistory {
                    ReportableObject = obj, Snapshot = currentSnapshot
                });
                reportableObjects.InsertOne(obj);
                return(obj);
            }
            else
            {
                var storedObj = existingObjects.First();
                try
                {
                    if (storedObj.Hash == null && obj.Hash == null)
                    {
                        return(obj);
                    }
                    if (storedObj.Hash != null && obj.Hash != null)
                    {
                        if (storedObj.Hash.SequenceEqual(obj.Hash))
                        {
                            return(obj); //no change
                        }
                    }
                    await objectHistories.InsertOneAsync(new ObjectHistory { ReportableObject = storedObj, Snapshot = currentSnapshot });

                    await reportableObjects.ReplaceOneAsync(x => x.ID == obj.ID, obj);

                    return(obj);
                }
                catch (Exception e)
                {
                    throw e;
                } //If an error occurs,
                ///TODO:
                ///Pass this query task off to the DB to do the comparison for latency
            }
        }
 protected override void PopulateProperties(ExecutionEntry from, ReportableObject to)
 {
     #region Basic Details
     to.ID = from.Surrogate.ToString();
     #endregion
     List <Property> properties = new List <Property>();
     properties.Add(new Property {
         Name = nameof(from.DisplayedName), Value = from.DisplayedName
     });
     properties.Add(new Property {
         Name = nameof(from.NodePath), Value = from.NodePath
     });
     properties.Add(new Property {
         Name = nameof(from.ActualResult), Value = from.ActualResult.ToString()
     });
     properties.Add(new Property {
         Name = nameof(from.IsBusinessExecutionEntry), Value = from.IsBusinessExecutionEntry
     });
     to.Properties = properties;
 }
Example #25
0
        protected override void PopulateProperties(TestCase from, ReportableObject to)
        {
            #region Basic Details
            to.ID = from.Surrogate.ToString();
            #endregion
            List <Property> properties = new List <Property>();
            properties.Add(new Property {
                Name = nameof(from.DisplayedName), Value = from.DisplayedName
            });
            properties.Add(new Property {
                Name = nameof(from.NodePath), Value = from.NodePath
            });
            properties.Add(new Property {
                Name = nameof(from.Description), Value = from.Description
            });
            properties.Add(new Property {
                Name = nameof(from.IsTemplate), Value = from.IsTemplate
            });
            properties.Add(new Property {
                Name = nameof(from.IsOsvItem), Value = from.IsOsvItem
            });
            string testType = "Automated";
            if (from.ContainsManualItems)
            {
                testType = "Manual";
            }

            properties.Add(new Property {
                Name = "Test Type", Value = testType
            });
            foreach (var prop in from.GetAllProperties().ToArray())
            {
                properties.Add(new Property {
                    Name = prop.Name, Value = prop.Value
                });
            }
            to.Properties = properties;
        }
Example #26
0
        protected override void PopulateProperties(Module from, ReportableObject to)
        {
            to.ID = from.Surrogate.ToString();
            List <Property> properties = new List <Property>();

            properties.Add(new Property {
                Name = nameof(from.DisplayedName), Value = from.DisplayedName
            });
            properties.Add(new Property {
                Name = nameof(from.NodePath), Value = from.NodePath
            });
            properties.Add(new Property {
                Name = "Module Type", Value = "Module"
            });

            foreach (var prop in from.GetAllPropertyNames().ToArray())
            {
                properties.Add(new Property {
                    Name = prop, Value = from.GetPropertyValue(prop)
                });
            }
            to.Properties = properties;
        }
Example #27
0
        protected override void PopulateLinks(XModule from, ReportableObject to)
        {
            List <Link> links      = new List <Link>();
            var         logs       = from.TestSteps.ToArray();
            var         attributes = from.AllAttributes.ToArray();

            if (logs.Length > 0)
            {
                links.Add(new Link {
                    LinkDescription = new LinkDescription {
                        Description = "Test Steps", SourceEntity = to.Type, TargetEntityTypes = new string[] { "Test Step" }
                    }, LinkedObjects = logs.Select(x => x.Surrogate.ToString()).ToArray()
                });
            }
            if (attributes.Length > 0)
            {
                links.Add(new Link {
                    LinkDescription = new LinkDescription {
                        Description = "Module Attributes", SourceEntity = to.Type, TargetEntityTypes = new string[] { "Module Attribute" }
                    }, LinkedObjects = attributes.Select(x => x.Surrogate.ToString()).ToArray()
                });
            }
            to.Links = links;
        }
Example #28
0
        public void GenerateAccentureReport()
        {
            using (FileStream stream = new FileStream(@"C:\Temp\AccentureReport.xlsx", FileMode.Create))
            {
                using (var package = new ExcelPackage(stream))
                {
                    var wb = package.Workbook;
                    var ws = wb.Worksheets.Add("Test Execution");
                    //TestCaseExecutionId	TestCaseName	Phase	Status	Priority	Cycle	ExecutionPlannedDate	ExecutionActualDate	LoggedOn	LoggedBy

                    MongoDB.Driver.MongoClient client = new MongoDB.Driver.MongoClient();
                    var db = client.GetDatabase("tosca");
                    var reportableObjects = db.GetCollection <ReportableObject>("reportable_objects");
                    #region Test Execution
                    var executionLogs = reportableObjects.FindSync <ReportableObject>(Builders <ReportableObject> .Filter.Eq <string>("Type", "Execution Test Case Log")).ToList();

                    ws.Cells[1, 1].Value  = "TestCaseExecutionId";
                    ws.Cells[1, 2].Value  = "TestCaseName";
                    ws.Cells[1, 3].Value  = "Phase";
                    ws.Cells[1, 4].Value  = "Status";
                    ws.Cells[1, 5].Value  = "Priority";
                    ws.Cells[1, 6].Value  = "Cycle";
                    ws.Cells[1, 7].Value  = "ExecutionPlannedDate";
                    ws.Cells[1, 8].Value  = "ExecutionActualDate";
                    ws.Cells[1, 9].Value  = "LoggedOn";
                    ws.Cells[1, 10].Value = "LoggedBy";
                    ws.Cells[1, 11].Value = "ExecutedTestCase";

                    for (int i = 0; i < executionLogs.Count; i++)
                    {
                        ReportableObject log = executionLogs[i];
                        ws.Cells[i + 2, 1].Value = log.ID;
                        ws.Cells[i + 2, 2].Value = log["DisplayedName"];
                        ws.Cells[i + 2, 3].Value = "Product Test";
                        ws.Cells[i + 2, 4].Value = log["Result"];
                        ws.Cells[i + 2, 5].Value = "Medium";
                        ws.Cells[i + 2, 6].Value = "1";
                        ws.Cells[i + 2, 7].Value = log["EndTime"];
                        ws.Cells[i + 2, 7].Style.Numberformat.Format = "dd-mmm-yyyy";

                        ws.Cells[i + 2, 8].Value = log["EndTime"];
                        ws.Cells[i + 2, 8].Style.Numberformat.Format = "dd-mmm-yyyy";

                        ws.Cells[i + 2, 9].Value = log["StartTime"];
                        ws.Cells[i + 2, 9].Style.Numberformat.Format = "dd-mmm-yyyy";

                        ws.Cells[i + 2, 10].Value = log["UserName"];
                        ws.Cells[i + 2, 11].Value = log["ExecutedTestCase"];
                    }
                    #endregion
                    #region Test Cases
                    var testCases = reportableObjects.Find(x => x.Type == "Test Case").ToList();
                    ws = wb.Worksheets.Add("Test Cases");

                    ws.Cells[1, 1].Value  = "TestCaseId";
                    ws.Cells[1, 2].Value  = "TestCaseName";
                    ws.Cells[1, 3].Value  = "TestCaseDescription";
                    ws.Cells[1, 4].Value  = "Phase";
                    ws.Cells[1, 5].Value  = "Priority";
                    ws.Cells[1, 6].Value  = "Status";
                    ws.Cells[1, 7].Value  = "IsAutomated";
                    ws.Cells[1, 8].Value  = "CarryForwardFlag";
                    ws.Cells[1, 9].Value  = "Cycle";
                    ws.Cells[1, 10].Value = "TestExecutionPlannedDate";
                    ws.Cells[1, 11].Value = "LoggedBy";
                    ws.Cells[1, 12].Value = "LoggedOn";
                    ws.Cells[1, 13].Value = "Requirement";
                    for (int i = 0; i < testCases.Count; i++)
                    {
                        ReportableObject log = testCases[i];
                        var reqFilter        = Builders <ReportableObject> .Filter.ElemMatch(x => x.Links, x => x.LinkDescription.Description == "Linked Test Cases" && x.LinkedObjects.Contains(log.ID));

                        var reqs = reportableObjects.Find(reqFilter).ToList();
                        ws.Cells[i + 2, 1].Value  = log.ID;
                        ws.Cells[i + 2, 2].Value  = log["DisplayedName"];
                        ws.Cells[i + 2, 3].Value  = log["Description"];
                        ws.Cells[i + 2, 4].Value  = "Product Test";
                        ws.Cells[i + 2, 5].Value  = "Medium";
                        ws.Cells[i + 2, 6].Value  = "Created";
                        ws.Cells[i + 2, 7].Value  = "No";
                        ws.Cells[i + 2, 8].Value  = "No";
                        ws.Cells[i + 2, 9].Value  = "1";
                        ws.Cells[i + 2, 10].Value = "";
                        ws.Cells[i + 2, 11].Value = "Admin";
                        ws.Cells[i + 2, 12].Value = "";
                        if (reqs.Count > 0)
                        {
                            ws.Cells[i + 2, 13].Value = reqs.Select(x => x.ID).Aggregate((x, y) => $"{x},{y}");
                        }
                    }

                    var reqWS   = wb.Worksheets.Add("Requirements");
                    var allReqs = reportableObjects.Find(x => x.Type == "Requirement").ToList();
                    for (int i = 0; i < allReqs.Count; i++)
                    {
                        var req = allReqs[i];

                        for (int j = 0; j < req.Properties.Count; j++)
                        {
                            if (i == 0)
                            {
                                if (j == 0)
                                {
                                    reqWS.Cells[1, 1].Value = "ID";
                                }
                                reqWS.Cells[1, j + 2].Value = req.Properties[j].Name;
                            }
                            if (j == 0)
                            {
                                reqWS.Cells[i + 2, 1].Value = req.ID;
                            }
                            reqWS.Cells[i + 2, j + 2].Value = req.Properties[j].Value;
                        }
                    }
                    #endregion
                    package.Save();
                }
            }
        }
Example #29
0
 protected abstract void PopulateLinks(T from, ReportableObject to);
Example #30
0
 protected abstract void PopulateProperties(T from, ReportableObject to);