public void DisplayPrograms(Category category = Category.ALL) { List <Program> programs = ProgramDataService.FindAll(); currentPrograms.Clear(); DataSectionStack.Children.Clear(); if (category != Category.ALL) { foreach (var program in programs) { if (program.Category == category) { ProgramCell programCell = new ProgramCell(program, this); Grid viewProgramCell = programCell.BuildCell(); DataSectionStack.Children.Add(viewProgramCell); currentPrograms.Add(program); } } } else { foreach (var program in programs) { ProgramCell programCell = new ProgramCell(program, this); Grid viewProgramCell = programCell.BuildCell(); DataSectionStack.Children.Add(viewProgramCell); } currentPrograms = programs; } }
public async Task RetrieveFranchises_UnsuccessfulResponse() { // ARRANGE var appCache = (IAppCache)_context.Properties["appCache"]; var configuration = (IConfiguration)_context.Properties["configuration"]; var httpClientFactoryMock = new Mock <IHttpClientFactory>(); var clientHandlerStub = new DelegatingHandlerStub((request, cancellationToken) => { var response = new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent(_badResponseString, Encoding.UTF8) }; return(Task.FromResult(response)); }); var client = new HttpClient(clientHandlerStub); var unitUnderTest = new ProgramDataService(appCache, configuration, httpClientFactoryMock.Object); httpClientFactoryMock.Setup(mock => mock.CreateClient(It.IsAny <string>())) .Returns(client).Verifiable(); var bearerToken = "SAMPLETOKEN"; // ACT var _ = await unitUnderTest.RetrieveFranchises(ProgramDataSources.ClearCare, bearerToken); }
private void Find_Executed(object sender, ExecutedRoutedEventArgs e) { string findName = FindBar.Text; DataSectionStack.Children.Clear(); currentPrograms.Clear(); currentPrograms = ProgramDataService.FindByName(findName); if (currentPrograms != null && currentPrograms.Count > 0) { PrintCurrentPrograms(); } UndoRedoStack.Command command = new UndoRedoStack.Command(() => { DataSectionStack.Children.Clear(); currentPrograms.Clear(); currentPrograms = ProgramDataService.FindByName(findName); if (currentPrograms != null && currentPrograms.Count > 0) { PrintCurrentPrograms(); } }); undoRedo.AddAction(command); }
public void UpdateProgram_Executed(object sender, ExecutedRoutedEventArgs e) { DataUpdate dataUpdate = new DataUpdate(mainWindow); DataUpdateFieldInit(dataUpdate); ProgramDataService.RemoveProgram(program); dataUpdate.Show(); mainWindow.DisplayPrograms(); }
public async Task RetrieveFranchises_ArgumentOutOfRangeException() { // ARRANGE var appCache = (IAppCache)_context.Properties["appCache"]; var configuration = (IConfiguration)_context.Properties["configuration"]; var httpClientFactoryMock = new Mock <IHttpClientFactory>(); var unitUnderTest = new ProgramDataService(appCache, configuration, httpClientFactoryMock.Object); var bearerToken = "SAMPLETOKEN"; // ACT var _ = await unitUnderTest.RetrieveFranchises(ProgramDataSources.Invalid, bearerToken); }
private void Enter_Click(object sender, RoutedEventArgs e) { if (IsValid()) { ProgramDataService.AddProgram(CreateProgram()); this.Close(); } else { MessageBox.Show("Please write all fields ..."); } main.DisplayPrograms(); }
public async Task RetrieveFranchises_SuccessfulResponseAndUnexpectedDataResponse() { // ARRANGE var appCache = (IAppCache)_context.Properties["appCache"]; var configuration = (IConfiguration)_context.Properties["configuration"]; var httpClientFactoryMock = new Mock <IHttpClientFactory>(); var clientHandlerStub = new DelegatingHandlerStub(); var client = new HttpClient(clientHandlerStub); var unitUnderTest = new ProgramDataService(appCache, configuration, httpClientFactoryMock.Object); httpClientFactoryMock.Setup(mock => mock.CreateClient(It.IsAny <string>())) .Returns(client).Verifiable(); var bearerToken = "SAMPLETOKEN"; // ACT var _ = await unitUnderTest.RetrieveFranchises(ProgramDataSources.ClearCare, bearerToken); }
public async Task RetrieveFranchises_ClearCare_Success() { // ARRANGE var appCache = (IAppCache)_context.Properties["appCache"]; var configuration = (IConfiguration)_context.Properties["configuration"]; var httpClientFactoryMock = new Mock <IHttpClientFactory>(); var jsonResponse = "[100,9999,997,713,101,169,3009]"; var clientHandlerStub = new DelegatingHandlerStub((request, cancellationToken) => { var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(jsonResponse, Encoding.UTF8) }; return(Task.FromResult(response)); } ); var client = new HttpClient(clientHandlerStub); var unitUnderTest = new ProgramDataService(appCache, configuration, httpClientFactoryMock.Object); httpClientFactoryMock.Setup(mock => mock.CreateClient(It.IsAny <string>())) .Returns(client).Verifiable(); var bearerToken = "SAMPLETOKEN"; // ACT var results = await unitUnderTest.RetrieveFranchises(ProgramDataSources.ClearCare, bearerToken); client.Dispose(); // ASSERT httpClientFactoryMock.Verify(); Assert.IsNotNull(results); Assert.AreEqual(7, results.Length); Assert.AreEqual(100, results.First()); Assert.AreEqual(3009, results.Last()); }
/// <summary> /// The ConfirmProgramChange. /// </summary> private void Confirm() { ProgramDataService.SetSelectedProgramAsCurrent(); CleanInstance(); }
public void DeleteProgram_Executed(object sender, ExecutedRoutedEventArgs e) { ProgramDataService.RemoveProgram(program); mainWindow.DisplayPrograms(); }