Пример #1
0
        public void GetCoinPriceByCoinCodeTest()
        {
            //Setup
            var handlerMock = new Mock <HttpMessageHandler>();
            var response    = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(ApiData.Payload),
            };

            handlerMock
            .Protected()
            .Setup <Task <HttpResponseMessage> >(
                "SendAsync",
                ItExpr.IsAny <HttpRequestMessage>(),
                ItExpr.IsAny <CancellationToken>())
            .ReturnsAsync(response);
            var httpClient = new HttpClient(handlerMock.Object)
            {
                BaseAddress = new Uri(Constants.ApiUrl),
            };
            var loggerMock = new Mock <ILogger <IQuotesRepository> >();

            var repo = new QuotesRepository(loggerMock.Object, httpClient);

            //Act
            var result = repo.GetCoinPriceByCoinCode("BTC");

            //Assert
            Assert.AreEqual(result.IsCompletedSuccessfully, true);
        }
Пример #2
0
 public UnitOfWork(GalleryAppContext context)
 {
     this.context = context;
     Arts         = new ArtRepository(context);
     Artists      = new ArtistRepository(context);
     Categories   = new CategoryRepository(context);
     Contacts     = new ContactRepository(context);
     Quotes       = new QuotesRepository(context);
 }
        public QuoteDetailPageViewModel(INavigationService navigationService,
                                        QuotesRepository quotesRepository
                                        )
            : base(navigationService)
        {
            _quotesRepository = quotesRepository;

            Title = "Author Quotes";
        }
Пример #4
0
 public void Activate()
 {
     _profileRepository         = new ProfileRepository();
     _materialsRepository       = new MaterialsRepository();
     _servicesRepository        = new ServicesRepository();
     _serviceMaterialRepository = new ServiceMaterialsRepository();
     _quotesRepository          = new QuotesRepository();
     _customersRepository       = new CustomersRepository();
 }
Пример #5
0
 public void Activate()
 {
     _profileRepository = new ProfileRepository();
     _materialsRepository = new MaterialsRepository();
     _servicesRepository = new ServicesRepository();
     _serviceMaterialRepository = new ServiceMaterialsRepository();
     _quotesRepository = new QuotesRepository();
     _customersRepository = new CustomersRepository();
 }
        public QuoteDetailPageViewModel(INavigationService navigationService,
                                        IEventAggregator eventAggregator,
                                        QuotesRepository quotesRepository
                                        ) : base(navigationService, eventAggregator)
        {
            _quotesRepository = quotesRepository;
            Title             = "Author Quotes";

            NavigateCommand = new DelegateCommand(NavigateToClickPageView);
        }
        public static void AddBookToQuote()
        {
            var   bookRepo  = new BooksRepository();
            var   quoteRepo = new QuotesRepository();
            Book  book      = bookRepo.FindBy(b => b.Title.StartsWith("Haparanda")).FirstOrDefault();
            Quote quote     = quoteRepo.FindBy(q => q.Id == 5).FirstOrDefault();

            quote.FromBook = book;
            Console.WriteLine(quote.Text + " " + quote.FromBook.Title);
            Console.ReadKey();
        }
        private IQuotesManager SetupStubbedQuotesManager()
        {
            var builder        = new DbContextOptionsBuilder <AppDbContext>().UseSqlite(_connection);
            var appDataContext = new AppDbContext(builder.Options);

            appDataContext.Database.EnsureDeleted();
            appDataContext.Database.EnsureCreated();

            var repository = new QuotesRepository(appDataContext);

            return(new QuotesManager(repository, null));
        }
Пример #9
0
        public void GetQuotesReturnsAllQuotes()
        {
            // Arrange
            var sut = new QuotesRepository();

            // Act
            var result = sut.GetQuotes();

            // Assert
            var list = result.ToList();

            Assert.True(list.Count > 0);
        }
Пример #10
0
        public static void Update()
        {
            var quoteRepo = new QuotesRepository();
            var quotes    = quoteRepo.FindBy(q => q.Text.StartsWith("When you see you are blind")).ToList();

            foreach (var quote in quotes)
            {
                Console.WriteLine(quote.Text);
                quote.Text = "When you can't see you are blind";
                quoteRepo.Update(quote);
                quoteRepo.Save();
                Console.WriteLine("\tNew Quote: " + quote.Text);
            }
        }
        public QuoteMasterPageViewModel(
            INavigationService navigationService,
            IEventAggregator eventAggregator,
            QuotesRepository quotesRepository
            )
            : base(navigationService)
        {
            _quotesRepository = quotesRepository;
            _eventAggregator  = eventAggregator;

            Title                = "Quotes";
            ItemClicked          = new DelegateCommand <Quote>(DoItemClicked);
            NavigateMenuPageView = new DelegateCommand(NavigateToMenuPageView);
            GetRandomQuotes();
        }
