Exemplo n.º 1
0
        public void SetUp()
        {
            var httpConfiguration = new HttpConfiguration();

            httpConfiguration.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}",
                                                  new { id = RouteConfig.GetOptional() });
            server = new HttpServer(httpConfiguration);
            client = new HttpClient(server);


            for (int i = 0; i < 10; ++i)
            {
                var id = MorceauRobotRepo.GetNextId();
                MorceauRobotRepo.MorceauxRobot[id] = new MorceauRobot
                {
                    Id          = id,
                    Description = i.ToString(CultureInfo.InvariantCulture),
                    Longueur    = ((double)i) / 2
                };
            }

            result = client.PostAsJsonAsync("http://localhost/api/morceaurobotapi",
                                            new MorceauRobot
            {
                Description = "patate",
                Longueur    = 1394,
                Nom         = "flugelhorn"
            }).Result;
        }
Exemplo n.º 2
0
 public void Post(MorceauRobot morceauRobot)
 {
     morceauRobot.Id = MorceauRobotRepo.GetNextId();
     MorceauRobotRepo.MorceauxRobot[morceauRobot.Id] = morceauRobot;
 }