public void AddEmptyThing() { using (FakeServer fs = new FakeServer().StartWithFakeRepos()) { using(JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri)){ var newThing = new Thing(); client.Post(newThing); } } }
public void TestEmptyThingRequest() { using (FakeServer fs = new FakeServer().Start()) { JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri); ThingsRequest req = new ThingsRequest(new string[] { }); IEnumerable<Thing> res = client.Get(req); Assert.AreEqual(0, res.Count()); } }
public void EmptyRequest() { using (FakeServer fs = new FakeServer().StartWithFakeRepos()) { using(JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri)){ ThingsRequest req = new ThingsRequest(); var res = client.Get(req); Assert.AreEqual(0, res.Count()); } } }
public void TestThingRequest() { using (FakeServer fs = new FakeServer().Start()) { Thing mike = new Thing("Mike"); fs.fakeThingsRepos.Things.AddFirst(mike); JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri); ThingsRequest req = new ThingsRequest(new string[] { "Mike", "Mike", "Not Mike" }); IEnumerable<Thing> res = client.Get(req); Assert.AreEqual(1, res.Count()); Assert.That(res.First().Name, Is.EqualTo(mike.Name)); } }
public void CreateExistingThing() { using (FakeServer fs = new FakeServer().StartWithFakeRepos()) { using(JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri)){ var newThing = new Thing(){ Name="d", Description="Not C++", Quadrantid=Quadrant.Languages}; fs.FakeThingsRepos.Things.AddLast(newThing); client.Post(newThing); } } }
public void AddNewThing() { using (FakeServer fs = new FakeServer().StartWithRealRepos()) { using(JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri)){ var newThing = new Thing(){ Title="D", Description="Not C++", Quadrantid=Quadrant.Languages}; client.Post(newThing); ThingsRequest req = new ThingsRequest(){Names = new string[] { "d" }}; IEnumerable<Thing> res = client.Get(req.UrlEncodeNames()); res.Count().ShouldBe(1); res.First().Description.ShouldBe(newThing.Description); res.First().Quadrantid.ShouldBe(newThing.Quadrantid); } } }
public void MultipleItemsInRequest() { using (FakeServer fs = new FakeServer().StartWithFakeRepos()) { var things = fs.FakeThingsRepos.Things; things.AddFirst(new Thing(){Name="c#"}); things.AddFirst(new Thing(){Name="mono"}); things.AddFirst(new Thing(){Name="c++"}); using(JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri)){ ThingsRequest req = new ThingsRequest(){Names = new string[] { "C#","mono" , "c++" }}; // notice that C# should be c# IEnumerable<Thing> res = client.Get(req); Assert.AreEqual(2, res.Count()); } } }
public void UpdateThing() { using (FakeServer fs = new FakeServer().StartWithRealRepos()) { using(JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri)){ var newThing = new Thing(){ Name="d", Title="D", Description="Not C++", Quadrantid=Quadrant.Languages}; newThing = fs.RealThingsRepos.StoreNew(newThing); var updatedThing = new Thing() { Name = "d", Description = ", whatever" }; client.Put(updatedThing); ThingsRequest req = new ThingsRequest(){Names = new string[] { "d" }}; IEnumerable<Thing> res = client.Get(req.UrlEncodeNames()); res.Count().ShouldBe(1); Thing result = res.Single(); result.Quadrantid.ShouldBe(newThing.Quadrantid); result.Description.ShouldBe(updatedThing.Description); } } }
public void UpdateThingDescription() { using (FakeServer fs = new FakeServer().StartWithFakeRepos()) { using(JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri)){ var newThing = new Thing(){ Name="d", Description="Not C++", Quadrantid=Quadrant.Languages}; fs.FakeThingsRepos.Things.AddLast(newThing); var updatedThing = new Thing(){ Name="d", Description="Not C++, but kinda the same"}; client.Put(updatedThing); ThingsRequest req = new ThingsRequest(){Names = new string[] { "d" }}; IEnumerable<Thing> res = client.Get(req.UrlEncodeNames()); Assert.AreEqual(1, res.Count()); Thing result = res.Single(); Assert.That(result.Quadrantid, Is.EqualTo(newThing.Quadrantid)); Assert.That(result.Description, Is.EqualTo(updatedThing.Description)); } } }
public void UpdateOfTitleShouldFail() { using (FakeServer fs = new FakeServer().StartWithFakeRepos()) { using(JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri)){ var newThing = new Thing(){ Name="f#net", Title="F# .NET", Description="something functional", Quadrantid=Quadrant.Languages}; fs.FakeThingsRepos.Things.AddLast(newThing); var updatedThing = new Thing(){ Name="f#net", Title="F#", Description="something functional", Quadrantid=Quadrant.Languages}; Thing result= client.Post(updatedThing); } } }
public void UpdateNonExistingThing() { using (FakeServer fs = new FakeServer().StartWithFakeRepos()) { using(JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri)){ var newThing = new Thing(){ Name="d", Description="Not C++", Quadrantid=Quadrant.Languages}; client.Put(newThing); } } }
public void SingleRequesByNametWithSingleAnswer() { using (FakeServer fs = new FakeServer().StartWithFakeRepos()) { Thing csharp = new Thing(){Name="c#"}; fs.FakeThingsRepos.Things.AddFirst(csharp); using(JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri)){ ThingsRequest req = new ThingsRequest() { Names = new string[] { "VBS?", "Yes", csharp.Name } }; IEnumerable<Thing> res = client.Get(req); Assert.AreEqual(1, res.Count()); Assert.That(res.First().Name, Is.EqualTo(csharp.Name)); } } }
public void SelectyByQuadrant() { using (FakeServer fs = new FakeServer().StartWithFakeRepos()) { var things = fs.FakeThingsRepos.Things; things.AddFirst(new Thing(){Name="c#", Quadrantid=Quadrant.Languages}); things.AddFirst(new Thing(){Name="mono", Quadrantid=Quadrant.Platforms}); things.AddFirst(new Thing(){Name="c++", Quadrantid =Quadrant.Languages}); using(JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri)){ ThingsRequest req = new ThingsRequest(){Quadrant = Quadrant.Languages}; IEnumerable<Thing> res = client.Get(req); Assert.AreEqual(2, res.Count()); } } }
public void SelectByKeywordSearchAndQuadrant() { using (FakeServer fs = new FakeServer().StartWithFakeRepos()) { var things = fs.FakeThingsRepos.Things; things.AddFirst(new Thing(){Name="c#", Quadrantid=Quadrant.Languages, Description="a Java like language from Microsoft" }); things.AddFirst(new Thing(){Name="mono", Quadrantid=Quadrant.Platforms, Description="an application platform by Microsoft"}); things.AddFirst(new Thing(){Name="c++", Quadrantid =Quadrant.Languages, Description="an ancient language"}); using(JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri)){ ThingsRequest req = new ThingsRequest(){Keywords = new string[]{"microsoft"}, Quadrant = Quadrant.Languages}; IEnumerable<Thing> res = client.Get(req); Assert.AreEqual(1, res.Count()); } } }