public void Execute() { List <ResultItem> results = new DescriptionRule(openApiContract, supressions, ruleSettings, cache).Execute(); Assert.Equal("info.description:", results[0].Value); Assert.Equal("path:/path-one", results[1].Value); Assert.Equal("path:/path-one,method:get", results[2].Value); Assert.Equal("path:/path-two", results[3].Value); Assert.Equal("path:/path-two,method:get", results[4].Value); Assert.Equal("path:/path-two,query-paramter:parameterOne,method:get", results[5].Value); Assert.Equal( "path:/path-two,method:get,response:200", results[6].Value); Assert.Equal( "path:/path-two,method:get,response:200,content:application/json,response.property:data.propertyOne", results[7].Value); Assert.True(new DescriptionRule(openApiContract, supressionEntireRule, ruleSettings, cache).Execute().Count == 0); }
public void Execute() { List <ResultItem> results = new DescriptionRule(openApiContract, supressions, ruleSettings, cache).Execute(); Assert.Equal("Info.Description=''", results[0].Value); Assert.Equal("Path='/path-one'", results[1].Value); Assert.Equal("Path='/path-one',Operation='get'", results[2].Value); Assert.Equal("Path='/path-two'", results[3].Value); Assert.Equal("Path='/path-two',Operation='get'", results[4].Value); Assert.Equal( "Path='/path-two',Operation='get',Parameter='parameterOne',Value='too short'", results[5].Value); Assert.Equal( "Path='/path-two',Operation='get',Response='200',Description='Status 200'", results[6].Value); Assert.Equal( "Path='/path-two',Operation='get',ResponseCode='200',Content='application/json',PropertyFull='data.propertyOne','PropertyDescription=''", results[7].Value); Assert.True(new DescriptionRule(openApiContract, supressionEntireRule, ruleSettings, cache).Execute().Count == 0); }
public static bool IsValid(string name, string description) { var nameRule = new NameRule(); var descriptionRule = new DescriptionRule(); return(nameRule.ApplyRule(name) && descriptionRule.ApplyRule(description)); }
public void DescriptionRuleTest() { var rule = new DescriptionRule(); var ad1 = new AdVO { Typology = "GARAGE", Description = "Garaje de prueba", Pictures = new List <int>(), HouseSize = 150, Score = 40 }; Assert.True(rule.Calculate(ad1) == 5); var ad2 = new AdVO { Typology = "GARAGE", Pictures = new List <int>(), HouseSize = 150, Score = 40 }; Assert.True(rule.Calculate(ad2) == 0); var ad3 = new AdVO { Typology = "GARAGE", Description = "", Pictures = new List <int>(), HouseSize = 150, Score = 40 }; Assert.True(rule.Calculate(ad3) == 0); var ad4 = new AdVO { Typology = "GARAGE", Description = " ", Pictures = new List <int>(), HouseSize = 150, Score = 40 }; Assert.True(rule.Calculate(ad4) == 0); }
public Description(string description) { var validator = new DescriptionRule(); if (!validator.IsValid(description)) { throw new InvalidEntityException(); } Value = description; }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DescriptionRule = await _context.DescriptionRule.FirstOrDefaultAsync(m => m.DescriptionRuleID == id); if (DescriptionRule == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } DescriptionRule = await _context.DescriptionRule.FindAsync(id); if (DescriptionRule != null) { _context.DescriptionRule.Remove(DescriptionRule); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }