예제 #1
0
        public PrintWeatherForecastUseCaseTest()
        {
            pact = new Pact();
            pact.Given("")
            .UponReceiving("A weather forecast request")
            .With(new HttpRequest
            {
                Method = System.Net.Http.HttpMethod.Get,
                Path   = "weatherforecast/Munich/3"
            })
            .WithRequestMatchingRule(r => r.Path, r => r.Regex(pathFormat.ToString()))
            .WillRespondWith(request =>
            {
                var match = pathFormat.Match(request.Path);
                return(new HttpResponse
                {
                    Status = System.Net.HttpStatusCode.OK,
                    Body = new WeatherForecast
                    {
                        City = match.Groups[1].Value,
                        Date = new DateTime(2020, 3, 24),
                        Summary = "Sunny",
                        TemperatureC = 24,
                        TemperatureF = 75
                    }
                });
            })
            .WithResponseMatchingRule(r => ((WeatherForecast)r.Body), r => r.Type());

            server = new HttpMockServer(pact, new JsonPayloadFormat());
            server.Start();
        }
예제 #2
0
파일: BLLPact.cs 프로젝트: 15831944/C-12-
 public bool update(Pact pacts)
 {
     try
     {
         Pact newPact = dbcontext.PactContext.Find(pacts.PactID);
         newPact.FileNum        = pacts.FileNum;
         newPact.PactNum        = pacts.PactNum;
         newPact.PactName       = pacts.PactName;
         newPact.PactType       = pacts.PactType;
         newPact.StartTime      = pacts.StartTime;
         newPact.EndTime        = pacts.EndTime;
         newPact.ProjectID      = pacts.ProjectID;
         newPact.SecrecyLevel   = pacts.SecrecyLevel;
         newPact.ChargePerson   = pacts.ChargePerson;
         newPact.PactMoney      = pacts.PactMoney;
         newPact.RealMoney      = pacts.RealMoney;
         newPact.PactCompletion = pacts.PactCompletion;
         newPact.IsExistingFile = pacts.IsExistingFile;
         newPact.IsPass         = pacts.IsPass;
         dbcontext.SaveChanges();
         return(true);
     }
     catch (System.Data.SqlClient.SqlException e)
     {
         throw e;
     }
 }
예제 #3
0
        internal static Pact DefinePact(Func <Request, Response> requestHandler = null)
        {
            var pact = new Pact();

            pact
            .Given("A foo with id 1 exists")
            .UponReceiving("A get foo request")
            .With(new Request
            {
                Type = "Foo",
                Ids  = { "1" }
            })
            .WithRequestArrayMatchingRule(r => r.Ids, i => i.LengthMin(1).All().Regex("^[1-9][0-9]*$"))
            .WillRespondWith(requestHandler ?? ValidRequestHandler)
            .WithResponseArrayMatchingRule(r => r.Bars, b => b.LengthMax(0))
            .WithResponseArrayMatchingRule(r => r.Foos, r => r.At(0).With(f => f.Size, s => s.TypeMin(0)))
            .WithResponseArrayMatchingRule(r => r.Foos, r => r.All().With(f => f.Id, i => i.Regex("^[1-9][0-9]*$")));

            pact
            .Given("A bar with id 12 exists")
            .UponReceiving("A get bar request")
            .With(new Request
            {
                Type = "Bar",
                Ids  = { "12" }
            })
            .WithRequestArrayMatchingRule(r => r.Ids, i => i.LengthMin(1).All().Regex("^[1-9][0-9]*$"))
            .WillRespondWith(requestHandler ?? ValidRequestHandler)
            .WithResponseArrayMatchingRule(r => r.Foos, b => b.LengthMax(0))
            .WithResponseArrayMatchingRule(r => r.Bars, r => r.At(0).With(f => f.Name, s => s.Type()))
            .WithResponseArrayMatchingRule(r => r.Bars, r => r.All().With(f => f.Id, i => i.Regex("^[1-9][0-9]*$")));

            return(pact);
        }
예제 #4
0
        public HttpResponseMessage PutPact(int id, [FromBody] Pact post)
        {
            var pacts = PactsRepository.UpdatePact(id, post);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, pacts);

            return(response);
        }
