public async Task AssertAddSubscriptionCallsRepoAsync() { var subscription = new Subscription { TopicID = subTopicId, AccountID = subAccountId }; //Given var ar = new ActionResult <Topic>() { resposeObject = new Topic(), statusCode = HttpStatusCode.OK }; _mockTopicRepo.Setup(m => m.GetTopic(subTopicId)).Returns(Task.FromResult(ar)); var ar2 = new ActionResult <Subscription>() { resposeObject = subscription, statusCode = HttpStatusCode.Created }; _mockSubRepo.Setup(m => m.AddSubscription(It.IsAny <Subscription>())).Returns(Task.FromResult(ar2)); //When var result = await _subscriptionService.CreateSubscription(subAccountId, subTopicId, string.Empty); //Then _mockTopicRepo.Verify(m => m.GetTopic(subTopicId)); _mockSubRepo.Verify(m => m.GetSubscriptionByTopic(subTopicId, subAccountId, string.Empty)); _mockSubRepo.Verify(m => m.AddSubscription(It.IsAny <Subscription>())); Assert.Equal(subTopicId, result.resposeObject.TopicID); Assert.Equal(subAccountId, result.resposeObject.AccountID); }
public IEnumerable <Subscription> CreateSubscription(Subscription subscription) { var tmpId = _subscriptionService.GetAll().Last().Id; subscription.Id = tmpId + 1; return(_subscriptionService.CreateSubscription(subscription)); }
public void Given_A_Subscription_Exists_When_I_Call_TopicExists_Then_True_Is_Returned() { //arrange var configurationHelper = new ConfigurationHelper(); _subscriptionId = $"{configurationHelper.SubscriptionId}-{Guid.NewGuid()}"; _sut.CreateSubscription(_projectId, _topicId, _subscriptionId, _ackTimeoutInSeconds); //act var result = _sut.SubscriptionExists(_projectId, _subscriptionId); //assert Assert.IsNotNull(result); Assert.IsInstanceOf <bool>(result); Assert.IsTrue(result); }
public void Setup() { var configurationHelper = new ConfigurationHelper(); _projectId = configurationHelper.ProjectId; _topicId = $"{configurationHelper.TopicId}-{Guid.NewGuid()}"; _subscription1Id = $"{configurationHelper.SubscriptionId}-{Guid.NewGuid()}"; _subscription2Id = $"{configurationHelper.SubscriptionId}-{Guid.NewGuid()}"; _ackTimeoutInSeconds = 60; _topicService = new TopicService(); _subscriptionService = new SubscriptionService(); _publisherService = new PublisherService(); _topicService.CreateTopic(_projectId, _topicId); _subscriptionService.CreateSubscription(_projectId, _topicId, _subscription1Id, _ackTimeoutInSeconds); _subscriptionService.CreateSubscription(_projectId, _topicId, _subscription2Id, _ackTimeoutInSeconds); }
public bool AddOrUpdateSubscription(eSubscription sub, SaleListingDTO salelistingviewmodel) { try { SaleListing salelisting = _saleListingRepository.GetSaleListing(salelistingviewmodel.ID); Subscription subscription = _subscriptionService.CreateSubscription(sub); _saleListingRepository.UpdateSaleListingSubscription(salelisting, subscription); //_log.LogSaleListing(salelisting.Owner.ID, salelisting.ID, eLogSaleListingType.Update); return(true); } catch (Exception ex) { return(false); } }
public string CreateSubscription(ClientDetailsModel model) { var token = TokenService.GetToken(); if (!String.IsNullOrWhiteSpace(token)) { try { string responseMessage = SubscriptionService.CreateSubscription(model.SalesId, model.ClientId, token, model.CellPhone, model.CampaignName); return(responseMessage); } catch (Exception ex) { evLogger.LogEvent("Something went while creating subscription." + ex.Message + "\n" + ex.StackTrace, System.Diagnostics.EventLogEntryType.Error); } } return("Something went wrong creating subscription."); }
private async Task OnSaveCommandExecute() { if (IsBusy) { return; } IsBusy = true; try { Int64 orderId = await IdService.CreateOrderIdAsync(); User user = await UserService.GetUserAsync(Helpers.DeviceHelper.GetMunchyId()); Card card = await CreditCardService.CreateCreditCard(); card = await CreditCardService.AuthorizeCreditCard(card.id.ToString(), "1000000000000008", "2112", 123); Subscription subscription = await SubscriptionService.CreateSubscription(orderId); CardDetails cardDetails = await CreditCardService.CreateCreditCardToken(card.id.ToString()); Subscription authSub = await SubscriptionService.AuthorizeSubscription(subscription.id.ToString(), 1000, cardDetails.token); authSub = await SubscriptionService.GetSubscription(authSub.id.ToString()); if (authSub.accepted) { SimpleCreditCard creditCard = new SimpleCreditCard(card.metadata.brand.ToString(), card.metadata.exp_year.ToString(), card.metadata.exp_month.ToString(), "XXXX XXXX XXXX " + card.metadata.last4); await this.UserService.CreateUserCreditCard(user.Id, creditCard); await Application.Current.MainPage.Navigation.PushAsync(new CreatePaymentAuthenticationPage(authSub.id.ToString())); } } catch (Exception e) { await Application.Current.MainPage.DisplayAlert("Fejl!", e.ToString(), "OK"); } finally { IsBusy = false; } }
public void Setup() { _messageHandler = new TestMessageHandler(); _topicService = new TopicService(); _subscriptionService = new SubscriptionService(); var configurationHelper = new ConfigurationHelper(); _projectId = configurationHelper.ProjectId; _topicId = $"{configurationHelper.TopicId}-{Guid.NewGuid()}"; _subscriptionId = $"{configurationHelper.SubscriptionId}-{Guid.NewGuid()}"; _ackTimeoutInSeconds = 60; _topicService.CreateTopic(_projectId, _topicId); _subscriptionService.CreateSubscription(_projectId, _topicId, _subscriptionId, _ackTimeoutInSeconds); _sut = new FluentQueueApi(); }
public void Given_A_Message_When_I_Call_PublishMessage_Then_The_Message_Is_Published() { //arrange var message = $"Hello, world {Guid.NewGuid()}"; _topicService.CreateTopic(_projectId, _topicId); _subscriptionService.CreateSubscription(_projectId, _topicId, _subscriptionId, _ackTimeoutInSeconds); //act _sut .WithProject(_projectId) .WithTopic(_topicId) .Publish(message); var result = _messageHelper.GetMessage(_projectId, _subscriptionId); //assert Assert.IsNotNull(result); Assert.AreEqual(message, result); }
private void CreateDeadletterTopicAndSubscription() { _topicService.CreateTopic(_projectId, _deadLetterTopicId); _subscriptionService.CreateSubscription(_projectId, _deadLetterTopicId, _deadLetterSubscriptionId, 600); }