public async Task AddPersonAsync_WithCorrectInput_ReturnsOk() { var mockLogger = Mock.Of <ILogger <MaintenanceController> >(); var mockFaceClientService = new Mock <IFaceClientService>(); mockFaceClientService .Setup(service => service.CreatePersonAsync(It.IsNotNull <string>(), It.IsNotNull <string>())) .Returns(() => Task.FromResult(new Cloud.Models.Person { PersonId = $"{Guid.NewGuid()}" })); var dto = new NewPersonDto { FaceUrl = $"http://www.google.com", Name = $"{Guid.NewGuid()}" }; var controller = new MaintenanceController(mockFaceClientService.Object, mockLogger); var actionResult = await controller.AddPersonAsync(dto); Assert.NotNull(actionResult); var okObjectResult = Assert.IsAssignableFrom <OkObjectResult>(actionResult); var person = Assert.IsAssignableFrom <Cloud.Models.Person>(okObjectResult.Value); person.Should().NotBeNull(); person.PersonId.Should().NotBeNullOrWhiteSpace(); }
public static IMapper GetMapper(this MaintenanceController account) { return((new MapperConfiguration(cfg => { cfg.CreateMap <ExtendedIdentityUser, UserViewModel>(); cfg.CreateMap <UserViewModel, ExtendedIdentityUser>(); cfg.CreateMap <ExtendedIdentityUser, UpdateUserViewModel>(); cfg.CreateMap <UpdateUserViewModel, ExtendedIdentityUser>(); cfg.CreateMap <UserDTO, UpdateUserViewModel>(); cfg.CreateMap <UpdateUserViewModel, UserDTO>(); cfg.CreateMap <UpdateUserDTO, UpdateUserViewModel>(); cfg.CreateMap <UpdateUserViewModel, UpdateUserDTO>(); cfg.CreateMap <UserDTO, UserViewModel>(); cfg.CreateMap <UserViewModel, UserDTO>(); cfg.CreateMap <UpdateFieldDTO, UpdateFieldViewModel>(); cfg.CreateMap <UpdateFieldViewModel, UpdateFieldDTO>(); cfg.CreateMap <AddUserDTO, AddUserViewModel>(); cfg.CreateMap <AddUserViewModel, AddUserDTO>(); cfg.CreateMap <AddFieldItemViewModel, FieldItemDTO>(); cfg.CreateMap <FieldItemDTO, AddFieldItemViewModel>(); cfg.CreateMap <UpdateFieldItemViewModel, FieldItemDTO>(); cfg.CreateMap <FieldItemDTO, UpdateFieldItemViewModel>(); cfg.CreateMap <AddFieldViewModel, AddFieldDTO>(); cfg.CreateMap <AddFieldDTO, AddFieldViewModel>(); cfg.CreateMap <DepartmentDTO, DepartmentViewModel>(); cfg.CreateMap <DepartmentViewModel, DepartmentDTO>(); cfg.CreateMap <ChangePasswordUserDTO, ChangePasswordUserViewModel>(); cfg.CreateMap <ChangePasswordUserViewModel, ChangePasswordUserDTO>(); cfg.CreateMap <UpdateDepartmentDTO, UpdateDepartmentViewModel>(); cfg.CreateMap <UpdateDepartmentViewModel, UpdateDepartmentDTO>(); cfg.CreateMap <AddDepartmentDTO, AddDepartmentViewModel>(); cfg.CreateMap <AddDepartmentViewModel, AddDepartmentDTO>(); cfg.CreateMap <FieldDTO, FieldViewModel>() .ForMember(x => x.TypeName, opt => opt.MapFrom(src => src.Type.ToString())); cfg.CreateMap <AddDatasetViewModel, AddDatasetDTO>(); cfg.CreateMap <AddDatasetDTO, AddDatasetViewModel>(); cfg.CreateMap <DatasetViewModel, DatasetDTO>(); cfg.CreateMap <DatasetDTO, DatasetViewModel>(); cfg.CreateMap <UpdateDatasetViewModel, UpdateDatasetDTO>(); cfg.CreateMap <UpdateDatasetDTO, UpdateDatasetViewModel>(); cfg.CreateMap <DatasetViewModel, UpdateDatasetDTO>(); cfg.CreateMap <UpdateDatasetDTO, DatasetViewModel>(); cfg.CreateMap <AddFieldDatasetViewModel, AddFieldDatasetDTO>(); cfg.CreateMap <AddFieldDatasetDTO, AddFieldDatasetViewModel>(); cfg.CreateMap <FieldDatasetViewModel, DatasetFieldDTO>(); cfg.CreateMap <DatasetFieldDTO, FieldDatasetViewModel>(); //.ForMember(x => x.Field, opt => opt.Ignore()); cfg.CreateMap <FieldDTO, FieldViewModel>(); cfg.CreateMap <FieldViewModel, FieldDTO>(); cfg.CreateMap <UpdateUserDTO, ChangePasswordUserViewModel>(); cfg.CreateMap <ChangePasswordUserViewModel, UpdateUserDTO>(); cfg.CreateMap <ChangeCompanyInfoViewModel, CompanyInfoDTO>(); cfg.CreateMap <CompanyInfoDTO, ChangeCompanyInfoViewModel>(); })).CreateMapper()); }
public async Task RemoveFaceAsync_WithMissingFaceId_ReturnsBadRequest() { var mockLogger = Mock.Of <ILogger <MaintenanceController> >(); var mockFaceClientService = Mock.Of <IFaceClientService>(); var controller = new MaintenanceController(mockFaceClientService, mockLogger); var actionResult = await controller.RemoveFaceAsync($"{Guid.NewGuid()}", null); Assert.NotNull(actionResult); Assert.IsAssignableFrom <BadRequestResult>(actionResult); }
public async Task AddFaceAsync_WithMissingPersonId_ReturnsBadRequest() { var mockLogger = Mock.Of <ILogger <MaintenanceController> >(); var mockFaceClientService = Mock.Of <IFaceClientService>(); var controller = new MaintenanceController(mockFaceClientService, mockLogger); var actionResult = await controller.AddFaceAsync(null, new FaceDto()); Assert.NotNull(actionResult); Assert.IsAssignableFrom <BadRequestResult>(actionResult); }
private void DoChangeStatus(object sender, RoutedEventArgs e) { int id; Int32.TryParse(idText.Text, out id); MaintenanceController.DoChangeMaintainStatus(id); MaintenanceHomePage maintenanceHomePage = new MaintenanceHomePage(); this.NavigationService.Navigate(maintenanceHomePage); MessageBox.Show("Maintain Status Changed !"); }
public async Task BeginTrainingAsync_WithCorrectInput_ReturnsOk() { var mockLogger = Mock.Of <ILogger <MaintenanceController> >(); var mockFaceClientService = Mock.Of <IFaceClientService>(); var controller = new MaintenanceController(mockFaceClientService, mockLogger); var actionResult = await controller.BeginTrainingAsync(); Assert.NotNull(actionResult); Assert.IsAssignableFrom <OkResult>(actionResult); }
public async Task RemoveFaceAsync_WithFaceClientServiceFault_ThrowsException() { var mockLogger = Mock.Of <ILogger <MaintenanceController> >(); var mockFaceClientService = new Mock <IFaceClientService>(); mockFaceClientService .Setup(service => service.RemoveFaceAsync(It.IsNotNull <string>(), It.IsNotNull <string>())) .Throws <NotImplementedException>(); var controller = new MaintenanceController(mockFaceClientService.Object, mockLogger); await Assert.ThrowsAsync <NotImplementedException>(async() => { await controller.RemoveFaceAsync($"{Guid.NewGuid()}", $"{Guid.NewGuid()}"); }); }
public async Task RemoveFaceAsync_WithCorrectInput_ReturnsOk() { var mockLogger = Mock.Of <ILogger <MaintenanceController> >(); var mockFaceClientService = new Mock <IFaceClientService>(); mockFaceClientService .Setup(service => service.RemoveFaceAsync(It.IsNotNull <string>(), It.IsNotNull <string>())); var controller = new MaintenanceController(mockFaceClientService.Object, mockLogger); var actionResult = await controller.RemoveFaceAsync($"{Guid.NewGuid()}", $"{Guid.NewGuid()}"); Assert.NotNull(actionResult); Assert.IsAssignableFrom <NoContentResult>(actionResult); }
public async Task BeginTrainingAsync_WithFaceClientServiceFault_ThrowsException() { var mockLogger = Mock.Of <ILogger <MaintenanceController> >(); var mockFaceClientService = new Mock <IFaceClientService>(); mockFaceClientService .Setup(service => service.BeginTrainingAsync()) .Throws <NotImplementedException>(); var controller = new MaintenanceController(mockFaceClientService.Object, mockLogger); await Assert.ThrowsAsync <NotImplementedException>(async() => { await controller.BeginTrainingAsync(); }); }
public async Task GetTrainingStatusAsync_WithCorrectInput_ReturnsOk() { var mockLogger = Mock.Of <ILogger <MaintenanceController> >(); var mockFaceClientService = new Mock <IFaceClientService>(); mockFaceClientService .Setup(service => service.GetTrainingStatusAsync()) .Returns(() => Task.FromResult(new TrainingStatus { Status = TrainingStatusType.Succeeded })); var controller = new MaintenanceController(mockFaceClientService.Object, mockLogger); var actionResult = await controller.GetTrainingStatusAsync(); Assert.NotNull(actionResult); var okObjectResult = Assert.IsAssignableFrom <OkObjectResult>(actionResult); Assert.IsAssignableFrom <TrainingStatus>(okObjectResult.Value); }
public async Task AddFaceAsync_WithFaceClientServiceFault_ThrowsException() { var mockLogger = Mock.Of <ILogger <MaintenanceController> >(); var mockFaceClientService = new Mock <IFaceClientService>(); mockFaceClientService .Setup(service => service.AddFaceAsync(It.IsNotNull <string>(), It.IsNotNull <string>())) .Throws <NotImplementedException>(); var dto = new FaceDto { FaceUrl = $"http://www.google.com" }; var controller = new MaintenanceController(mockFaceClientService.Object, mockLogger); await Assert.ThrowsAsync <NotImplementedException>(async() => { await controller.AddFaceAsync($"{Guid.NewGuid()}", dto); }); }
private void DoScheduleTime(object sender, RoutedEventArgs e) { int id; Int32.TryParse(idText.Text, out id); if (ConnectionController.GetInstance().Rides.Where(x => x.Id.Equals(id) && x.RideMaintainStatus.Equals("Yes")).FirstOrDefault() != null) { MessageBox.Show("Can's Schedule, Ride is under Maintain"); } else { MessageBox.Show("Ride Maintenance Scheduled !"); } MaintenanceController.DoScheduleMaintainTime(startTime.Text, endTime.Text, id); MaintenanceHomePage maintenanceHomePage = new MaintenanceHomePage(); this.NavigationService.Navigate(maintenanceHomePage); }
public void HourlyMaintenanceTest() { FakeMessageService messageMock = new FakeMessageService(); //Create reminder with unknown email address at first string emailAddress = Guid.NewGuid().ToString() + "@gmx.de"; ReminderModel reminder = GetReminder(emailAddress); var homeController = new HomeController(messageMock); homeController.CreateReminder(reminder); //Verify that no reminder mail has been sent Assert.That(messageMock.ReminderEmailsSentCount, Is.EqualTo(0)); //Insert a remindii directly into the database int mailID = _db.GetEmailID(emailAddress); _db.AddReminder(reminder, mailID, DateTime.Now.AddDays(-1)); //Run hourly maintenance and check that no mail is sent out (email not verified yet) var maintenanceController = new MaintenanceController(messageMock); Assert.That(messageMock.ReminderEmailsSentCount, Is.EqualTo(0)); //Verify user new VerificationController().VerifyMailAddress(messageMock.SentVerificationCode); //Run hourly maintenance and no the reminder should be sent out new MaintenanceController(messageMock).Hourly("1234"); Assert.That(messageMock.ReminderEmailsSentCount, Is.EqualTo(1)); Assert.That(messageMock.SentoutReminder.EmailAddress, Is.EqualTo(emailAddress)); Assert.That(messageMock.SentoutReminder.Name, Is.EqualTo(reminder.Name)); //run hourly again and verify that no other reminder will be sent out new MaintenanceController(messageMock).Hourly("1234"); Assert.That(messageMock.ReminderEmailsSentCount, Is.EqualTo(1)); }
public void HourlyMaintenanceTest() { FakeMessageService messageMock = new FakeMessageService(); //Create reminder with unknown email address at first string emailAddress = Guid.NewGuid().ToString() + "@gmx.de"; ReminderModel reminder = GetReminder( emailAddress ); var homeController = new HomeController( messageMock ); homeController.CreateReminder( reminder ); //Verify that no reminder mail has been sent Assert.That( messageMock.ReminderEmailsSentCount, Is.EqualTo( 0 ) ); //Insert a remindii directly into the database int mailID = _db.GetEmailID( emailAddress ); _db.AddReminder( reminder, mailID, DateTime.Now.AddDays( -1 ) ); //Run hourly maintenance and check that no mail is sent out (email not verified yet) var maintenanceController = new MaintenanceController( messageMock ); Assert.That( messageMock.ReminderEmailsSentCount, Is.EqualTo( 0 ) ); //Verify user new VerificationController().VerifyMailAddress( messageMock.SentVerificationCode ); //Run hourly maintenance and no the reminder should be sent out new MaintenanceController( messageMock ).Hourly( "1234" ); Assert.That( messageMock.ReminderEmailsSentCount, Is.EqualTo( 1 ) ); Assert.That( messageMock.SentoutReminder.EmailAddress, Is.EqualTo( emailAddress ) ); Assert.That( messageMock.SentoutReminder.Name, Is.EqualTo( reminder.Name ) ); //run hourly again and verify that no other reminder will be sent out new MaintenanceController( messageMock ).Hourly( "1234" ); Assert.That( messageMock.ReminderEmailsSentCount, Is.EqualTo( 1 ) ); }