コード例 #1
0
        public void GetCustomerMethod()
        {
            //Arrange
            var stream = new MemoryStream(Encoding.UTF8.GetBytes(@"{ ""Metadata"":{""id"":""System.Int32"",""type"":""System.String""},""Data"":[1,""Local""]}"));
            var args   = new RequestBodyParser().Parse(stream);

            ServiceRequest request = ServiceRequest.Create(
                "Contracts.ICustomer", null,
                "GetCustomer",
                new HeaderDictionary()
            {
                ["module"] = "Contracts"
            }, args);

            ServiceGatewayHandler handler = new ServiceGatewayHandler();

            //Act
            var response = handler.Process(ServiceManager.Instance, request);

            //Assert
            Assert.IsNotNull(response.Body);
            var customer = Newtonsoft.Json.JsonConvert.DeserializeObject <Customer>(Encoding.UTF8.GetString(response.Body));

            Assert.IsNotEmpty(customer.Name);
        }
コード例 #2
0
        public void SaveMethod()
        {
            //Arrange
            var stream = new MemoryStream(Encoding.UTF8.GetBytes(@"{""Metadata"":null,""Data"":null}"));
            var args   = new RequestBodyParser().Parse(stream);

            ServiceRequest request = ServiceRequest.Create("Contracts.ICustomer", null, "Save",
                                                           new HeaderDictionary()
            {
                ["module"] = "Contracts"
            }
                                                           , args);
            ServiceGatewayHandler handler = new ServiceGatewayHandler();

            //Act
            var response = handler.Process(ServiceManager.Instance, request);

            //Assert
            Assert.IsNull(response?.Body);
        }