コード例 #1
0
 public void AddEmptyThing()
 {
     using (FakeServer fs = new FakeServer().StartWithFakeRepos())
     {
         using(JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri)){
             var newThing = new Thing();
             client.Post(newThing);
         }
     }
 }
コード例 #2
0
ファイル: ThingsTest.cs プロジェクト: Oduig/sioux_tech_radar
 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());
     }
 }
コード例 #3
0
 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());
         }
     }
 }
コード例 #4
0
ファイル: ThingsTest.cs プロジェクト: Oduig/sioux_tech_radar
 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));
     }
 }
コード例 #5
0
        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);
                }
            }
        }
コード例 #6
0
        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);
                }
            }
        }
コード例 #7
0
        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());
                }
            }
        }
コード例 #8
0
        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);
                }
            }
        }
コード例 #9
0
        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));
                }
            }
        }
コード例 #10
0
        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);
                }
            }
        }
コード例 #11
0
        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);
                }
            }
        }
コード例 #12
0
        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));
                }
            }
        }
コード例 #13
0
        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());
                }
            }
        }
コード例 #14
0
        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());
                }
            }
        }