public void Init() { var now = DateTime.Now; this.currentDate = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second); this.analysisInfo = new AnalysisInformation(currentDate, "test", "for testing"); }
public void AliasProperty_OnSet_SetsTheValue() { var analysisInformation = new AnalysisInformation(); analysisInformation.Alias = "alias"; Assert.AreEqual("alias", analysisInformation.Alias); }
public async Task SynchronizeWithServer_ConnectedModeWithIssues_IssuesAddedToStore() { var serverIssue1 = new TestSonarQubeIssue(); var serverIssue2 = new TestSonarQubeIssue(); var issueViz1 = Mock.Of <IAnalysisIssueVisualization>(); var issueViz2 = Mock.Of <IAnalysisIssueVisualization>(); var converter = new Mock <ITaintIssueToIssueVisualizationConverter>(); converter.Setup(x => x.Convert(serverIssue1)).Returns(issueViz1); converter.Setup(x => x.Convert(serverIssue2)).Returns(issueViz2); var taintStore = new Mock <ITaintStore>(); var analysisInformation = new AnalysisInformation("some branch", DateTimeOffset.Now); var sonarServerMock = CreateSonarService(); SetupTaintIssues(sonarServerMock, serverIssue1, serverIssue2); SetupAnalysisInformation(sonarServerMock, analysisInformation); var testSubject = CreateTestSubject(taintStore.Object, converter.Object, sonarService: sonarServerMock.Object); await testSubject.SynchronizeWithServer(); taintStore.Verify(x => x.Set(new[] { issueViz1, issueViz2 }, It.Is((AnalysisInformation a) => a.AnalysisTimestamp == analysisInformation.AnalysisTimestamp && a.BranchName == analysisInformation.BranchName)), Times.Once); }
public void TokensProperty_OnSet_SetsTheValueToNull() { var analysisInformation = new AnalysisInformation(); analysisInformation.Tokens = null; Assert.IsNull(analysisInformation.Tokens); }
public override Analysis GetAnalysis() { Analysis analysis; if (!string.IsNullOrEmpty(FocusKeyword) && FocusKeyword != "undefined") { FocusKeyword = FocusKeyword.ToLower(); var wordOccurenceService = new WordOccurenceService(); var topwords = wordOccurenceService.GetKeywords(HtmlResult); var information = new AnalysisInformation { Alias = "keywordanalyzer_top_words" }; information.Tokens.Add(FocusKeyword); foreach (var word in topwords) { information.Tokens.Add(word.Key); information.Tokens.Add(word.Value.ToString()); } analysis = base.GetAnalysis(); analysis.Information.Add(information); } else { analysis = new Analysis(); var information = new AnalysisInformation { Alias = "keywordanalyzer_focus_keyword_not_set" }; analysis.Information.Add(information); } return(analysis); }
public void ResultsProperty_OnSet_SetsTheValueToNull() { var analysisInformation = new AnalysisInformation(); analysisInformation.Alias = null; Assert.IsNull(analysisInformation.Alias); }
private AnalysisInformation SaveAnalysisInformation(IAnalysisMetadata amd) { var ad = new AnalysisInformation(amd.CreationDate, amd.Title, amd.Description, this.controller); ad.Save(); return(ad); }
private void SaveAnalysisData(IAnalysisData <IAnalysisDataRow> ad, AnalysisInformation ai) { var xArray = ad.Data.Select(d => d.X).ToArray(); var yArray = ad.Data.Select(d => d.Y).ToArray(); var adEntity = new AnalysisData(ad.XMeaning, xArray, ad.YMeaning, yArray, ai, this.controller); adEntity.Save(); }
public void TokensProperty_OnSet_SetsTheValue() { var analysisInformation = new AnalysisInformation(); analysisInformation.Tokens = new List <string>() { "token" }; Assert.IsNotNull(analysisInformation.Tokens); Assert.AreEqual(1, analysisInformation.Tokens.Count()); }
public void GetAnalysisInformation_HasInformation_ReturnsInformation() { var analysisInformation = new AnalysisInformation("some branch", DateTimeOffset.Now); var testSubject = CreateTestSubject(); testSubject.Set(Enumerable.Empty <IAnalysisIssueVisualization>(), analysisInformation); var result = testSubject.GetAnalysisInformation(); result.Should().BeSameAs(analysisInformation); }
public Analysis GetAnalysis() { var analysis = new Analysis(); if (!string.IsNullOrEmpty(FocusKeyword) && FocusKeyword != "undefined") { FocusKeyword = FocusKeyword.ToLower(); var wordOccurenceService = new WordOccurenceService(); var topwords = wordOccurenceService.GetKeywords(_htmlResult); var information = new AnalysisInformation { Alias = "keywordanalyzer_top_words" }; information.Tokens.Add(FocusKeyword); foreach (var word in topwords) { information.Tokens.Add(word.Key); information.Tokens.Add(word.Value.ToString()); } analysis.Information.Add(information); var keywordTitleAnalyzer = new KeywordTitleAnalyzer(); analysis.Results.Add(keywordTitleAnalyzer.Analyse(_htmlResult.Document, FocusKeyword)); var keywordMetaDescriptionAnalyzer = new KeywordMetaDescriptionAnalyzer(); analysis.Results.Add(keywordMetaDescriptionAnalyzer.Analyse(_htmlResult.Document, FocusKeyword)); var keywordUrlAnalyzer = new KeywordUrlAnalyzer(); analysis.Results.Add(keywordUrlAnalyzer.Analyse(_htmlResult.Document, FocusKeyword, _htmlResult.Url)); var keywordContentAnalyzer = new KeywordContentAnalyzer(); analysis.Results.Add(keywordContentAnalyzer.Analyse(_htmlResult.Document, FocusKeyword)); var keywordHeadingAnalyzer = new KeywordHeadingAnalyzer(); analysis.Results.Add(keywordHeadingAnalyzer.Analyse(_htmlResult.Document, FocusKeyword)); } else { var information = new AnalysisInformation { Alias = "keywordanalyzer_focus_keyword_not_set" }; analysis.Information.Add(information); } return(analysis); }
private AnalysisInformation GetAnalysisInformation(string focusKeyword) { var topwords = _wordOccurenceHelper.GetKeywords(HtmlResult).Take(10); var information = new AnalysisInformation { Alias = "keywordanalyzer_top_words" }; information.Tokens.Add(focusKeyword); foreach (var wordOccurence in topwords) { information.Tokens.Add(wordOccurence.Key); information.Tokens.Add(wordOccurence.Value.ToString()); } return(information); }
private AnalysisInformation GetAnalysisInformation(string focusKeyword) { var information = new AnalysisInformation { Alias = "keywordanalyzer_top_words" }; if (Document != null) { var topwords = _wordOccurenceHelper.GetKeywords(Document).OrderByDescending(x => x.Value).Take(10); information.Tokens.Add(focusKeyword); foreach (var wordOccurence in topwords) { information.Tokens.Add(wordOccurence.Key); information.Tokens.Add(wordOccurence.Value.ToString()); } } return(information); }
public override Analysis GetAnalysis() { Analysis analysis; if (!string.IsNullOrEmpty(FocusKeyword) && FocusKeyword != "undefined") { var focusKeyword = FocusKeyword.ToLower(); var information = GetAnalysisInformation(focusKeyword); analysis = base.GetAnalysis(); analysis.Information.Add(information); } else { analysis = new Analysis(); var information = new AnalysisInformation { Alias = "keywordanalyzer_focus_keyword_not_set" }; analysis.Information.Add(information); } return(analysis); }
private void SetupAnalysisInformation(Mock <ISonarQubeService> sonarQubeService, AnalysisInformation mainBranchInformation) { var projectBranches = new[] { new SonarQubeProjectBranch(Guid.NewGuid().ToString(), false, DateTimeOffset.MaxValue), new SonarQubeProjectBranch(mainBranchInformation.BranchName, true, mainBranchInformation.AnalysisTimestamp), new SonarQubeProjectBranch(Guid.NewGuid().ToString(), false, DateTimeOffset.MinValue) }; sonarQubeService.Setup(x => x.GetProjectBranchesAsync(SharedProjectKey, CancellationToken.None)) .ReturnsAsync(projectBranches); }
public void Constructor_OnExecute_InitializesCollections() { var analysisInformation = new AnalysisInformation(); Assert.IsNotNull(analysisInformation.Tokens); }
public static void DisplayData(AnalysisInformation ai, AnalysisData ad) { Console.WriteLine($"{ai.Id} {ai.CreationDate.ToString()} {ai.Title} {ai.Descrioption}\n" + $"{ad.Id} {ad.XMeaning} [{string.Join(", ", ad.XData)}] {ad.YMeaning} [{string.Join(", ", ad.YData)}]"); }
private void SetupAnalysisInformation(Mock <ITaintStore> store, AnalysisInformation analysisInformation) { store.Setup(x => x.GetAnalysisInformation()).Returns(analysisInformation); }
static void Main(string[] args) { //C.R.U.D. Example: //To make queries to the database we instantiate the Model Adapter Controller and we give it the namespace where the models are and the DbContext subclass var controller = new ModelController <LinearRegressionDbContext>("LinearRegression.Database.Model"); //X and Y data for two entities var x = new double[] { 1, 2, 3, 4, 5 }; //can be any kind of Enumerable collection var y = new double[] { 6, 7, 8, 9, 10 }; var x1 = new double[] { 1.1, 2.2, 3.3, 4.4, 5.5 }; var y1 = new double[] { 6.6, 7.7, 8.8, 9.9, 10.10 }; //Creating the entities. //First we create the AnalysisInformation entity. It is important to mention that we use Database.ModelAdapters not Database.Model var ai1 = new AnalysisInformation(DateTime.Now, "Analysis1", "Test entity", controller); var ai2 = new AnalysisInformation(DateTime.Now, "Analysis2", "Test entity", controller); //IT IS A MUST TO SAVE ALL THE CREATED ENTITIES RIGHT AFTER CREATION!!!! //That way they get their ID incremented ai1.Save(); ai2.Save(); //Right after that we are able to link the AnalysisData to the AnalysisInformation. For the perpouse we again use the class from Database.ModelAdapters var ad1 = new AnalysisData("X", x, "Y", y, ai1, controller); var ad2 = new AnalysisData("X", x1, "Y", y1, ai2, controller); //After that we immediately save the changes ad1.Save(); ad2.Save(); //Data can have comments added to it var comment = new Comment(ai1.Id, "Benchi", "Sednal na edno druvo", controller); comment.Save(); //Get all the entities from analysis information var allInformation = controller.GetAllEntities <AnalysisInformation>(); //To retrieve comments just ask for them Console.WriteLine(allInformation.First().Comments.First().Content); //Calculations can also be added to the analysis to save time on the next opening var calculation = new AnalysisCalculations(ad2, new double[] { 1.2, 3.6, 5.4 }, 12.3, 15.5, 1.36, 1478.5, 323, 4, 6, 44, 66, 88, controller); calculation.Save(); //Calculation is obtained by asking the related AnalysisData for it var calcObtained = ad2.AnalysisCalculations; //Lets check if it works Console.WriteLine(string.Join(" ", calcObtained.AdjustedY)); //Getting an item from the database. //We can get an item by its ID var firstEntityId = controller.GetAllEntities <AnalysisInformation>().First().Id; //As generic parameters we pass the Model Adapter class and the Model class itself var itemById = controller.GetEntityById <AnalysisInformation>(firstEntityId); //Each item keeps relation with its analysis data var itemByIdData = itemById.Data; DisplayData(itemById, itemByIdData); //We can also use a function to find an item var anInfWhere = controller.FindEntity <AnalysisInformation>(ai => ((Model.AnalysisInformation)ai).Title == "Analysis2"); DisplayData(anInfWhere, anInfWhere.Data); //And we can get all the items from the database var collection = controller.GetAllEntities <AnalysisData>(); foreach (var entity in collection) { DisplayData(entity.AnalysisInformation, entity as AnalysisData); } //Finally but not least we can delete items like this controller.DeleteAllEntities(allInformation); //It is important to mention that AnalysisData and AnalysisCalculations CANNOT be directly deleted! You must delete AnalysisInformation which will trigger all other deletions. }