[Fact]//Controllers.HaikuController.cs public void HaikuControllerTest6() { HaikuRepo haikuRepo = new HaikuRepo(hContext); UserRepo userRepo = new UserRepo(hContext); HaikuGenerator haikugen = new HaikuGenerator(haikuRepo); HaikuMethods haikuMethods = new HaikuMethods(haikuRepo); HaikuController haikucon = new HaikuController(haikugen, haikuMethods); RawHaikuLine newLine = new RawHaikuLine(); newLine.syllable = 5; newLine.line = "Just another test line"; newLine.tags = "huh"; newLine.username = "******"; HaikuDTO haiku = new HaikuDTO(); haiku.haikuLine1 = newLine.line; var actionhaikuline = haikucon.SubmitHaikuLine(newLine); newLine.syllable = 7; newLine.line = "Is this the real life?"; newLine.tags = "who"; haiku.haikuLine2 = newLine.line; actionhaikuline = haikucon.SubmitHaikuLine(newLine); newLine.syllable = 5; newLine.line = "Is this just fantasy"; newLine.tags = "where"; haiku.haikuLine3 = newLine.line; actionhaikuline = haikucon.SubmitHaikuLine(newLine); var activonhaiku = haikucon.SubmitHaiku(haiku); var expected = true; var actual = haikucon.ApproveHaiku(1).Value; Assert.Equal(expected, actual); }
[Fact]//HaikuGenerator.cs public void HaikuGeneratorTest3() { HaikuRepo haikurepo = new HaikuRepo(hContext); HaikuMethods haikumethods = new HaikuMethods(haikurepo); HaikuGenerator haikugen = new HaikuGenerator(haikurepo); HaikuController haikucon = new HaikuController(haikugen, haikumethods); RawHaikuLine newLine = new RawHaikuLine(); newLine.syllable = 5; newLine.line = "Just another test line"; newLine.tags = "huh"; newLine.username = "******"; var actionhaiku = haikucon.SubmitHaikuLine(newLine); newLine.syllable = 7; newLine.line = "Is this the real life?"; newLine.tags = "who"; actionhaiku = haikucon.SubmitHaikuLine(newLine); newLine.syllable = 5; newLine.line = "Is this just fantasy"; newLine.tags = "where"; actionhaiku = haikucon.SubmitHaikuLine(newLine); HaikuDTO haiku = haikucon.GenerateHaiku().Value; var expected = true; var actual = (haiku != null); Assert.Equal(expected, actual); }
public ActionResult <Haiku> SubmitHaiku([FromBody] HaikuDTO haiku) { Haiku h = new Haiku { HaikuLine1 = haiku.haikuLine1, HaikuLine2 = haiku.haikuLine2, HaikuLine3 = haiku.haikuLine2, Tags = haiku.tags, Approved = false, Username = haiku.username }; Haiku newhaiku = _haikuMethod.SubmitHaiku(h); return(newhaiku); }
public HaikuDTO GenerateHaiku() { //Get lines for the haiku MakeHaiku(); //Get tags string tags = GetTags(Line1, Line2, Line3); //get usernames string username = GetUsername(Line1, Line2, Line3); // set haiku lines for haiku DTO HaikuDTO generatedHaiku = new HaikuDTO { haikuLine1 = Line1.Line, haikuLine2 = Line2.Line, haikuLine3 = Line3.Line, tags = tags, username = username }; return(generatedHaiku); }
public IList <HaikuDTO> Get(int skipCount, int takeCount, HaikuSortBy orderType = HaikuSortBy.RatingValue, SortingOrder sortingOrder = SortingOrder.ASC) { var repo = _dataManager.CreateInstance <Haiku>(); return(HaikuDTO.CovertToHaikuDTO(repo.Get(skipCount, takeCount, orderType.ToString(), sortingOrder))); }
public ActionResult <HaikuDTO> GenerateHaiku() { HaikuDTO haiku = _haukuGenerator.GenerateHaiku(); return(haiku); }