private static ProjectionService CreateProjectionService() { var projectionService = new ProjectionService(GetEventStoreConnection); projectionService.SubscribeTo("$ce-reservation", "Reservations", new Projection[] { new ReservationProjection(GetDatabaseConnection), new ReservationSummaryProjection(GetDatabaseConnection) }); projectionService.StartAsync().GetAwaiter().GetResult(); return(projectionService); }
public void Projectionervice_CreateProjection_When_Updating_Non_Existing_Movie() { // Arrange List <Projection> projectionsModelsList = new List <Projection>(); _mockProjectionsRepository = new Mock <IProjectionsRepository>(); _mockProjectionsRepository.Setup(x => x.Insert(It.IsAny <Projection>())).Throws(new DbUpdateException()); _mockProjectionsRepository.Setup(x => x.Save()); ProjectionService projectionsController = new ProjectionService(_mockProjectionsRepository.Object, _mockReservationService.Object); //Act var resultAction = projectionsController.CreateProjection(_projectionDomainModel).ConfigureAwait(false).GetAwaiter().GetResult(); }
public void ProjectionService_DeleteByAuditoriumMovieId_ProjectionRepositoryReturnsNull_ReturnsNull() { ProjectionService projectionsService = new ProjectionService(_mockProjectionsRepository.Object, _mockReservationService.Object); IEnumerable <Projection> projections = null; Task <IEnumerable <Projection> > responseTask = Task.FromResult(projections); _mockProjectionsRepository.Setup(x => x.DeleteByAuditoriumIdMovieId(It.IsAny <int>(), It.IsAny <Guid>())).Returns(responseTask); //Act var resultAction = projectionsService.DeleteByAuditoriumIdMovieId(_projection.AuditoriumId, _projection.MovieId).ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNull(resultAction); }
public ActionResult TopFilm() { List <Film> films = filmService.GetMany(f => f.FilmNote >= 4).ToList(); IProjectionService pcv = new ProjectionService(); foreach (var item in films) { item.Projections = pcv.GetMany(p => p.FilmId == item.FilmId).ToList(); item.Categories = filmService.GetFilmCategories(item.FilmId).ToList(); } return(PartialView(films)); }
public async Task ThrowEntityDoesntExistException_WhenReservationDoesntExist() { // Arrange var contextOptions = new DbContextOptionsBuilder <AlphaCinemaContext>() .UseInMemoryDatabase(databaseName: "ThrowEntityDoesntExistException_WhenReservationDoesntExist") .UseInternalServiceProvider(serviceProvider) .Options; //Act and Assert using (var assertContext = new AlphaCinemaContext(contextOptions)) { var command = new ProjectionService(assertContext); await Assert.ThrowsExceptionAsync <EntityDoesntExistException>(async() => await command.DeclineReservation(testUserId, testProjectionId)); } }
public void ProjectionService_GetAllAsync_ReturnNull() { //Arrange IEnumerable <Projection> projections = null; Task <IEnumerable <Projection> > responseTask = Task.FromResult(projections); _mockProjectionsRepository = new Mock <IProjectionsRepository>(); _mockProjectionsRepository.Setup(x => x.GetAll()).Returns(responseTask); ProjectionService projectionsController = new ProjectionService(_mockProjectionsRepository.Object); //Act var resultAction = projectionsController.GetAllAsync().ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNull(resultAction); }
public void ProjectionService_GetAllAsync_ReturnListOfProjecrions() { //Arrange int expectedResultCount = 1; ProjectionService projectionsController = new ProjectionService(_mockProjectionsRepository.Object); //Act var resultAction = projectionsController.GetAllAsync(query).ConfigureAwait(false).GetAwaiter().GetResult(); var result = (List <ProjectionDomainModel>)resultAction; //Assert Assert.IsNotNull(result); Assert.AreEqual(expectedResultCount, result.Count); Assert.AreEqual(_projection.Id, result[0].Id); Assert.IsInstanceOfType(result[0], typeof(ProjectionDomainModel)); }
public void ProjectionService_GetAllAsync_ReturnsEmptyList() { //Arrange var expectedCount = 0; List <Projection> projections = new List <Projection>(); _mockProjectionsRepository = new Mock <IProjectionsRepository>(); _mockProjectionsRepository.Setup(x => x.GetAll()).ReturnsAsync(projections); ProjectionService projectionsController = new ProjectionService(_mockProjectionsRepository.Object); //Act var resultAction = projectionsController.GetAllAsync(query).ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.AreEqual(expectedCount, resultAction.Count()); }
public JsonResult AddProjection(Projection projection) { JsonResult result = new JsonResult(); result.JsonRequestBehavior = JsonRequestBehavior.AllowGet; if (projection != null) { ProjectionService.AddProjection(projection); result.Data = new { Success = true }; } else { result.Data = new { Success = false }; } return(result); }
public void ProjectionService_UpdateProjection_ReturnUpdatedProjection() { // Arrange ProjectionService projectionsService = new ProjectionService(_mockProjectionsRepository.Object, _mockReservationService.Object); _mockProjectionsRepository.Setup(x => x.Update(It.IsAny <Projection>())).Returns(_projection); _mockProjectionsRepository.Setup(x => x.Save()); // Act var resultAction = projectionsService.UpdateProjection(_projectionDomainModel).ConfigureAwait(false).GetAwaiter().GetResult(); // Assert Assert.IsNotNull(resultAction); Assert.AreEqual(resultAction.Id, _projectionDomainModel.Id); Assert.IsInstanceOfType(resultAction, typeof(ProjectionDomainModel)); }
public void ProjectionService_GetProjectionByIdAsync_IncorrectId_ReturnNull() { //Arrange Projection projection = null; ProjectionService projectionsService = new ProjectionService(_mockProjectionsRepository.Object, _mockReservationService.Object); _mockProjectionsRepository.Setup(x => x.GetByIdAsync(It.IsAny <Guid>())).Returns(Task.FromResult(projection)); _mockProjectionsRepository.Setup(x => x.Save()); //Act var resultAction = projectionsService.GetProjectionByIdAsync(_projection.Id).ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNull(resultAction); Assert.IsNotInstanceOfType(resultAction, typeof(ProjectionDomainModel)); }
public void ProjectionService_GetProjectionByAuditoriumIdMovieId_WrongId_ReturnEmptyList() { // Arrange ProjectionService projectionsService = new ProjectionService(_mockProjectionsRepository.Object, _mockReservationService.Object); List <Projection> projectionsModelsList = new List <Projection>(); _mockProjectionsRepository.Setup(x => x.GetByAuditoriumIdMovieId(It.IsAny <int>(), It.IsAny <Guid>())).Returns(projectionsModelsList); //Act var resultAction = projectionsService.GetProjectionByAuditoriumIdMovieId(_projection.AuditoriumId, _projection.MovieId).ConfigureAwait(false).GetAwaiter().GetResult().ToList(); //Assert Assert.IsNotNull(resultAction); Assert.AreEqual(resultAction.Count, 0); Assert.IsInstanceOfType(resultAction, typeof(List <ProjectionDomainModel>)); }
public async Task ReturnCollectionOfProjections_WhenCountIsValid() { //Arrange // Create a new options instance telling the context to use an InMemory database and the new service provider. var contextOptions = new DbContextOptionsBuilder <AlphaCinemaContext>() .UseInMemoryDatabase(databaseName: "ReturnCollectionOfProjections_WhenCountIsValid") .UseInternalServiceProvider(serviceProvider) .Options; var listOfProjections = new List <Projection>() { testProjectionOne, testProjectionTwo, testProjectionThree }; var listOfMovies = new List <Movie>() { testMovieOne, testMovieTwo, testMovieThree }; //Act and Assert using (var actContext = new AlphaCinemaContext(contextOptions)) { await actContext.AddRangeAsync(listOfProjections); await actContext.AddRangeAsync(listOfMovies); await actContext.AddAsync(testOpenHour); await actContext.AddAsync(testCity); await actContext.SaveChangesAsync(); } //Assert using (var assertContext = new AlphaCinemaContext(contextOptions)) { var command = new ProjectionService(assertContext); var result = await command.GetTopProjections(projectionCount); Assert.AreEqual(testProjectionOne.Id, result.First().Id); //We are returning the FirstProjection and we want the top 1 } }
public void ProjectionService_CreateProjection_WithProjectionAtSameTime_ReturnErrorMessage() { //Arrange List <Projection> projectionsModelsList = new List <Projection>(); projectionsModelsList.Add(_projection); string expectedMessage = "Cannot create new projection, there are projections at same time alredy."; _mockProjectionsRepository = new Mock <IProjectionsRepository>(); _mockProjectionsRepository.Setup(x => x.GetByAuditoriumId(It.IsAny <int>())).Returns(projectionsModelsList); ProjectionService projectionsController = new ProjectionService(_mockProjectionsRepository.Object); //Act var resultAction = projectionsController.CreateProjection(_projectionDomainModel).ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNotNull(resultAction); Assert.AreEqual(expectedMessage, resultAction.ErrorMessage); Assert.IsFalse(resultAction.IsSuccessful); }
public void ProjectionService_CreateProjection_InsertMocked_ReturnProjection() { //Arrange List <Projection> projectionsModelsList = new List <Projection>(); _mockProjectionsRepository = new Mock <IProjectionsRepository>(); _mockProjectionsRepository.Setup(x => x.GetByAuditoriumId(It.IsAny <int>())).Returns(projectionsModelsList); _mockProjectionsRepository.Setup(x => x.Insert(It.IsAny <Projection>())).Returns(_projection); _mockProjectionsRepository.Setup(x => x.Save()); ProjectionService projectionsController = new ProjectionService(_mockProjectionsRepository.Object); //Act var resultAction = projectionsController.CreateProjection(_projectionDomainModel).ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNotNull(resultAction); Assert.AreEqual(_projection.Id, resultAction.Projection.Id); Assert.IsNull(resultAction.ErrorMessage); Assert.IsTrue(resultAction.IsSuccessful); }
public void ProjectionService_DeleteByAuditoriumId_ProjectionRepositoryReturnsNull_ReturnsNull() { List <Projection> projectionsModelsList = new List <Projection>(); projectionsModelsList.Add(_projection); IEnumerable <Projection> projections = projectionsModelsList; ProjectionService projectionsService = new ProjectionService(_mockProjectionsRepository.Object, _mockReservationService.Object); Projection projection = null; _mockProjectionsRepository.Setup(x => x.GetByAuditoriumId(It.IsAny <int>())).Returns(projections); _mockProjectionsRepository.Setup(x => x.Delete(It.IsAny <int>())).Returns(projection); //Act var resultAction = projectionsService.DeleteByAuditoriumId(_projection.AuditoriumId).ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNull(resultAction); }
public void ProjectionService_UpdateProjection_ProjectionRepositoryReturnsNull_ReturnsNull() { //Arrange Projection projection = null; ProjectionService projectionsService = new ProjectionService(_mockProjectionsRepository.Object, _mockReservationService.Object); _mockProjectionsRepository.Setup(x => x.Update(It.IsAny <Projection>())).Returns(projection); _mockProjectionsRepository.Setup(x => x.Save()); //Act var resultAction = projectionsService.UpdateProjection(_projectionDomainModel).ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNull(resultAction); }
public void ProjectionService_CreateProjection_InsertMockedNull_ReturnErrorMessage() { //Arrange List <Projection> projectionsModelsList = new List <Projection>(); _projection = null; string expectedMessage = "Error occured while creating new projection, please try again."; _mockProjectionsRepository = new Mock <IProjectionsRepository>(); _mockProjectionsRepository.Setup(x => x.GetByAuditoriumId(It.IsAny <int>())).Returns(projectionsModelsList); _mockProjectionsRepository.Setup(x => x.Insert(It.IsAny <Projection>())).Returns(_projection); ProjectionService projectionsController = new ProjectionService(_mockProjectionsRepository.Object); //Act var resultAction = projectionsController.CreateProjection(_projectionDomainModel).ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNotNull(resultAction); Assert.AreEqual(expectedMessage, resultAction.ErrorMessage); Assert.IsFalse(resultAction.IsSuccessful); }
public void ProjectionService_DeleteProjection_ReservationServiceReturnsNull_ReturnsNull() { // Arrange Task <IEnumerable <ReservationDomainModel> > reservationResponseTask = null; _mockReservationService = new Mock <IReservationService>(); _mockReservationService.Setup(x => x.DeleteByProjectionId(It.IsAny <Guid>())).Returns(reservationResponseTask); ProjectionService projectionsService = new ProjectionService(_mockProjectionsRepository.Object, _mockReservationService.Object); _mockProjectionsRepository.Setup(x => x.Delete(It.IsAny <Guid>())).Returns(_projection); _mockProjectionsRepository.Setup(x => x.Save()); // Act var resultAction = projectionsService.DeleteProjection(_projection.Id).ConfigureAwait(false).GetAwaiter().GetResult(); // Assert Assert.IsNull(resultAction); }
public void ProjectionService_GetProjectionsByAuditoriumId_ReturnsProjectionDomainModelList() { // Arrange int expectedCount = 1; ProjectionService projectionsService = new ProjectionService(_mockProjectionsRepository.Object, _mockReservationService.Object); List <Projection> projectionsModelsList = new List <Projection>(); projectionsModelsList.Add(_projection); _mockProjectionsRepository.Setup(x => x.GetByAuditoriumId(It.IsAny <int>())).Returns(projectionsModelsList); //Act var resultAction = projectionsService.GetProjectionsByAuditoriumId(_projection.AuditoriumId).ConfigureAwait(false).GetAwaiter().GetResult().ToList(); //Assert Assert.IsNotNull(resultAction); Assert.AreEqual(resultAction.Count, expectedCount); Assert.IsInstanceOfType(resultAction[0], typeof(ProjectionDomainModel)); Assert.AreEqual(resultAction[0].Id, _projection.Id); }
public HomeController(PaymentService paymentService, RemainingBalanceService remainingBalanceService, ProjectionService projectionService) { _paymentService = paymentService; _remainingBalanceService = remainingBalanceService; _projectionService = projectionService; }
private void Process() { Bitmap bitmapFromScreen = BitmapService.BitmapFromScreen(CaptureArea.Width, CaptureArea.Height, CaptureArea.Left, CaptureArea.Top, this.comboBoxScreen.SelectedIndex); pictureBox1.Image = bitmapFromScreen; projectionBitMapFilter = ProjectionService.ProjectandFilter(SelectedColor, Convert.ToInt32(this.numericUpDownColorMargin.Value), bitmapFromScreen); ProjectionsToChartSeries(projectionBitMapFilter); ProjectionsToChartSeries(projectionBitMapFilter); this.pictureBox2.Image = projectionBitMapFilter.Bitmap; projectionBitMapFilter.HorizontalSegments = ProjectionService.ToSegments(projectionBitMapFilter.HorizontalProjection, projectionBitMapFilter.Bitmap.Height); projectionBitMapFilter.VerticalSegments = new List <Segment>(); if (SubtitlesDetected(projectionBitMapFilter.HorizontalSegments)) { long Range = projectionBitMapFilter.HorizontalSegments[0].End - projectionBitMapFilter.HorizontalSegments[0].Starts; Int64 AverageRange = MathHelper.Average(Ranges); projectionBitMapFilter.VerticalSegments = ProjectionService.ToSegments(projectionBitMapFilter.VerticalProjection, projectionBitMapFilter.Bitmap.Height); if (projectionBitMapFilter.VerticalSegments.Count != 0) { projectionBitMapFilter = ProjectionService.MaxMinEvaluation(bitmapFromScreen.Height, projectionBitMapFilter); List <Segment> GroupedSegments = SegmentationService.GroupSegments(projectionBitMapFilter.VerticalSegments); Bitmap bitmapInitialSegments = (Bitmap)projectionBitMapFilter.Bitmap.Clone(); Bitmap bitmapGroupedSegments = (Bitmap)projectionBitMapFilter.Bitmap.Clone(); this.pictureBox2.Image = BitmapService.DrawSegmentsinBitmap(projectionBitMapFilter.VerticalSegments, bitmapInitialSegments, Brushes.DarkRed); this.pictureBoxGrouped.Image = BitmapService.DrawSegmentsinBitmap(GroupedSegments, bitmapGroupedSegments, Brushes.Orange); projectionBitMapFilter.CroppedBitmaps = BitmapService.ExtractCropBitmaps(GroupedSegments, projectionBitMapFilter.Bitmap); foreach (Bitmap crop in projectionBitMapFilter.CroppedBitmaps) { var margin = BitmapService.CorrectMargin(crop); projectionBitMapFilter.CorrectedMarginBitmaps.Add(margin); } List <char> predictions = new List <char>(); foreach (Bitmap bitmap in projectionBitMapFilter.CorrectedMarginBitmaps) { Bitmap resized = BitmapService.ResizeImage(bitmap, 32, 32); projectionBitMapFilter.ResizedBitmaps.Add(resized); string zerosandones = DatasetGenerator.ToZerosOnesSequence(' ', resized); var c = PredictionService.Predict(zerosandones); predictions.Add(c); x++; } BitmapsToScreen(projectionBitMapFilter.ResizedBitmaps); AddTextBoxToScreen(projectionBitMapFilter.CroppedBitmaps.Count, predictions); } } }
public Projectionist Add(ProjectionService service) { return Add(service.Project); }
public static void GenerateDataSet(int level) { ArrayList all = new ArrayList(); DictionaryService dictionaryService = new DictionaryService(); for (int i = 1; i <= level; i++) { ArrayList words = dictionaryService.GetAllWords(i); all.AddRange(words); } ArrayList chars = new ArrayList(); foreach (Word w in all) { foreach (Char c in w.Character) { if (!chars.Contains(c)) { chars.Add(c); var Projection = ProjectionService.GenerateProjectionfromFontChar(c, new Size(32, 32), 28, "DengXian", FontStyle.Regular); var sequence = ToZerosOnesSequence(c, Projection.Bitmap); FileWriter.AddLine(sequence, datasetPath); } } } foreach (Word w in all) { foreach (Char c in w.Character) { if (!chars.Contains(c)) { chars.Add(c); var Projection = ProjectionService.GenerateProjectionfromFontChar(c, new Size(32, 32), 28, "DengXian Light", FontStyle.Regular); var sequence = ToZerosOnesSequence(c, Projection.Bitmap); string path = @"C:\Users\dlorente\Desktop\RecogZi\dataset.csv"; FileWriter.AddLine(sequence, path); } } } foreach (Word w in all) { foreach (Char c in w.Character) { if (!chars.Contains(c)) { chars.Add(c); var Projection = ProjectionService.GenerateProjectionfromFontChar(c, new Size(32, 32), 28, "DengXian", FontStyle.Italic); var sequence = ToZerosOnesSequence(c, Projection.Bitmap); FileWriter.AddLine(sequence, datasetPath); } } } foreach (Word w in all) { foreach (Char c in w.Character) { if (!chars.Contains(c)) { chars.Add(c); var Projection = ProjectionService.GenerateProjectionfromFontChar(c, new Size(32, 32), 28, "DengXian Light", FontStyle.Italic); var sequence = ToZerosOnesSequence(c, Projection.Bitmap); FileWriter.AddLine(sequence, datasetPath); } } } }
static void Main() { ProjectionService.Start().WaitForExit(); }