public async Task AddCommentAsyncTest() { try { Trace.Write(" "); var request = new Comment { CommentText = "Test comment " + DateTime.Now + " " + Guid.NewGuid().ToString(), UpdateUserGuid = "22c9e6dd-2b43-479f-a3a1-0f465e81aed3", NoteId = 6, CommentType = 1 }; var comments = await WebDataService.AddComment(request); foreach (var note in comments) { foreach (var comment in comments) { Trace.WriteLine("------ " + comment.CommentText); } Trace.WriteLine(""); } } catch (Exception ex) { string output = $"Unable to get notes: { ex.Message}"; Trace.Write(output); Assert.Fail(output); } }
private static void ProcessCommands([NotNull] WebDataService dataService, [NotNull] XElement commandsElement) { Debug.ArgumentNotNull(dataService, nameof(dataService)); Debug.ArgumentNotNull(commandsElement, nameof(commandsElement)); foreach (var submenuElement in commandsElement.Elements("submenu")) { var webCommandSubmenu = new WebCommandSubmenu(dataService, submenuElement); var submenu = submenuElement.GetElementValue("submenu"); var commandDescriptor = new CommandManager.CommandDescriptor(webCommandSubmenu, submenu, typeof(WebCommand)); CommandManager.Add(commandDescriptor); } foreach (var commandElement in commandsElement.Elements("command")) { var webCommand = new WebCommand(dataService, commandElement); var submenu = commandElement.GetElementValue("submenu"); var commandDescriptor = new CommandManager.CommandDescriptor(webCommand, submenu, typeof(WebCommand)); CommandManager.Add(commandDescriptor); } }
public async Task GetNotesByUserIdAsyncTest() { try { Trace.Write(" "); var notes = await WebDataService.GetNotesByUserIdAsync("22c9e6dd-2b43-479f-a3a1-0f465e81aed3"); foreach (var note in notes) { Trace.WriteLine("Id: " + note.Id); Trace.WriteLine("Title: " + note.Title); Trace.WriteLine("Content: " + note.Content); Trace.WriteLine("Comments: "); foreach (var comment in note.Comments) { Trace.WriteLine("------ " + comment.CommentText); } Trace.WriteLine(""); } } catch (Exception ex) { string output = $"Unable to get notes: { ex.Message}"; Trace.Write(output); Assert.Fail(output); } }
public static void Load([NotNull] WebDataService dataService, [NotNull] XElement webcommandsElement) { Assert.ArgumentNotNull(dataService, nameof(dataService)); Assert.ArgumentNotNull(webcommandsElement, nameof(webcommandsElement)); foreach (var commandsElement in webcommandsElement.Elements()) { ProcessCommands(dataService, commandsElement); } }
public void GivenALocationTheWebDataServiceShouldCallBbcService() { var downloadService = new Mock <IDownloadStringService>(); WebDataService service = new WebDataService(downloadService.Object); var location = "england"; service.GetData(location); downloadService.Verify(d => d.GetData <BbcWeatherResult>($"http://localhost:60350/Weather/{location}")); }
public LoggedInPipeline WithParameters([NotNull] WebDataService webDataService, [NotNull] XElement output) { Assert.ArgumentNotNull(webDataService, nameof(webDataService)); Assert.ArgumentNotNull(output, nameof(output)); WebDataService = webDataService; RootElement = output; Start(); return(this); }
public void GivenBbcWeatherDataWebDataServiceShouldConvertToWeatherDataCorrectly() { var downloadService = new Mock <IDownloadStringService>(); WebDataService service = new WebDataService(downloadService.Object); var result = service.ConvertBbcToStandardResult(new BbcWeatherResult { TemperatureCelsius = 45, Location = "sfbsfbx", WindSpeedKph = 50 }); Assert.Equal(113, result.TemperatureF); Assert.InRange <double>(result.WindSpeedMph, 31.06, 31.07); }
public void GivenAccWeatherDataWebDataServiceShouldConvertToWeatherDataCorrectly() { var downloadService = new Mock <IDownloadStringService>(); WebDataService service = new WebDataService(downloadService.Object); var result = service.ConvertAccToStandardResult(new AccWeatherResult { TemperatureFahrenheit = 78, Where = "Svsfv", WindSpeedMph = 45 }); Assert.InRange <double>(result.TemperatureC, 25.5555, 25.5557); Assert.InRange <double>(result.WindSpeedKph, 72.42, 72.43); }
public WebCommandSubmenu([NotNull] WebDataService dataService, [NotNull] XElement submenuElement) { Assert.ArgumentNotNull(dataService, nameof(dataService)); Assert.ArgumentNotNull(submenuElement, nameof(submenuElement)); DataService = dataService; Text = submenuElement.GetElementValue("text", "[text missing]"); SortingValue = submenuElement.GetElementValueInt("sorting", 1000); Group = submenuElement.GetElementValue("group", "WebCommands"); SubmenuName = submenuElement.GetElementValue("name", Text); var context = submenuElement.GetElementValue("context"); ParseContext(context); }
public async Task GetLinkTypesAsyncTest() { try { Trace.Write(" "); var linkTypes = await WebDataService.GetLinkTypes(); foreach (var lt in linkTypes) { Trace.Write(lt.Id + " - " + lt.Title + " - " + lt.CreatedDate); } } catch (Exception ex) { string output = $"Unable to get linkTypes: { ex.Message}"; Trace.Write(output); Assert.Fail(output); } }
public WebCommand([NotNull] WebDataService dataService, [NotNull] XElement commandElement) { Assert.ArgumentNotNull(dataService, nameof(dataService)); Assert.ArgumentNotNull(commandElement, nameof(commandElement)); DataService = dataService; Window = string.Empty; WindowTitle = string.Empty; canExecute = (parameter, parameterType) => true; Text = commandElement.GetElementValue("text", "[text missing]"); SortingValue = commandElement.GetElementValueInt("name", 1000); Group = commandElement.GetElementValue("group", "WebCommands"); Request = commandElement.GetElementValue("request"); RequireLogin = string.Compare(commandElement.GetElementValue("requirelogin", "true"), "true", StringComparison.InvariantCultureIgnoreCase) == 0; var windowElement = commandElement.Element("window"); if (windowElement != null) { Window = windowElement.Value; WindowHeight = windowElement.GetAttributeInt("height", -1); WindowWidth = windowElement.GetAttributeInt("width", -1); WindowTitle = windowElement.GetAttributeValue("title"); } var contextElement = commandElement.Element("context"); if (contextElement != null) { AllowMultipleItems = string.Compare(contextElement.GetAttributeValue("allowmultipleitem"), "true", StringComparison.InvariantCultureIgnoreCase) == 0; AllowNoItems = string.Compare(contextElement.GetAttributeValue("allownoitem"), "true", StringComparison.InvariantCultureIgnoreCase) == 0; ParseContext(contextElement.Value); } Actions = commandElement.Element("afterexecute"); }
public async Task CreateNoteAsyncTest() { try { Trace.Write(" "); var request = new Note { NoteType = 1, Content = Guid.NewGuid().ToString() + " " + Environment.NewLine + Guid.NewGuid().ToString() + " " + Environment.NewLine + Guid.NewGuid().ToString() + " ", UpdateUserGuid = "22c9e6dd-2b43-479f-a3a1-0f465e81aed3", Title = "Note" + "Test Note " + DateTime.Now, ImageFile = string.Empty, ImageThumb = string.Empty }; var notes = await WebDataService.CreateNote(request); foreach (var note in notes) { Trace.WriteLine("Id: " + note.Id); Trace.WriteLine("Title: " + note.Title); Trace.WriteLine("Content: " + note.Content); Trace.WriteLine("Comments: "); foreach (var comment in note.Comments) { Trace.WriteLine("------ " + comment.CommentText); } Trace.WriteLine(""); } } catch (Exception ex) { string output = $"Unable to get notes: { ex.Message}"; Trace.Write(output); Assert.Fail(output); } }
public WeatherData Index(string location) { WebDataService temp = new WebDataService(new DownloadStringService()); return(temp.GetData(location)); }