public void SourceService_Add_Throws_On_Null_Source() { //Arrange _service = new SourceService(_mockUnitOfWork.Object); //Assert Assert.Throws<ArgumentNullException>(() => _service.Add(null)); }
public void SourceService_Add_Calls_Source_Add_Method_With_The_Same_Source_Object_It_Recieved() { // Create test data var newSource = new Source { Author = "Foo", Title = "Bar" }; //Create Mock var mockRepository = new Mock<IRepository<Source>>(); _mockUnitOfWork.Setup(d => d.GetRepository<Source>()).Returns(mockRepository.Object); //Arrange _service = new SourceService(_mockUnitOfWork.Object); //Act _service.Add(newSource); //Assert mockRepository.Verify(r => r.Add(newSource)); }
public void SourceService_Get_Calls_Source_Get() { //Arrange var mockRepository = new Mock<IRepository<Source>>(); _mockUnitOfWork.Setup(u => u.GetRepository<Source>()).Returns(mockRepository.Object); _service = new SourceService(_mockUnitOfWork.Object); const int id = TestConstants.ID_Exists; //Act _service.Get(id, It.IsAny<int>()); //Assert mockRepository.Verify(r => r.Get(It.IsAny<int>())); }
public void SourceService_Get_Throws_On_Negative_Id() { //Arrange _service = new SourceService(_mockUnitOfWork.Object); //Assert Assert.Throws<IndexOutOfRangeException>(() => _service.Get(-1, It.IsAny<int>())); }
public CardsSearchController(CardService cardService, SourceService sourceService) { _cardService = cardService; _sourceService = sourceService; }
public void SourceService_Update_Calls_UnitOfWork_Commit_Method() { // Create test data var individual = new Source { Id = TestConstants.ID_Exists, Author = "Foo", Title = "Bar" }; //Create Mock var mockRepository = new Mock<IRepository<Source>>(); _mockUnitOfWork.Setup(d => d.GetRepository<Source>()).Returns(mockRepository.Object); //Arrange _service = new SourceService(_mockUnitOfWork.Object); //Act _service.Update(individual); //Assert _mockUnitOfWork.Verify(db => db.Commit()); }
public void SourceService_Get_ByPage_Overload_Returns_PagedList_Of_Sources() { //Arrange var mockRepository = new Mock<IRepository<Source>>(); mockRepository.Setup(r => r.Get(It.IsAny<int>())).Returns(GetSources(TestConstants.PAGE_TotalCount)); _mockUnitOfWork.Setup(u => u.GetRepository<Source>()).Returns(mockRepository.Object); _service = new SourceService(_mockUnitOfWork.Object); const int treeId = TestConstants.TREE_Id; //Act var sources = _service.Get(treeId, t => true, 0, TestConstants.PAGE_RecordCount); //Assert Assert.IsInstanceOf<IPagedList<Source>>(sources); Assert.AreEqual(TestConstants.PAGE_TotalCount, sources.TotalCount); Assert.AreEqual(TestConstants.PAGE_RecordCount, sources.PageSize); }
public void SourceService_Get_ByPage_Overload_Throws_On_Negative_TreeId() { //Arrange _service = new SourceService(_mockUnitOfWork.Object); //Assert Assert.Throws<IndexOutOfRangeException>(() => _service.Get(-1, t => true, 0, TestConstants.PAGE_RecordCount)); }
/// <summary> /// Creates a new source controller. /// </summary> /// <param name="sourceService">The source service.</param> public SourceController(SourceService sourceService) => _sourceService = sourceService;
internal void SetPeopleWhoLikeThisIds(IEnumerable <FacebookObjectId> likerIds) { // Should only be set during initialization Assert.IsNull(_mergeableLikers); _mergeableLikers = new FBMergeableCollection <FacebookContact>(from uid in likerIds select SourceService.GetUser(uid), false); }
public string GetHowToWatch(string query, long userId) { var response = SourceService.Query(query); return(Parse(query, userId, response)); }
public SourcesController(SourceService service) { Service = service; }
public SourceServiceTest(MockHttpClientFixture mockHttpClientFixture) : base(mockHttpClientFixture) { this.service = new SourceService(); this.attachOptions = new SourceAttachOptions { Source = SourceId, }; this.createOptions = new SourceCreateOptions { Type = SourceType.AchCreditTransfer, Currency = "usd", Mandate = new SourceMandateOptions { Acceptance = new SourceMandateAcceptanceOptions { Date = DateTime.Parse("Mon, 01 Jan 2001 00:00:00Z"), Ip = "127.0.0.1", NotificationMethod = "manual", Status = "accepted", UserAgent = "User-Agent", }, }, Owner = new SourceOwnerOptions { Address = new AddressOptions { State = "CA", City = "City", Line1 = "Line1", Line2 = "Line2", PostalCode = "90210", Country = "US", }, Email = "*****@*****.**", Name = "Owner Name", Phone = "5555555555", }, Receiver = new SourceReceiverOptions { RefundAttributesMethod = "manual", }, }; this.listOptions = new SourceListOptions { Limit = 1, }; this.updateOptions = new SourceUpdateOptions { Metadata = new Dictionary <string, string> { { "key", "value" }, }, }; this.verifyOptions = new SourceVerifyOptions { Values = new List <string> { "32", "45" }, }; }
private void GetAllSources() { var all = new SourceService(new SourceRepository()).GetAll(); Sources = new ObservableCollection <Source>(all); }
public void SourceService_Get_Returns_Null_On_InValid_Id() { //Arrange var mockRepository = new Mock<IRepository<Source>>(); mockRepository.Setup(r => r.Get(It.IsAny<int>())).Returns(GetSources(TestConstants.PAGE_NotFound)); _mockUnitOfWork.Setup(u => u.GetRepository<Source>()).Returns(mockRepository.Object); _service = new SourceService(_mockUnitOfWork.Object); const int id = TestConstants.ID_NotFound; //Act var individual = _service.Get(id, It.IsAny<int>()); //Assert Assert.IsNull(individual); }
public void SourceService_Get_Overload_Throws_On_Negative_TreeId() { //Arrange _service = new SourceService(_mockUnitOfWork.Object); //Assert Assert.Throws<IndexOutOfRangeException>(() => _service.Get(-1)); }
public static void Main(string[] args) { SourceService sourceService = new SourceService("http://*****:*****@WebFault."); } catch (SoapException e) { //fall through } relationshipService.Touch(); AssertionService assertionService = new AssertionService("http://localhost:8080/full/AssertionServiceService"); Assertion[] assertions = assertionService.ReadAssertions(); Assertion gender = assertions[0]; Assert.AreEqual("gender", gender.Id); Assert.IsTrue(gender is Gender); Assertion name = assertions[1]; Assert.AreEqual("name", name.Id); Assert.IsTrue(name is Name); }
public void SourceService_Get_ByPage_Overload_Calls_Repository_Get() { //Arrange var mockRepository = new Mock<IRepository<Source>>(); _mockUnitOfWork.Setup(u => u.GetRepository<Source>()).Returns(mockRepository.Object); _service = new SourceService(_mockUnitOfWork.Object); const int treeId = TestConstants.TREE_Id; //Act _service.Get(treeId, t => true, 0, TestConstants.PAGE_RecordCount); //Assert mockRepository.Verify(r => r.Get(It.IsAny<int>())); }
public bool Pay( string CardNo, int ExpiredYear, int ExpiredMonth, string CVV, decimal amount, string currency, string receiptEmail = "", string description = "") { try { TokenCreateOptions stripeCard = new TokenCreateOptions { Card = new TokenCardOptions { Number = CardNo, ExpMonth = Convert.ToInt64(ExpiredMonth), ExpYear = Convert.ToInt64(ExpiredYear), Cvc = CVV, }, }; TokenService service = new TokenService(); Token newToken = service.Create(stripeCard); var cardOption = new SourceCreateOptions { Type = SourceType.Card, Currency = currency, Token = newToken.Id }; var sourceService = new SourceService(); Source source = sourceService.Create(cardOption); /* * CustomerCreateOptions customerInfo = new CustomerCreateOptions * { * Name = "SP Tutorial", * Email = stripeEmail, * Description = "Paying 10 Rs", * Address = new AddressOptions { * City = "Kolkata", * Country = "India", * Line1 = "Sample Address", * Line2 = "Sample Address 2", * PostalCode = "700030", * State = "WB" * } * }; * * //var customerService = new CustomerService(); * //var customer = customerService.Create(customerInfo); */ var chargeoption = new ChargeCreateOptions { Amount = Convert.ToInt32(amount * 100), Currency = currency, Description = description, ReceiptEmail = receiptEmail, Source = source.Id }; var chargeService = new ChargeService(); Charge charge = chargeService.Create(chargeoption); if (charge.Status == "succeeded") { return(true); } else { return(false); } } catch (Exception e) { Console.WriteLine(e); return(false); } }
public void SourceService_Update_Calls_Source_Update_Method_With_The_Same_Source_Object_It_Recieved() { // Create test data var individual = new Source { Id = TestConstants.ID_Exists, Author = "Foo", Title = "Bar" }; //Create Mock var mockRepository = new Mock<IRepository<Source>>(); _mockUnitOfWork.Setup(d => d.GetRepository<Source>()).Returns(mockRepository.Object); //Arrange _service = new SourceService(_mockUnitOfWork.Object); //Act _service.Update(individual); //Assert mockRepository.Verify(r => r.Update(individual)); }
public PaymentView(DateTime bookingDate, string centerName, string sportName, string courtName, string startingBookingTime, string endingBookingTime, double TotalPaymentAmount) { InitializeComponent(); //startingBookingTime AND endingBookingTime are TimeSpan not DateTime ...... Done var uname = Preferences.Get("UserName", String.Empty); if (String.IsNullOrEmpty(uname)) { username.Text = "Guest"; } else { username.Text = uname; } centername.Text = centerName; courtname.Text = courtName; //bookingdate.Text = bookingDate.Date.ToString(); cvm = new PaymentViewModel(bookingDate); this.BindingContext = cvm; bookingtime.Text = startingBookingTime.ToString() + " - " + endingBookingTime.ToString(); double RoundedTotalPaymentAmount = Math.Round(TotalPaymentAmount, 1, MidpointRounding.ToEven); totalpaymentamount.Text = "RM " + RoundedTotalPaymentAmount.ToString(); string totalp = totalpaymentamount.Text; DateTime s = Convert.ToDateTime(startingBookingTime); DateTime d = Convert.ToDateTime(endingBookingTime); NewEventHandler.Clicked += async(sender, args) => { // if check payment from Moustafa is true, then add booking to firebase try { //StripeConfiguration.SetApiKey("sk_test_51IpayhGP2IgUXM55te5JbGRu14MOp6AU6GORVFhqpOilEOp96ERDzKCi1VN9rDLrOmOEwNPqgOvQuIyaNg8YKfkL00Qoq8a7QX"); StripeConfiguration.SetApiKey("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"); //This are the sample test data use MVVM bindings to send data to the ViewModel Stripe.TokenCardOptions stripcard = new Stripe.TokenCardOptions(); stripcard.Number = cardnumber.Text; stripcard.ExpYear = Int64.Parse(expiryYear.Text); stripcard.ExpMonth = Int64.Parse(expirymonth.Text); stripcard.Cvc = cvv.Text; //stripcard.Cvc = Int64.Parse(cvv.Text); //Step 1 : Assign Card to Token Object and create Token Stripe.TokenCreateOptions token = new Stripe.TokenCreateOptions(); token.Card = stripcard; Stripe.TokenService serviceToken = new Stripe.TokenService(); Stripe.Token newToken = serviceToken.Create(token); // Step 2 : Assign Token to the Source var options = new SourceCreateOptions { Type = SourceType.Card, Currency = "myr", Token = newToken.Id }; var service = new SourceService(); Source source = service.Create(options); //Step 3 : Now generate the customer who is doing the payment Stripe.CustomerCreateOptions myCustomer = new Stripe.CustomerCreateOptions() { Name = "Moustafa", Email = "*****@*****.**", Description = "Customer for [email protected]", }; var customerService = new Stripe.CustomerService(); Stripe.Customer stripeCustomer = customerService.Create(myCustomer); mycustomer = stripeCustomer.Id; // Not needed //Step 4 : Now Create Charge Options for the customer. var chargeoptions = new Stripe.ChargeCreateOptions { //Amount = (Int64.Parse(RoundedTotalPaymentAmount)) * 100, //(int(RoundedTotalPaymentAmount)) //Amount = Convert.ToInt32(RoundedTotalPaymentAmount) * 100, //Amount = (long?)(double.Parse(RoundedTotalPaymentAmount) * 100), Amount = (long?)(double.Parse(totalp) * 100), Currency = "MYR", ReceiptEmail = "*****@*****.**", Customer = stripeCustomer.Id, Source = source.Id }; //Step 5 : Perform the payment by Charging the customer with the payment. var service1 = new Stripe.ChargeService(); Stripe.Charge charge = service1.Create(chargeoptions); // This will do the Payment getchargedID = charge.Id; // Not needed } catch (Exception ex) { UserDialogs.Instance.Alert(ex.Message, null, "ok"); Console.Write("error" + ex.Message); //await Application.Current.MainPage.DisplayAlert("error ", ex.Message, "OK"); } finally { //if (getchargedID != null) if (getchargedID != null) { var acd = new AddBookingData(sportName, courtName, username.Text, centerName, s, d, bookingDate, RoundedTotalPaymentAmount); await acd.AddBookingDataAsync(); UserDialogs.Instance.Alert("Payment Successed", "Success", "Ok"); Xamarin.Forms.Application.Current.MainPage = new MainTabbedView(); //await Application.Current.MainPage.DisplayAlert("Payment Successed ", "Success", "OK"); } else { UserDialogs.Instance.Alert("Something Wrong", "Faild", "OK"); //await Application.Current.MainPage.DisplayAlert("Payment Error ", "faild", "OK"); } } /* * var acd = new AddBookingData(sportName, courtName, username.Text, centerName, s, d, bookingDate, RoundedTotalPaymentAmount); * await acd.AddBookingDataAsync(); * /* * * * //Application.Current.MainPage = new MainTabbedView(); * * //await Navigation.PopModalAsync(); * //await Navigation.PopToRootAsync(); * /* * Navigation.InsertPageBefore(new NewPage(), Navigation.NavigationStack[0]); * await Navigation.PopToRootAsync(); */ }; /* * public void GetCustomerInformationID(object sender, EventArgs e) * { * var service = new CustomerService(); * var customer = service.Get(mycustomer); * var serializedCustomer = JsonConvert.SerializeObject(customer); * // var UserDetails = JsonConvert.DeserializeObject<CustomerRetriveModel>(serializedCustomer); * * } * * * public void GetAllCustomerInformation(object sender, EventArgs e) * { * var service = new CustomerService(); * var options = new CustomerListOptions * { * Limit = 3, * }; * var customers = service.List(options); * var serializedCustomer = JsonConvert.SerializeObject(customers); * } * * * public void GetRefundForSpecificTransaction(object sender, EventArgs e) * { * var refundService = new RefundService(); * var refundOptions = new RefundCreateOptions * { * Charge = getchargedID, * }; * Refund refund = refundService.Create(refundOptions); * refundID = refund.Id; * } * * * public void GetRefundInformation(object sender, EventArgs e) * { * var service = new RefundService(); * var refund = service.Get(refundID); * var serializedCustomer = JsonConvert.SerializeObject(refund); * * } */ /* * * async Task NewEventHandler(object sender, EventArgs e) * { * // if check payment from Moustafa is true, then * * // add booking to firebase * * var acd = new AddBookingData(sportName, courtName, username.Text, centerName, s, d, bookingDate, TotalPaymentAmount); * await acd.AddBookingDataAsync(); * } */ }
private TN MapInternal <T, TN>(T src, TN dest = default(TN), bool dynamicTrial = false) { var srcType = typeof(T); var destType = typeof(TN); var cacheKey = CalculateCacheKey(srcType, destType); if (CustomMappers.ContainsKey(cacheKey)) { var customTypeMapper = CustomMappers[cacheKey]; var typeMapper = customTypeMapper() as ICustomTypeMapper <T, TN>; var context = new DefaultMappingContext <T, TN> { Source = src, Destination = dest }; return(typeMapper.Map(context)); } var mappingService = EqualityComparer <TN> .Default.Equals(dest, default(TN)) ? SourceService : DestinationService; if (mappingService.TypeMappers.ContainsKey(cacheKey)) { if (EqualityComparer <T> .Default.Equals(src, default(T))) { return(default(TN)); } var mapper = mappingService.TypeMappers[cacheKey] as ITypeMapper <T, TN>; return(mapper != null ? mapper.MapTo(src, dest) : default(TN)); } var tCol = typeof(T).GetInterfaces() .FirstOrDefault(t => t.IsGenericType && t.GetGenericTypeDefinition() == GenericEnumerableType) ?? (typeof(T).IsGenericType && typeof(T).GetInterfaces().Any(t => t == typeof(IEnumerable)) ? typeof(T) : null); var tnCol = typeof(TN).GetInterfaces() .FirstOrDefault(t => t.IsGenericType && t.GetGenericTypeDefinition() == GenericEnumerableType) ?? (typeof(TN).IsGenericType && typeof(TN).GetInterfaces().Any(t => t == typeof(IEnumerable)) ? typeof(TN) : null); if ((tCol == null || tnCol == null)) { if (dynamicTrial) { throw new MapNotImplementedException( string.Format("There is no mapping has bee found. Source Type: {0}, Destination Type: {1}", srcType.FullName, destType.FullName)); } Register <T, TN>(); return(MapInternal <T, TN>(src, dest, true)); } PrecompileCollection <T, TN>(); // todo: make same signature in both compiled funcs with destination var result = (TN)(((EqualityComparer <TN> .Default.Equals(dest, default(TN))) ? SourceService.MapCollection(cacheKey).DynamicInvoke(src) : DestinationService.MapCollection(cacheKey).DynamicInvoke(src, dest))); return(result); }
public static void Main(string[] args) { SourceService sourceService = new SourceService("http://*****:*****@WebFault."); } catch (SoapException e) { //fall through } relationshipService.Touch(); AssertionService assertionService = new AssertionService("http://localhost:8080/full/AssertionServiceService"); Assertion[] assertions = assertionService.ReadAssertions(); Assertion gender = assertions[0]; Assert.AreEqual("gender",gender.Id); Assert.IsTrue(gender is Gender); Assertion name = assertions[1]; Assert.AreEqual("name",name.Id); Assert.IsTrue(name is Name); }
public void SourceService_Add_Calls_UnitOfWork_Commit_Method() { // Create test data var newSource = new Source { Author = "Foo", Title = "Bar" }; //Create Mock var mockRepository = new Mock<IRepository<Source>>(); _mockUnitOfWork.Setup(d => d.GetRepository<Source>()).Returns(mockRepository.Object); //Arrange _service = new SourceService(_mockUnitOfWork.Object); //Act _service.Add(newSource); //Assert _mockUnitOfWork.Verify(db => db.Commit()); }
public SourceController(ILogger <SourceController> logger, SourceService sourceService) { _logger = logger; _sourceService = sourceService; }