예제 #1
0
 public void TakeFirstCompanyTest()
 {
     using (SapRfcConnection conn = this.GetConnection())
     {
         var scarr = conn.Table <AirlineCompany>("SCARR").Take(1).Read();
         Assert.Equal(1, scarr.Count());
     }
 }
예제 #2
0
 public void ReadAllEntriesTest()
 {
     using (SapRfcConnection conn = this.GetConnection())
     {
         var scarr = conn.Table <AirlineCompany>("SCARR").Read();
         Assert.Equal(18, scarr.Count());
     }
 }
 public void ObjectFunctionWithSingleReturnValueTest()
 {
     using (SapRfcConnection conn = GetConnection())
     {
         int value = conn.ExecuteFunction(new SumOfTwoNumbersFunction(2, 8));
         Assert.Equal(10, value);
     }
 }
 public void ObjectFunctionTest()
 {
     using (SapRfcConnection conn = GetConnection())
     {
         var result = conn.ExecuteFunction(new DivideTwoNumbersFunction(9, 2));
         Assert.Equal(4.5m, result.Quotient);
         Assert.Equal(1, result.Remainder);
     }
 }
예제 #5
0
        public void FirstCompanyShouldBeDifferentThanSecondCompanyTest()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var firstCompany  = conn.Table <AirlineCompany>("SCARR").Take(1).ReadOne();
                var secondCompany = conn.Table <AirlineCompany>("SCARR").Skip(1).Take(1).ReadOne();

                Assert.NotEqual(firstCompany.Code, secondCompany.Code);
            }
        }
예제 #6
0
 public void ShouldNotThrowTimeoutException()
 {
     using (SapRfcConnection conn = this.GetConnection())
     {
         var result = conn.ExecuteFunction("Z_SSRT_LONG_PROCESS", new
         {
             i_seconds = 1
         });
     }
 }
예제 #7
0
        public void ReadDeltaAirlineCompanyTest()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var scarr = conn.ReadTable <AirlineCompany>("SCARR", where : new string[] { "CARRID = 'DL'" });

                Assert.Equal(1, scarr.Count());
                Assert.Equal("DL", scarr.ElementAt(0).Code);
                Assert.Equal("Delta Airlines", scarr.ElementAt(0).Name);
            }
        }
예제 #8
0
        public void MaxDateInOutTest()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var result = conn.ExecuteFunction("Z_SSRT_IN_OUT", new
                {
                    I_DATUM = DateTime.MaxValue
                });

                Assert.Equal(DateTime.MaxValue.Date, result.GetOutput <DateTime>("E_DATUM"));
            }
        }
예제 #9
0
        public void NullDateInOutTest_NonNullableStruct()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var result = conn.ExecuteFunction("Z_SSRT_IN_OUT", new
                {
                    I_DATUM = (DateTime?)null
                });

                Assert.Equal(DateTime.MinValue, result.GetOutput <DateTime>("E_DATUM"));
            }
        }
예제 #10
0
 public void ReadSingleEntryTest()
 {
     using (SapRfcConnection conn = this.GetConnection())
     {
         var scarr = conn.ReadTable <AirlineCompany>("SCARR", count: 1);
         Assert.Equal(1, scarr.Count());
         Assert.Equal("AA", scarr.ElementAt(0).Code);
         Assert.Equal("American Airlines", scarr.ElementAt(0).Name);
         Assert.Equal("USD", scarr.ElementAt(0).Currency);
         Assert.Equal("http://www.aa.com", scarr.ElementAt(0).Url);
     }
 }
예제 #11
0
 public void ShouldNotExecuteFunctionBecauseItIsNotAllowed()
 {
     using (SapRfcConnection conn = this.GetConnection())
     {
         Assert.Throws <SharpRfcCallException>(() => {
             var result = conn.ExecuteFunction("Z_SSRT_SUM",
                                               new RfcParameter("i_num1", 2),
                                               new RfcParameter("i_num2", 4)
                                               );
         });
     }
 }
예제 #12
0
        public void StrongTypeGreaterEqualAndLessEqualThanConditionTest()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var flights = conn.Table <Flight>("SPFLI")
                              .Where("DISTANCE", RfcReadTableOption.GreaterOrEqualThan, 6030)
                              .And("DISTANCE", RfcReadTableOption.LessOrEqualThan, 9100)
                              .Read();

                Assert.Equal(12, flights.Count());
            }
        }