Пример #12
0
        public static void AddMany()
        {
            var quoteRepo = new QuotesRepository();

            quoteRepo.AddRange(new List <Quote> {
                new Quote {
                    Text = "When you see you are blind", BookId = 18
                },
                new Quote {
                    Text = "When you see you are blind", BookId = 19
                },
                new Quote {
                    Text = "Äre nån i stuga?", BookId = 10
                }
            });
            quoteRepo.Save();
        }
Пример #13
0
        //[HttpPost]
        public ActionResult EditChildEntity(PlayVM model)
        {
            QuotesRepository qRepo = new QuotesRepository();
            Quote            quote = qRepo.GetById(model.quote.Id, "Author");

            model.UserQuotesEditVM.Score = CheckAnswer(model.UserQuotesEditVM.SelectedAnswer, quote.Author.Name, model.authors[0].Name);

            bool result = model.UserQuotesEditVM.Score;

            model.msg        = GenerateMsg(result, quote.Author.Name);
            model.quote.Text = quote.Text;
            KeepTrackOfPlayedGames(quote);

            if (AuthenticationManager.LoggedUser != null)
            {
                SaveUserQuote(model, quote);
            }

            return(View("Play", model));
        }
Пример #14
0
        private Quote ChooseQuote()
        {
            QuotesRepository qRepo = new QuotesRepository();
            int count = qRepo.Count(null);
            Expression <Func <Quote, bool> > Filter = null;

            if (Session["PlayedGames"] != null)
            {
                List <int> PlayedGames = (List <int>)Session["PlayedGames"];

                if (PlayedGames.Count >= count)
                {
                    return(null);
                }

                Filter = x => !PlayedGames.Contains(x.Id);
            }
            Func <IQueryable <Quote>, IOrderedQueryable <Quote> > order = u => u.OrderBy(r => Guid.NewGuid());

            return(qRepo.GetAll(Filter, 1, 1, order, "Author").FirstOrDefault());
        }
Пример #15
0
 public QuotesService(QuotesRepository repo)
 {
     _repo = repo;
 }
Пример #16
0
 public QuotesController(QuotesRepository quotes)
 {
     Quotes = quotes;
 }
Пример #17
0
        public void Send_email_over_9_pallets(ref QuoteData quoteData, ref int newLogId)
        {
            try
            {
                if (quoteData.totalUnits > 9)
                {
                    #region Accessorials

                    string accessorials_email = "";
                    if (quoteData.AccessorialsObj.RESPU)
                    {
                        accessorials_email += "Residential Pickup,";
                    }
                    if (quoteData.AccessorialsObj.RESDEL)
                    {
                        accessorials_email += "Residential Delivery,";
                    }
                    if (quoteData.AccessorialsObj.LGPU)
                    {
                        accessorials_email += "Liftgate Pickup,";
                    }
                    if (quoteData.AccessorialsObj.LGDEL)
                    {
                        accessorials_email += "Liftgate Delivery,";
                    }
                    if (quoteData.AccessorialsObj.CONPU)
                    {
                        accessorials_email += "Construction Pickup,";
                    }
                    if (quoteData.AccessorialsObj.CONDEL)
                    {
                        accessorials_email += "Construction Delivery,";
                    }
                    if (quoteData.AccessorialsObj.INSDEL)
                    {
                        accessorials_email += "Inside Delivery,";
                    }
                    if (quoteData.AccessorialsObj.APTPU)
                    {
                        accessorials_email += "Appointment Pickup,";
                    }
                    if (quoteData.AccessorialsObj.APTDEL)
                    {
                        accessorials_email += "Appointment Delivery";
                    }

                    #endregion

                    var repo           = new QuotesRepository();
                    var quote_carriers = new List <AES_API_info>();
                    repo.Get_carriers_by_QuoteID(newLogId.ToString(), out quote_carriers);

                    StringBuilder sb_carriers = new StringBuilder();
                    GetEmailText(ref sb_carriers, ref quote_carriers);

                    StringBuilder sb_ship_info = new StringBuilder();
                    Get_shipment_info_EmailText(ref sb_ship_info, ref quoteData, ref accessorials_email);

                    // Send email
                    EmailInfo email_info = new EmailInfo();
                    email_info.subject = string.Concat("Genera Volume quote ", quoteData.origZip, " to ", quoteData.destZip);

                    email_info.to          = AppCodeConstants.BobsEmail;
                    email_info.bcc         = AppCodeConstants.Alex_email;
                    email_info.fromAddress = AppCodeConstants.Alex_email;

                    email_info.body =
                        string.Concat(
                            //quoteData.origCity, ", ", quoteData.origState, "/",
                            //quoteData.destCity, ", ", quoteData.destState,
                            sb_ship_info,
                            //" total units: ", quoteData.totalUnits,
                            //", total weight: ", quoteData.totalWeight, " ", accessorials_email,

                            "<br><br><br>", sb_carriers);
                    email_info.fromName = "Genera Booking";

                    Mail mail = new Mail(ref email_info);
                    mail.SendEmail();
                }
            }
            catch (Exception e)
            {
                DB.LogGenera("LTL_Carriers", "Send_email_over_9_pallets", e.ToString());
            }
        }