public void TakeFirstCompanyTest() { using (SapRfcConnection conn = this.GetConnection()) { var scarr = conn.Table <AirlineCompany>("SCARR").Take(1).Read(); Assert.Equal(1, scarr.Count()); } }
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); } }
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); } }
public void ShouldNotThrowTimeoutException() { using (SapRfcConnection conn = this.GetConnection()) { var result = conn.ExecuteFunction("Z_SSRT_LONG_PROCESS", new { i_seconds = 1 }); } }
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); } }
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")); } }
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")); } }
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); } }
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) ); }); } }
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()); } }
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); } }
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); } }
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); } }
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()); } }
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); } }
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(); }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } } }
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); } }
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); } }
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); } }
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; }