public void GetRoundWinner() { var resultsService = new ResultsService(); int[,] ans = new int[3, 3]; ans[0, 0] = -1; ans[0, 1] = 1; ans[0, 2] = 0; ans[1, 0] = 0; ans[1, 1] = -1; ans[1, 2] = 1; ans[2, 0] = 1; ans[2, 1] = 0; ans[2, 2] = -1; for (var i = 0; i < 3; i++) { for (var j = 0; j < 3; j++) { var result = new[] { i + 1, j + 1 }; Assert.IsTrue(resultsService.GetRoundWinner(result) == ans[i, j]); } } }
public void QueueCsvGenerationMessages_GivenNoSpecificationSummariesFound_ThrowsRetriableException() { //Arrange string errorMessage = "No specification summaries found to generate calculation results csv."; IEnumerable <SpecificationSummary> specificationSummaries = Enumerable.Empty <SpecificationSummary>(); ISpecificationsRepository specificationsRepository = CreateSpecificationsRepository(); specificationsRepository .GetSpecificationSummaries() .Returns(specificationSummaries); ILogger logger = CreateLogger(); ResultsService resultsService = CreateResultsService(logger, specificationsRepository: specificationsRepository); //Act Func <Task> test = async() => await resultsService.QueueCsvGenerationMessages(); //Assert test .Should() .ThrowExactly <RetriableException>() .Which .Message .Should() .Be(errorMessage); logger .Received(1) .Error(errorMessage); }
public ResultsCardViewModel(ResultsService resultsService) { FrontLeft = new TyreResultsViewModel(resultsService, TyrePlacement.FrontLeft); FrontRight = new TyreResultsViewModel(resultsService, TyrePlacement.FrontRight); RearLeft = new TyreResultsViewModel(resultsService, TyrePlacement.RearLeft); RearRight = new TyreResultsViewModel(resultsService, TyrePlacement.RearRight); }
public MainWindowViewModel(ITyreInformation tyreInformation, ITrackInformation trackInformation, ResultsService resultsService) { SelectionCard = new SelectionCardViewModel(tyreInformation, trackInformation, resultsService); ResultsCard = new ResultsCardViewModel(resultsService); SelectionWarning = new SelectionWarningViewModel(resultsService); }
/// <summary> /// get all appointments for the current user (represented by SessionData.UserSessionData.CurrentUserId) using AppointmentService, /// if the returned list is empty then show a specific message, /// otherwise for each appointment in the list find the corresponding results in the database using ResultsService, /// it the list returned is not empty append this results to the final list of results, /// if the final list of results is empty the show a specific message, else set dataGridResults.ItemsSource to this list /// </summary> private void RetrieveResults() { _resultService = new ResultsService(); _appointmentService = new AppointmentService(); List<Appointment> appointments = _appointmentService.FindAllByProperty(Utils.AppointmentTableProperties.IdPatient, SessionData.UserSessionData.CurrentUserId.ToString()); List<Results> results = new List<Results>(); if (appointments != null) { foreach (Appointment app in appointments) { List<Results> partialResults = _resultService.FindAllByProperty(Utils.ResultsTableProperties.IdAppointment, app.Id.ToString()); if (partialResults != null) { results.AddRange(partialResults); } } if (results.Count != 0) { dataGridResults.Visibility = Visibility.Visible; dataGridResults.ItemsSource = results; dataGridResults.IsReadOnly = true; } else { labelResultsMsg.Visibility = Visibility.Visible; } } else { labelResultsMsg.Visibility = Visibility.Visible; } }
public void QueueCsvGenerationMessages_GivenNoSpecificationSummariesFound_ThrowsRetriableException() { //Arrange string errorMessage = "No specification summaries found to generate calculation results csv."; IEnumerable <SpecModel.SpecificationSummary> specificationSummaries = Enumerable.Empty <SpecModel.SpecificationSummary>(); ISpecificationsApiClient specificationsApiClient = CreateSpecificationsApiClient(); specificationsApiClient .GetSpecificationSummaries() .Returns(new ApiResponse <IEnumerable <SpecModel.SpecificationSummary> >(HttpStatusCode.OK, specificationSummaries)); ILogger logger = CreateLogger(); ResultsService resultsService = CreateResultsService(logger, specificationsApiClient: specificationsApiClient); //Act Func <Task> test = async() => await resultsService.QueueCsvGenerationMessages(); //Assert test .Should() .ThrowExactly <RetriableException>() .Which .Message .Should() .Be(errorMessage); logger .Received(1) .Error(errorMessage); }
/// <summary> /// opens a connection to the database and initializes necessary services /// </summary> private void OpenConnection() { try { DBConnection.CreateConnection("localhost", "xe", "hr", "hr"); } catch (Exception) { try { DBConnection.CreateConnection("localhost", "ORCL", "hr", "roxana"); } catch (Exception e) { throw e; } } credentialsService = new CredentialsService(); administratorService = new AdministratorService(); patientService = new PatientService(); doctorService = new DoctorService(); departmentService = new DepartmentService(); appointmentService = new AppointmentService(); resultService = new ResultsService(); scheduleService = new ScheduleService(); }
public ActionResult TestPage(FormCollection fc) { var countRight = 0; var countWrong = 0; var error = ""; foreach (var key in fc.AllKeys) { if (key.Contains("rb")) { try { var value = fc[key]; ResultQuery resultQuery = ResultsService.AddAnswer(value, Session["Login"].ToString()); bool isAnswerRight = ResultsService.IsAnswerRight(value); if (isAnswerRight) { countRight++; } else { countWrong++; } } catch (Exception ex) { Nlogger.Error("Error in TestPage save result. " + ex.Message); } } } ViewBag.results = new ResultDto { CountRight = countRight, CountWrong = countWrong, Error = error }; return(View()); }
/// <summary> /// get all appointments for the current user (represented by SessionData.UserSessionData.CurrentUserId) using AppointmentService, /// if the returned list is empty then show a specific message, /// otherwise for each appointment in the list find the corresponding results in the database using ResultsService, /// it the list returned is not empty append this results to the final list of results, /// if the final list of results is empty the show a specific message, else set dataGridResults.ItemsSource to this list /// </summary> private void RetrieveResults() { _resultService = new ResultsService(); _appointmentService = new AppointmentService(); List <Appointment> appointments = _appointmentService.FindAllByProperty(Utils.AppointmentTableProperties.IdPatient, SessionData.UserSessionData.CurrentUserId.ToString()); List <Results> results = new List <Results>(); if (appointments != null) { foreach (Appointment app in appointments) { List <Results> partialResults = _resultService.FindAllByProperty(Utils.ResultsTableProperties.IdAppointment, app.Id.ToString()); if (partialResults != null) { results.AddRange(partialResults); } } if (results.Count != 0) { dataGridResults.Visibility = Visibility.Visible; dataGridResults.ItemsSource = results; dataGridResults.IsReadOnly = true; } else { labelResultsMsg.Visibility = Visibility.Visible; } } else { labelResultsMsg.Visibility = Visibility.Visible; } }
public void Go() { string name1 = "Player 1"; string name2 = "Player 2"; var messageService = new Mock <IMessageService>(); var turnService = new Mock <ITurnService>(); var resultsService = new ResultsService(); var roundService = new RoundService(resultsService); IPlayer[] players = new IPlayer[2] { new Human(turnService.Object) { Name = name1 }, new Human(turnService.Object) { Name = name2 } }; for (var i = 0; i < 4; i++) { messageService.Setup(e => e.ReadPlayerChoice()).Returns(i.ToString()); int result = roundService.Go(players); Assert.IsTrue(result == -1); } }
public SelectionCardViewModel( ITyreInformation tyreInformation, ITrackInformation trackInformation, ResultsService resultsService) { var location = System.Reflection.Assembly.GetExecutingAssembly().Location; // Get the Location of the data directory relative to the execution location of the app // this is where the TyresXML.xml and TrackDegradationCoefficients.txt are located. var dataLocation = Path.Combine(location, @"..\..\..\..\..\Data"); var tyreInfoFile = Path.Combine(dataLocation, "TyresXML.xml"); var trackInfoFile = Path.Combine(dataLocation, "TrackDegradationCoefficients.txt"); // Read in the data from the above files. // If this isn't working for some reason just hardcode the path in the function calls below // to wherever the files are located on your local machine. var tyreInfo = tyreInformation.GetTyreData(tyreInfoFile); var trackInfo = trackInformation.GetTrackData(trackInfoFile); FrontLeft = new TyreComboBoxViewModel(resultsService, TyrePlacement.FrontLeft, tyreInfo); FrontRight = new TyreComboBoxViewModel(resultsService, TyrePlacement.FrontRight, tyreInfo); RearLeft = new TyreComboBoxViewModel(resultsService, TyrePlacement.RearLeft, tyreInfo); RearRight = new TyreComboBoxViewModel(resultsService, TyrePlacement.RearRight, tyreInfo); TrackSelector = new TrackSelectorComboBoxViewModel(resultsService, trackInfo); TemperatureSelector = new TemperatureSelectorViewModel(resultsService); }
private static ResultsService CreateScoresService(int countError) { IXamarinWrapper xamarinWrapper = new XamarinWrapperStub(); IFileHelper fileHelper = new FileHelperStub(countError); ResultsService resultsService = new ResultsService(xamarinWrapper, fileHelper); return(resultsService); }
static ViewModelLocator() { Utility.WriteDebugEntryMessage(MethodBase.GetCurrentMethod()); XamarinWrapper = new XamarinWrapper(); FileHelper = new FileHelper(XamarinWrapper); ResultsService = new ResultsService(XamarinWrapper, FileHelper); }
public FormTranferData() { InitializeComponent(); InitializeMenuItems(); _resultService = new ResultsService(); EnableButtonEditAndDelete(false); }
public void EventCount_Test() { int eventCount = 0; ResultsService resultsService = CreateScoresService(0); resultsService.ResultsChanged += (sender, args) => eventCount++; Result result = new Result(default, 1, 0);
public void SetUp() { _player = TestHelper.CreatePlayer(); _result = TestHelper.CreateResults(); _playerList = TestHelper.PlayerList(); _playerRepository = new PlayerRepository(); _service = new ResultsService(new PlayerRepository(), new ResultRepository()); }
public void Constructor_Test() { IXamarinWrapper xamarinWrapper = new XamarinWrapperStub(); IFileHelper fileHelper = new FileHelperStub(); ManualTimer manualTimer = new ManualTimer(); ResultsService resultsService = new ResultsService(xamarinWrapper, fileHelper); GameService gameService = new GameService(xamarinWrapper, fileHelper, manualTimer, resultsService); }
public async Task QueueCsvGenerationMessages_GivenSpecificationSummariesFoundAndHasNewResults_CreatesNewMessage() { //Arrange IEnumerable <SpecModel.SpecificationSummary> specificationSummaries = new[] { new SpecModel.SpecificationSummary { Id = specificationId } }; ISpecificationsApiClient specificationsApiClient = CreateSpecificationsApiClient(); specificationsApiClient .GetSpecificationSummaries() .Returns(new ApiResponse <IEnumerable <SpecModel.SpecificationSummary> >(HttpStatusCode.OK, specificationSummaries)); ICalculationResultsRepository calculationResultsRepository = CreateResultsRepository(); calculationResultsRepository .CheckHasNewResultsForSpecificationIdAndTime( Arg.Is(specificationId), Arg.Any <DateTimeOffset>()) .Returns(true); ILogger logger = CreateLogger(); IJobManagement jobManagement = CreateJobManagement(); IBlobClient blobClient = CreateBlobClient(); blobClient .DoesBlobExistAsync($"{CalculationResultsReportFilePrefix}-{specificationId}", CalcsResultsContainerName) .Returns(true); ResultsService resultsService = CreateResultsService( logger, specificationsApiClient: specificationsApiClient, resultsRepository: calculationResultsRepository, jobManagement: jobManagement, blobClient: blobClient); //Act await resultsService.QueueCsvGenerationMessages(); //Assert await jobManagement .Received(1) .QueueJob( Arg.Is <JobCreateModel>(_ => _.JobDefinitionId == JobConstants.DefinitionNames.GenerateCalcCsvResultsJob && _.Properties["specification-id"] == specificationId)); logger .Received() .Information($"Found new calculation results for specification id '{specificationId}'"); }
public GroupViewModel(string groupName, string leagueTitle, IEnumerable <Result> results) { var groupItems = CreateGroupItemsFromResults(results); LeagueTitle = leagueTitle; Group = groupName; Matchday = ResultsService.GetMatchday(results); Standing = groupItems; }
public void CanRetrieveResults() { var resultsService = new ResultsService(_context); var result = resultsService.GetResults().ToList(); Assert.NotEmpty(result); Assert.Contains(result, item => item.Subject == "Subject" && item.Results.Any(a => a.Grade == "PASS" && a.Year == 2010)); }
private static ResultsViewModel CreateResultsViewModel() { IXamarinWrapper xamarinWrapper = new XamarinWrapperStub(); IFileHelper fileHelper = new FileHelperStub(); ResultsService resultsService = new ResultsService(xamarinWrapper, fileHelper); ResultsViewModel resultsViewModel = new ResultsViewModel(xamarinWrapper, resultsService); return(resultsViewModel); }
public GroupViewModel(Group group) { if (group != null) { var groupItems = CreateGroupItemsFromResults(group.Results); LeagueTitle = group.LeagueTitle; Group = group.Name; Matchday = ResultsService.GetMatchday(group.Results); Standing = groupItems; } }
public ActionResult Report() { ViewBag.Message = "Отчет"; var results = ResultsService.GetReport(); results.FirstOrDefault().CountRight = 4; results.FirstOrDefault().CountWrong = 1; ViewBag.Results = results; return(View()); }
public SelectionWarningViewModel(ResultsService resultsService) { _visibility = Visibility.Collapsed; _warningMessage = string.Empty; resultsService.SelectionsValid += () => WarningVisibility = Visibility.Collapsed; resultsService.SelectionsInvalid += s => { WarningMessage = s; WarningVisibility = Visibility.Visible; }; }
public async Task QueueCsvGenerationMessages_GivenSpecificationSummariesFoundButNoResults_DoesNotCreateNewMessages() { //Arrange IEnumerable <SpecModel.SpecificationSummary> specificationSummaries = new[] { new SpecModel.SpecificationSummary { Id = "spec-1" } }; ISpecificationsApiClient specificationsApiClient = CreateSpecificationsApiClient(); specificationsApiClient .GetSpecificationSummaries() .Returns(new ApiResponse <IEnumerable <SpecModel.SpecificationSummary> >(HttpStatusCode.OK, specificationSummaries)); ICalculationResultsRepository calculationResultsRepository = CreateResultsRepository(); calculationResultsRepository .ProviderHasResultsBySpecificationId( Arg.Is("spec-1")) .Returns(false); IBlobClient blobClient = CreateBlobClient(); blobClient .DoesBlobExistAsync($"{CalculationResultsReportFilePrefix}-spec-1", CalcsResultsContainerName) .Returns(false); ILogger logger = CreateLogger(); IJobManagement jobManagement = CreateJobManagement(); ResultsService resultsService = CreateResultsService( logger, specificationsApiClient: specificationsApiClient, resultsRepository: calculationResultsRepository, jobManagement: jobManagement, blobClient: blobClient); //Act await resultsService.QueueCsvGenerationMessages(); //Assert await jobManagement .DidNotReceive() .QueueJob(Arg.Any <JobCreateModel>()); logger .DidNotReceive() .Information($"Found new calculation results for specification id 'spec-1'"); }
private static GameViewModel CreateGameViewModel(ManualTimer manualTimer = null) { IXamarinWrapper xamarinWrapper = new XamarinWrapperStub(); IFileHelper fileHelper = new FileHelperStub(0); manualTimer = manualTimer ?? new ManualTimer(); ResultsService resultsService = new ResultsService(xamarinWrapper, fileHelper); GameService gameService = new GameService(xamarinWrapper, fileHelper, manualTimer, resultsService); GameViewModel gameViewModel = new GameViewModel(xamarinWrapper, gameService); return(gameViewModel); }
public ResultsController(IDataRepository <Team, Result> dataRepository, IServiceScopeFactory serviceScopeFactory) { _dataRepository = dataRepository; _serviceScopeFactory = serviceScopeFactory; using (var scope = _serviceScopeFactory.CreateScope()) { var scopedService = scope.ServiceProvider; var allHostedServices = scopedService.GetService <IEnumerable <IHostedService> >(); var resultsServices = allHostedServices.OfType <ResultsService>(); _resultsService = resultsServices.SingleOrDefault(); } }
public TrackSelectorComboBoxViewModel( ResultsService resultsService, IReadOnlyDictionary <string, TrackInformation> trackInformation) { _resultsService = resultsService; _trackInformation = trackInformation; Tracks = new ObservableCollection <string>(); foreach (var track in trackInformation) { Tracks.Add(track.Key); } }
public async Task QueueCsvGenerationMessages_GivenSpecificationSummariesFoundAndHasNewResults_CreatesNewMessage() { //Arrange IEnumerable <SpecificationSummary> specificationSummaries = new[] { new SpecificationSummary { Id = "spec-1" } }; ISpecificationsRepository specificationsRepository = CreateSpecificationsRepository(); specificationsRepository .GetSpecificationSummaries() .Returns(specificationSummaries); ICalculationResultsRepository calculationResultsRepository = CreateResultsRepository(); calculationResultsRepository .CheckHasNewResultsForSpecificationIdAndTimePeriod( Arg.Is("spec-1"), Arg.Any <DateTimeOffset>(), Arg.Any <DateTimeOffset>()) .Returns(true); ILogger logger = CreateLogger(); IMessengerService messengerService = CreateMessengerService(); ResultsService resultsService = CreateResultsService( logger, specificationsRepository: specificationsRepository, resultsRepository: calculationResultsRepository, messengerService: messengerService); //Act await resultsService.QueueCsvGenerationMessages(); //Assert await messengerService .Received(1) .SendToQueue( Arg.Is(ServiceBusConstants.QueueNames.CalculationResultsCsvGeneration), Arg.Is(string.Empty), Arg.Is <Dictionary <string, string> >(m => m["specification-id"] == "spec-1"), Arg.Is(false)); logger .Received() .Information($"Found new calculation results for specification id 'spec-1'"); }
public void Initialize() { _mockTyreInformationBuilder = new MockTyreInformationBuilder(); _tyreInformation = _mockTyreInformationBuilder.Build(); _mockTrackInformationBuilder = new MockTrackInformationBuilder(); _trackInformation = _mockTrackInformationBuilder.Build(); _resultsService = new ResultsService(); _mainWindowViewModel = new MainWindowViewModel( _tyreInformation.Object, _trackInformation.Object, _resultsService); }
public void NewResultsTests() { // ToDo: This duplicates CreateResultsViewModel because we need access to _resultsService. IXamarinWrapper xamarinWrapper = new XamarinWrapperStub(); IFileHelper fileHelper = new FileHelperStub(); ResultsService resultsService = new ResultsService(xamarinWrapper, fileHelper); ResultsViewModel resultsViewModel = new ResultsViewModel(xamarinWrapper, resultsService); IEnumerable <Result> bestResults = resultsViewModel.BestResults; IEnumerable <Result> latestResults = resultsViewModel.LatestResults; Result result = new Result(default, 1, 0);
public DoctorAppointmentAssignResult(int appoitnmentId) { InitializeComponent(); groupBox.Visibility = Visibility.Hidden; h_date.Visibility = Visibility.Hidden; h_diagnosis.Visibility = Visibility.Hidden; h_medication.Visibility = Visibility.Hidden; h_symptoms.Visibility = Visibility.Hidden; h_results.Visibility = Visibility.Hidden; _appointmentService = new AppointmentService(); _patientService = new PatientService(); _resultsService = new ResultsService(); _selectedAppointment = _appointmentService.FindById(appoitnmentId); _selectedPatient = _patientService.FindById(_selectedAppointment.IdPacient); nameLabel.Content = _selectedPatient.FirstName + " " + _selectedPatient.LastName; insuranceNumberLabel.Content = _selectedPatient.InsuranceNumber; geneticDisorderLabel.Content = _selectedPatient.GeneticDiseases; }