public JSONPotter(Potters potter, IURLHelper urlhelper) { name = potter.Name; country = potter.Country; href = potter.Id == null ? "" : urlhelper.buildPotterURL((int)potter.Id); potshref = potter.Id == null ? "" : urlhelper.buildPotterURL((int)potter.Id) + @"/pots"; }
public int?CreatePotter(string s) { // format should be {<id>,<name>,<country>} but no id. // so just {<name>,<country>} ? Potters potter = parsePotter(s); int? newid = backEnd.createPotter(potter); return(newid); }
public void deconstruct_potter() { Potters potter = new Potters(); potter.Id = 1; potter.Name = "Jimi"; potter.Country = "USA"; (int?potter_id, String potter_name, String potter_country) = potter; Assert.AreEqual(1, potter_id); Assert.AreEqual("Jimi", potter_name); }
public string GetById(int v) { Potters potter = backEnd.getPotterById(v); if (potter == null) { return(null); } else { return(JsonConvert.SerializeObject(new JSONPotter(potter, urlhelper))); } }
private static List <Potters> makeThreePotters() { List <Potters> returned = new List <Potters>(); Potters fitch = new Potters(1, "Fitch", "Scotland"); returned.Add(fitch); Potters blakely = new Potters(2, "Blakely", "England"); Potters collins = new Potters(3, "Collins", "England"); returned.Add(blakely); returned.Add(collins); return(returned); }
public void one_potters_get_all_test() { var ipap = new Mock <IPotsAndPotters>(); List <Potters> returned = new List <Potters>(); Potters fitch = new Potters(1, "Fitch", "Scotland"); returned.Add(fitch); ipap.Setup(foo => foo.getAllPotters()).Returns(returned); var urlhelper = new Mock <IURLHelper>(); PottersDelegate pc = new PottersDelegate((IPotsAndPotters)ipap.Object, urlhelper.Object); string[] outs = pc.GetAll(); Assert.AreEqual(1, outs.Length); ipap.Verify(foo => foo.getAllPotters(), Times.AtMostOnce); ipap.VerifyNoOtherCalls(); }
public void create_potter_test() { var ipap = new Mock <IPotsAndPotters>(); string s = "{\"Name\":\"Clive Bowen\",\"Country\":\"England\"}"; Potters p = new Potters(); p.Name = "Clive Bowen"; p.Country = "England"; ipap.Setup(foo => foo.createPotter(p)).Returns(4); var urlhelper = new Mock <IURLHelper>(); PottersDelegate pd = new PottersDelegate(ipap.Object, urlhelper.Object); int? newid = pd.CreatePotter(s); Assert.AreNotEqual(null, newid); Assert.AreEqual(4, newid); ipap.Verify(foo => foo.createPotter(p), Times.AtMostOnce); ipap.VerifyNoOtherCalls(); }