private async Task InitApi() { string epsgCode = "EPSG:28992"; IAddressSettings addressSettings = AddressSettingsFactory.Create("nl", "CMDatabase"); IDomElement element = DomElementFactory.Create(); var _options = OptionsFactory.Create("gbo", "Gg200786001", "testdfdsfj", epsgCode, addressSettings, element); try { await StreetSmartAPI.Init(_options); // Open image IList <ViewerType> viewerTypes = new List <ViewerType> { ViewerType.Panorama }; IPanoramaViewerOptions panoramaOptions = PanoramaViewerOptionsFactory.Create(true, false, true, true, true, true); panoramaOptions.MeasureTypeButtonToggle = false; IViewerOptions viewerOptions = ViewerOptionsFactory.Create(viewerTypes, epsgCode, panoramaOptions); try { IList <IViewer> viewers = await StreetSmartAPI.Open("Lange Haven 145, Schiedam", viewerOptions); } catch (StreetSmartImageNotFoundException) { MessageBox.Show("image openen >> kapot"); } } catch (StreetSmartLoginFailedException) { MessageBox.Show("api laden >> kapot"); } }
public TOptions Create(string name) { TOptions options = _innerFactory.Create(name); string formattedOptions = null; // See if we need to format these options, either from one of our Options // or from a registered IOptionsFormatter<TOptions> if (_optionsFormatter != null) { formattedOptions = _optionsFormatter.Format(options); } else if (options is IOptionsFormatter optionsFormatter) { formattedOptions = optionsFormatter.Format(); } if (formattedOptions != null) { string logString = $"{typeof(TOptions).Name}{Environment.NewLine}{formattedOptions}"; _logSource.LogOptions(logString); } return(options); }
public TOptions Create(string name = null) { var options = _rawOptions.Create(name); if (!_definitions.Any(x => x.Type == typeof(TOptions))) { return(options); } var context = _provider.GetRequiredService <BotDbContext>(); var definition = _definitions.First(x => x.Type == typeof(TOptions)); foreach (var property in definition.Type.GetProperties()) { var entry = context.Options.FirstOrDefault(x => x.Id == $"{definition.Name}:{property.Name}"); if (entry == null) { continue; } var value = JsonConvert.DeserializeObject(entry.Value, property.PropertyType); property.SetValue(options, value); } return(options); }
public void CanCreateOptionsFactory() { var factory = new OptionsFactory <FakeOptions>(new IConfigureOptions <FakeOptions> [0], new IPostConfigureOptions <FakeOptions>[] { }); Assert.Equal("", factory.Create("").Message); }
public void GivenTheFileDoesNotExist_FileDoesNotExistExceptionIsThrown() { var givenOptions = OptionsFactory.Create(""); var fileSystem = new MockFileSystem(); var sut = new FileStorage(givenOptions, fileSystem); Action act = () => sut.Read("qwerty").Close(); act.Should().Throw <FileDoesNotExistException>(); }
public void GivenShortFilename_ArgumentExceptionIsThrown(string givenFilename) { var givenOptions = OptionsFactory.Create(""); var fileSystem = new MockFileSystem(); var sut = new FileStorage(givenOptions, fileSystem); Action act = () => sut.CreateNew(givenFilename).Close(); act.Should().Throw <ArgumentException>(); }
public void GivenTheFileExists_ThenFileIsDeleted() { var givenOptions = OptionsFactory.Create(""); var fileSystem = new MockFileSystem() .WithFile("q/w/qwerty", "Sample content"); var sut = new FileStorage(givenOptions, fileSystem); sut.Delete("qwerty"); fileSystem.GetFile("q/w/qwerty").Should().BeNull(); }
public void GivenFileSystemContainingFileWithTheSameName_ThenFileExistsExceptionIsThrown() { var givenOptions = OptionsFactory.Create(""); var fileSystem = new MockFileSystem() .WithFile("a/b/abcdef", ""); var sut = new FileStorage(givenOptions, fileSystem); Action act = () => sut.CreateNew("abcdef").Close(); act.Should().Throw <FileExistsException>(); }
public void GivenEmptyFileSystem_ThenFileIsCreated() { var givenOptions = OptionsFactory.Create(""); var fileSystem = new MockFileSystem(); var sut = new FileStorage(givenOptions, fileSystem); sut.CreateNew("abcdef") .Close(); fileSystem.GetFile("a/b/abcdef").Should().NotBeNull(); }
public void GivenLongAlphanumericFilename_FileIsCreated(string givenFilename) { var givenOptions = OptionsFactory.Create(""); var fileSystem = new MockFileSystem(); var sut = new FileStorage(givenOptions, fileSystem); var initialFileCount = fileSystem.AllFiles.Count(); sut.CreateNew(givenFilename) .Close(); fileSystem.AllFiles.Count().Should().Be(1 + initialFileCount); }
public void GivenFileSystemContainingFileWithDifferentName_ThenFileIsCreated() { var givenOptions = OptionsFactory.Create(""); var fileSystem = new MockFileSystem() .WithFile("OtherFile", "file content"); var sut = new FileStorage(givenOptions, fileSystem); sut.CreateNew("abcdef") .Close(); fileSystem.GetFile("a/b/abcdef").Should().NotBeNull(); }
public void GivenTheFileExists_FileContentIsRead() { var givenOptions = OptionsFactory.Create(""); var givenFileContent = "SampleContent"; var fileSystem = new MockFileSystem() .WithFile("q/w/qwerty", givenFileContent); var sut = new FileStorage(givenOptions, fileSystem); var stream = sut.Read("qwerty"); var actualFileContent = new StreamReader(stream).ReadToEnd(); actualFileContent.Should().Be(givenFileContent); }
public void NextDialog() { concurrentDialog = concurrentDialog.GetNextDialog(); if (concurrentDialog.isOption()) { gameController.ShowOptions(); gameController.FillFildOfOption(concurrentDialog); gameController.FillOptions(optionFactory.Create(concurrentDialog.Dialogs().Count)); } else { gameController.ShowDialog(); gameController.FillFildOfDialog(concurrentDialog); } }
public void GivenEmptyFileSystemAndNonEmptyRootDirectory_ThenFileIsCreatedInsideRootDirectory() { var rootDirectory = "root-dir"; var givenOptions = OptionsFactory.Create(rootDirectory); var fileSystem = new MockFileSystem(); fileSystem.AddDirectory(rootDirectory); var sut = new FileStorage(givenOptions, fileSystem); sut.CreateNew("abcdef") .Close(); var expectedPath = Path.Combine(rootDirectory, "a", "b", "abcdef"); fileSystem.GetFile(expectedPath).Should().NotBeNull(); }