예제 #5
0
        static PactDefinition()
        {
            Pact = new Pact();
            var pathFormat = new Regex("weatherforecast\\/([a-zA-Z]+)\\/(\\d+)");

            Pact.Given("")
            .UponReceiving("A weather forecast request")
            .With(new HttpRequest
            {
                Method = System.Net.Http.HttpMethod.Get,
                Path   = "weatherforecast/Munich/3"
            })
            .WithRequestMatchingRule(r => r.Path, r => r.Regex(pathFormat.ToString()))
            .WillRespondWith(request =>
            {
                var match = pathFormat.Match(request.Path);
                return(new HttpResponse
                {
                    Status = System.Net.HttpStatusCode.OK,
                    Body = new WeatherForecast
                    {
                        City = match.Groups[1].Value,
                        Date = new DateTime(2020, 3, 24),
                        Summary = "Sunny",
                        TemperatureC = 24,
                        TemperatureF = 75
                    }
                });
            })
            .WithResponseMatchingRule(r => ((WeatherForecast)r.Body), r => r.Type());
        }
예제 #6
0
        public IHttpActionResult PactPact([FromBody] Pact post)
        {
            var pacts = PactsRepository.InsertPact(post);

            return(Ok(new {
                value = pacts
            }));
        }
예제 #7
0
        public IHttpActionResult FinalitzarPact([FromBody] Pact pact)
        {
            var pacts = PactsRepository.FinalitzarPacte(pact.Id_Pact, pact.date_finished, pact.hours);

            return(Ok(new {
                value = pacts
            }));
        }
예제 #8
0
파일: BLLPact.cs 프로젝트: 15831944/C-12-
 //插入合同信息
 public void Insert(Pact pact)
 {
     try
     {
         dbcontext.PactContext.Add(pact);
         dbcontext.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
예제 #9
0
파일: BLLPact.cs 프로젝트: 15831944/C-12-
 //删除附件
 public void UpdateAttachment(int ID)
 {
     try
     {
         Pact NewPact = dbcontext.PactContext.Find(ID);
         NewPact.AttachmentID = null;
         dbcontext.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
        public static Pact UpdatePact(int id, Pact pact)
        {
            var pc = db.Pacts.FirstOrDefault(x => x.Id_Pact == id);

            if (pc == null)
            {
                return(null);
            }

            pc.description   = pact.description;
            pc.title         = pact.title;
            pc.date_finished = pact.date_finished;
            pc.date_created  = pact.date_created;
            db.SaveChanges();
            return(pc);
        }
예제 #11
0
파일: BLLPact.cs 프로젝트: 15831944/C-12-
 //更新IsPass状态
 public void UpdateIsPass(int ID, bool isPass)
 {
     try
     {
         Pact NewPact = dbcontext.PactContext.Find(ID);
         if (NewPact == null)
         {
             return;
         }
         NewPact.IsPass = isPass;
         dbcontext.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
예제 #12
0
파일: BLLPact.cs 프로젝트: 15831944/C-12-
 //根据PactID删除合同信息
 public bool Delete(int pactID)
 {
     try
     {
         Pact pact = dbcontext.PactContext.Find(pactID);
         if (pact != null)
         {
             dbcontext.PactContext.Attach(pact);
             dbcontext.PactContext.Remove(pact);
             dbcontext.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         throw;
     }
 }
예제 #13
0
 public HttpMockServer(Pact pact, IPayloadFormat payloadFormat, ITransportMatchers transportMatchers)
 {
     this.pact              = pact;
     this.payloadFormat     = payloadFormat;
     this.transportMatchers = transportMatchers;
 }
예제 #14
0
 public HttpMockServer(Pact pact, IPayloadFormat payloadFormat)
     : this(pact, payloadFormat, new PactV2CompliantHttpTransportMatchers())
 {
 }
예제 #15
0
 public ProviderState(string providerState, Pact pact)
 {
     this.providerState = providerState;
     this.pact          = pact;
 }
예제 #16
0
 public HonourConsumerPact()
 {
     client             = new HttpClient();
     client.BaseAddress = new Uri("http://localhost:60374/");
     pact = new Pact(ConsumerPact.GetPactFile(), new HttpTransport(client, new ProtobufPayloadFormat <WeatherForecast>()), s => Task.CompletedTask);
 }
 public static int InsertPact(Pact pact)
 {
     db.Pacts.Add(pact);
     db.SaveChanges();
     return(pact.Id_Pact);
 }
예제 #18
0
 public CallbacksMockServer(Pact pact, ITransportMatchers matchers = null)
 {
     this.pact     = pact;
     this.matchers = matchers ?? new NoTransportMatchers();
 }
예제 #19
0
        private void GivenAPact(Func <Request, Response> responder)
        {
            var transport = new CallbackTransport(new NoTransportFormat(new JsonPayloadFormat()), request => Task.FromResult((object)responder(JsonConvert.DeserializeObject <Request>(request.ToString()))));

            pact = new Pact(PublishedPact.Get(), transport, s => Task.CompletedTask);
        }