예제 #13
0
        public void ExportSingleParameterTest()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var result = conn.ExecuteFunction("Z_SSRT_SUM",
                                                  new RfcParameter("i_num1", 2),
                                                  new RfcParameter("i_num2", 4)
                                                  );

                var total = result.GetOutput <int>("e_result");
                Assert.Equal(6, total);
            }
        }
        public void PreparedFunctionWithTwoParametersTest()
        {
            using (SapRfcConnection conn = GetConnection())
            {
                var function = conn.PrepareFunction("Z_SSRT_SUM");
                function.AddParameter(new RfcParameter("i_num1", 2));
                function.AddParameter(new { i_num2 = 4 });
                var result = function.Execute();

                var total = result.GetOutput <int>("e_result");
                Assert.Equal(6, total);
            }
        }
예제 #15
0
        public void ChangingSingleParameterTest()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var result = conn.ExecuteFunction("Z_SSRT_ADD",
                                                  new RfcParameter("i_add", 4),
                                                  new RfcParameter("c_num", 4)
                                                  );

                var total = result.GetOutput <int>("c_num");
                Assert.Equal(8, total);
            }
        }
예제 #16
0
        public void ReadAllFieldsTest()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var scarr = conn.ReadTable <AirlineCompany>("SCARR");

                var aa = scarr.FirstOrDefault(x => x.Code == "AA");
                Assert.Equal("AA", aa.Code);
                Assert.Equal("American Airlines", aa.Name);
                Assert.Equal("USD", aa.Currency);
                Assert.Equal("http://www.aa.com", aa.Url);
            }
        }
예제 #17
0
        public void ReadWithTwoOrConditionsTest()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var scarr = conn.Table <AirlineCompany>("SCARR")
                            .Select("CARRID", "CURRCODE")
                            .Where("CARRID = 'DL'")
                            .Or("CARRID = 'AA'")
                            .Read();

                Assert.Equal(2, scarr.Count());
            }
        }
예제 #18
0
 public void ExceptionTest()
 {
     using (SapRfcConnection conn = this.GetConnection())
     {
         SharpRfcCallException ex = Assert.Throws <SharpRfcCallException>(() =>
         {
             var result = conn.ExecuteFunction("Z_SSRT_DIVIDE",
                                               new RfcParameter("i_num1", 5),
                                               new RfcParameter("i_num2", 0)
                                               );
         });
         Assert.Equal("DIVIDE_BY_ZERO", ex.Message);
     }
 }
예제 #19
0
 public void TenTimesTest()
 {
     Parallel.For(1, 10, (int idx) =>
     {
         using (SapRfcConnection conn = this.GetConnection())
         {
             var result = conn.ExecuteFunction("Z_SSRT_SUM",
                                               new RfcParameter("i_num1", 2),
                                               new RfcParameter("i_num2", 4)
                                               );
         }
     });
     Task.WaitAll();
 }
예제 #20
0
        public void ExportSingleParameterTest_WithAnonymousType()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var result = conn.ExecuteFunction("Z_SSRT_SUM", new
                {
                    i_num1 = 2,
                    i_num2 = 7
                });

                var total = result.GetOutput <int>("e_result");
                Assert.Equal(9, total);
            }
        }
예제 #21
0
        public void ReadTwoFieldsTest()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var scarr = conn.Table <AirlineCompany>("SCARR").Select("CARRID", "CARRNAME").Read();
                Assert.Equal(18, scarr.Count());

                var aa = scarr.FirstOrDefault(x => x.Code == "AA");
                Assert.Equal("AA", aa.Code);
                Assert.Equal("American Airlines", aa.Name);
                Assert.Equal(null, aa.Currency);
                Assert.Equal(null, aa.Url);
            }
        }
예제 #22
0
        public void ReadSingleFieldTest()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var scarr = conn.ReadTable <AirlineCompany>("SCARR", fields: new string[] { "CARRID" });
                Assert.Equal(18, scarr.Count());

                var aa = scarr.FirstOrDefault(x => x.Code == "AA");
                Assert.Equal("AA", aa.Code);
                Assert.Equal(null, aa.Name);
                Assert.Equal(null, aa.Currency);
                Assert.Equal(null, aa.Url);
            }
        }
