public void TestRealVolumeDiff() { CsvDataSource csvDataSource = new CsvDataSource(); CsvOptions csvOptions = (CsvOptions)csvDataSource.GetDefaultOptions(); csvOptions.FileName = Path.Combine(TestDir, "depthvalues.csv"); csvOptions.GridStep = "200 m"; csvOptions.Separator = " "; DefaultTriangulation triangulation = new DefaultTriangulation(); SourceSurface surfaceTop = csvDataSource.GetSurface(csvOptions); var triangulatedSurfaceTop = triangulation.GetTriangulatedSurface(surfaceTop, triangulation.GetDefaultOptions()); SourceSurfaceMover mover = new SourceSurfaceMover(); var moverOptions = (SourceSurfaceMoverOptions)mover.GetDefaultOptions(); moverOptions.Z = "100 m"; SourceSurface surfaceBottom = mover.GetModifiedSurface(surfaceTop, moverOptions); var triangulatedSurfaceBottom = triangulation.GetTriangulatedSurface(surfaceBottom, triangulation.GetDefaultOptions()); IVolumeService service = new VolumeService(); var topVolume = service.GetVolumeUnderSurface(triangulatedSurfaceTop, 10000); var bottomVolume = service.GetVolumeUnderSurface(triangulatedSurfaceBottom, 10000); var diff = (int)(topVolume - bottomVolume); Assert.AreEqual(200 * 200 * 100 * 15 * 25, diff); }
public FormCitationSelector(ModelsForViewing vm, VolumeService volumeService, ICategoryService categoryService, CitationDeleterService citationDeleterService ) : this() { VM = vm; m_CategoryService = categoryService; m_CitationDeleterService = citationDeleterService; m_VolumeService = volumeService; if (!m_VolumeService.Citations.Any()) { return; } SelectedCitation = vm.CurrentCitation ?? m_VolumeService.Citations.FirstOrDefault(); LoadCitations(); dataGridView1.DataSource = m_FilteredCitations; UpdateCount(); if (!SelectRowById(SelectedCitation.Id)) { SelectRow(0); } }
public Form_Outline(VolumeService volumeService, Id currentCitation, int left, int top, int width, int height) { InitializeComponent(); Left = left; Top = top; Width = width; Height = height; if (m_DBService == null) { Mef.Compose(this); } References = m_VolumeService.GetAllReferences(); CitationReferences = CreateCitationReferenceList(References, m_VolumeService.Citations); listBox1.DrawItem += ListBox1_DrawItem; listBox1.MeasureItem += ListBox1_MeasureItem; listBox1.DataSource = CitationReferencesFiltered; CitationReference sel = CitationReferences.SingleOrDefault(x => x.Citation?.Id == currentCitation); if (sel != null) { listBox1.SelectedItem = sel; } }
public MainWindowVm() { _micService = MicService.GetInstance(); _micService.AmplitudeChanged += OnAmplitudeChanged; _micService.MicUp += OnMicUp; _micService.MicDown += OnMicDown; _volService = VolumeService.GetInstance(); }
public async void CanSearchByAuthor() { // Arrange var service = new VolumeService(); // Act var searchResult = await service.SearchByAuthorAsync("Isaac Asimov"); // Assert Assert.NotNull(searchResult); Assert.NotEqual(0, searchResult.TotalItems); Assert.Equal("Isaac Asimov", searchResult.Items.First().VolumeInfo.Authors.First()); }
public async void CanGetMoreThan40Books() { // Arrange var service = new VolumeService(); const int maxBooks = 120; // Act var searchResult = await service.SearchByAuthorAsync("Terry Pratchett", maxBooks); // Assert Assert.NotNull(searchResult); Assert.NotEqual(0, searchResult.TotalItems); Assert.InRange(searchResult.Items.Count(), 41, maxBooks); }
private List <Category> GenerateCategories() { var categories = new List <Category>(); foreach (var item in VolumeService.GetCategories()) { categories.Add(new Category() { Name = item }); } return(categories); }
private List <Publisher> GeneratePublishers() { var publishers = new List <Publisher>(); foreach (var item in VolumeService.GetPublishers()) { publishers.Add(new Publisher() { Name = item }); } return(publishers); }
public RuneLiteAPI() { services = new ServiceManager <IService>(); CacheService cacheService = new CacheService(); cacheService.AddCache <MemoryCache>().AddCache <FileCache>(); services.Register(cacheService); LatestPriceService = new LatestPriceService(services); Last5MinutePriceService = new Last5MinutePriceService(services); MappingService = new MappingService(services); VolumeService = new VolumeService(services); }
public void TestVolumes() { IVolumeService service = new VolumeService(); TriangulatedSurface surface = new TriangulatedSurface(new [] { new Triangle3D(new Point3D(0, 0, 10), new Point3D(10, 0, 10), new Point3D(0, 10, 10)) }); var result = service.GetVolumeUnderSurface(surface, 10); Assert.True(Equality.AreEqual(0, result)); result = service.GetVolumeUnderSurface(surface, 20); Assert.True(Equality.AreEqual(500, result)); surface = new TriangulatedSurface(new [] { new Triangle3D(new Point3D(0, 0, 10), new Point3D(10, 0, 5), new Point3D(0, 10, 10)) }); result = service.GetVolumeUnderSurface(surface, 20); Assert.True(Equality.AreEqual(500 + 250.0 / 3.0, result)); }
private async Task <List <Book> > GenerateBooksAsync() { var authors = _context.Author.ToList(); var languages = _context.BookLanguage.ToList(); var publishers = _context.Publisher.ToList(); var categories = _context.Category.ToList(); var books = new List <Book>(); var service = new VolumeService(); Console.WriteLine("Downloading data from the Google Books..."); foreach (var author in authors) { var authorBooks = new List <Book>(); Console.WriteLine($"Searching for the books by {author.Name}..."); var searchResult = await service.SearchByAuthorAsync(author.Name, 80); Console.WriteLine($"{searchResult.Items.Count()} books have been found and downloaded."); Console.WriteLine("Processing book data..."); foreach (var item in searchResult.Items) { // Skip Google Books which are not for sale or which do not match the database if (item.SaleInfo.Saleability != "FOR_SALE" || author.Name != item.VolumeInfo.Authors.First() || !publishers.Any(p => p.Name == item.VolumeInfo.Publisher) || !categories.Any(c => c.Name == item.VolumeInfo.Categories.First()) || !languages.Any(l => l.Code == item.VolumeInfo.Language) || !item.VolumeInfo.IndustryIdentifiers.Any(ii => ii.Type == "ISBN_13") ) { continue; } var volumeData = item.VolumeInfo; var saleData = item.SaleInfo; var book = new Book() { Title = volumeData.Title, Subtitle = volumeData.Subtitle, AuthorId = author.AuthorId, PublisherId = publishers.First(p => p.Name == volumeData.Publisher).PublisherId, Description = volumeData.Description, IsMature = volumeData.MaturityRating != "NOT_MATURE", Isbn10 = volumeData.IndustryIdentifiers.First(ii => ii.Type == "ISBN_10").Identifier, Isbn13 = volumeData.IndustryIdentifiers.First(ii => ii.Type == "ISBN_13").Identifier, TotalPages = volumeData.PageCount, CategoryId = categories.First(c => c.Name == volumeData.Categories.First()).CategoryId, CoverImage = await ImageHelper.DownloadImageAsync(volumeData.ImageLinks.Thumbnail), CoverImageType = "jpeg", BookLanguageId = languages.First(l => l.Code == volumeData.Language).BookLanguageId, Price = saleData.RetailPrice.Amount, DownloadLink = volumeData.CanonicalVolumeLink }; string publicationDate = volumeData.PublishedDate; if (publicationDate.Length == 4) // If there is only year in the publication date { publicationDate += "-01-01"; // add month and day to be able to store the date } book.PublicationDate = DateTime.Parse(publicationDate); authorBooks.Add(book); } books.AddRange(authorBooks); Console.WriteLine($"{authorBooks.Count()} have been saved."); } return(books); }
private static void StartProgram( IReadOnlyList <string> arguments = null, InputArguments inputArguments = null, string previousError = null, bool restart = true) { if (previousError == null) { ShowIntroText(); } else { ShowFailureText(previousError, restart); } if (inputArguments == null) { inputArguments = ValidateInputAguments(arguments); } ShowArgumentsText(inputArguments); try { if (!IsSpotifyInstalled()) { FailureHandling(inputArguments, "Spotify isn't installed on this computer...", false); } VolumeService.MuteComputerVolume(); StartSpotifyIfItsNotRunning(previousError != null); var spotifyLocalApi = new SpotifyLocalAPI(); if (!spotifyLocalApi.Connect()) { FailureHandling(inputArguments); } SpotifyAPI.Local.Models.StatusResponse spotifyStatus; const int numberOfTries = 5; var loopVariable = 0; do { spotifyStatus = spotifyLocalApi.GetStatus(); loopVariable++; } while (spotifyStatus == null && loopVariable < numberOfTries); if (null == spotifyStatus || !spotifyStatus.Online) { FailureHandling(inputArguments, "You are not logged in to Spotify..."); } spotifyLocalApi.SetSpotifyVolume(); spotifyLocalApi.UnMute(); spotifyLocalApi.PlayURL(inputArguments.SpotifyUrl.Value); VolumeService.IncreaseVolumeToMaxOverTime(inputArguments.MilliSecondsToSleep); #if DEBUG Console.WriteLine(" Press the escape key to exit..."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { Console.WriteLine(" Press the escape key to exit..."); } Environment.Exit(0); #endif } catch (Exception exception) { FailureHandling(inputArguments, exception.Message); } }