예제 #23
0
        public void ExportStructureTest()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var result = conn.ExecuteFunction("Z_SSRT_GET_CUSTOMER",
                                                  new RfcParameter("i_id", 2)
                                                  );

                var customer = result.GetOutput <ZCustomer>("e_customer");
                Assert.Equal(2, customer.Id);
                Assert.Equal("Walmart", customer.Name);
                Assert.Equal(false, customer.IsActive);
            }
        }
예제 #24
0
        public void WhenChar1IsLastField()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var objects = conn.ReadTable <RepositoryObject>("TADIR",
                                                                fields: new string[] { "OBJ_NAME", "DELFLAG" },
                                                                where : new string[] { "PGMID = 'R3TR'", "AND OBJECT = 'TABL'", "AND OBJ_NAME = 'TADIR'" }
                                                                );

                Assert.Equal(1, objects.Count());
                Assert.Equal("TADIR", objects.ElementAt(0).Name);
                Assert.Equal(false, objects.ElementAt(0).DeletionFlag);
            }
        }
예제 #25
0
        public void StrongTypeNotEqualsConditionTest()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var scarr = conn.Table <AirlineCompany>("SCARR")
                            .Select("CARRID", "CURRCODE")
                            .Where("CARRID", RfcReadTableOption.NotEquals, "DL")
                            .Read();

                foreach (var company in scarr)
                {
                    Assert.NotEqual("DL", company.Code);
                }
            }
        }
예제 #26
0
        public void ExportMultipleParametersTest()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var result = conn.ExecuteFunction("Z_SSRT_DIVIDE",
                                                  new RfcParameter("i_num1", 5),
                                                  new RfcParameter("i_num2", 2)
                                                  );

                var quotient  = result.GetOutput <decimal>("e_quotient");
                var remainder = result.GetOutput <int>("e_remainder");
                Assert.Equal(2.5m, quotient);
                Assert.Equal(1, remainder);
            }
        }
예제 #27
0
        public void ShouldThrowTimeoutException()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                Exception ex = Assert.Throws <SharpRfcCallException>(() =>
                {
                    var result = conn.ExecuteFunction("Z_SSRT_LONG_PROCESS", new
                    {
                        i_seconds = 10
                    });
                });

                Assert.IsType <TimeoutException>(ex.InnerException);
            }
        }
예제 #28
0
 public void CustomExceptionOnInvalidParameter()
 {
     using (SapRfcConnection conn = this.GetConnection())
     {
         Exception ex = Assert.Throws <UnknownRfcParameterException>(() =>
         {
             var result = conn.ExecuteFunction("Z_SSRT_SUM",
                                               new RfcParameter("i_num1", 2),
                                               new RfcParameter("i_num2", 4),
                                               new RfcParameter("i_num3", 4)
                                               );
         });
         Assert.Equal("Parameter I_NUM3 was not found on function Z_SSRT_SUM.", ex.Message);
     }
 }
예제 #29
0
        public void ImportStructureTest()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                var customer = new ZCustomer {
                    Id = 3, Name = "Microsoft", IsActive = true
                };
                var result = conn.ExecuteFunction("Z_SSRT_ADD_CUSTOMER",
                                                  new RfcParameter("i_customer", customer)
                                                  );

                string message = result.GetOutput <string>("e_success");
                Assert.Equal("Created:    3 - Microsoft - X", message);
            }
        }
        public void ExceptionToStringShouldReturnRequestBodyTest()
        {
            using (SapRfcConnection conn = this.GetConnection())
            {
                SharpRfcCallException ex = Assert.Throws <SharpRfcCallException>(() =>
                {
                    var result = conn.ExecuteFunction("Z_SSRT_DIVIDE", new
                    {
                        i_num1 = 2,
                        i_num2 = 0
                    });
                });

                Assert.Contains(this.GetExpectedRequestBody(), ex.ToString());
            }
        }
 public HomeController()
 {
     this.sap = new ProfiledSapRfcConnection(new SoapSapRfcConnection("SAP"), MiniProfiler.Current);
 }
 public ProfiledSapRfcConnection(SapRfcConnection connection, MiniProfiler profiler)
 {
     this.innerConnection = connection;
     this.profiler = profiler;
 }