public LoginViewModel(RegistrationService registrationService, INavigationService navigationService) { _registrationService = registrationService; _navigationService = navigationService; _registrationService.AuthorizationFinished += OnAuthorizationFinished; UserName = "******"; }
public void SetUp() { _testContext = new ExpandoObject(); _testContext.Exception = null; _guidFactory = MockRepository.GenerateMock<IGuidFactory>(); _registrationRepository = MockRepository.GenerateMock<IRegistrationRepository>(); _sut = new RegistrationService(_guidFactory, _registrationRepository); _request = new Registration(); }
public void MyService_WhenRegistered_InstantiatedAsInterface_ReturnsValue() { var service = new RegistrationService(); SystemBootstrapper.Init(service, typeof(DotNetCoreTests).Assembly); var srv = SystemBootstrapper.GetInstance <IMyService1>(); Assert.Equal(3, srv.Add(1, 2)); }
private static RegistrationService DefaultSetup(Customer customer) { _validator.IsValid(Arg.Any <Customer>()).Returns(true); _customerRepository.Save(Arg.Any <Customer>()).Returns(customer); _mailer.SendWelcome(Arg.Any <Customer>()).Returns(customer); var sut = new RegistrationService(_validator, _customerRepository, _mailer); return(sut); }
/// <summary> /// Create a Consumer instance based upon the Environment passed. /// </summary> /// <param name="environment">Environment object.</param> /// <param name="settings">Consumer settings. If null, Consumer settings will be read from the SifFramework.config file.</param> /// <param name="sessionService">Consumer session service. If null, the Consumer session will be stored in the SifFramework.config file.</param> protected FunctionalServiceConsumer( Environment environment, IFrameworkSettings settings = null, ISessionService sessionService = null) { ConsumerSettings = settings ?? SettingsManager.ConsumerSettings; environmentTemplate = EnvironmentUtils.MergeWithSettings(environment, ConsumerSettings); registrationService = new RegistrationService(ConsumerSettings, sessionService ?? SessionsManager.ConsumerSessionService); }
public async Task RegisterAsync() { var registrationResource = new CreateRegistrationResource() { EventId = _event.Id }; await RegistrationService.CreateRegistrationAsync(registrationResource); _event = await EventService.GetEventByIdAsync(Id); }
public void RegisterUser_ReturnCorrectID() { string userProfiles = "[{\"Id\":0,\"Nickname\":\"nickname0\",\"words\":[{\"show\":true,\"Count\":0,\"word\":\"Слово0\",\"transfer\":\"Перевод0\"},{\"show\":true,\"Count\":0,\"word\":\"Слово1\",\"transfer\":\"Перевод1\"}]},{\"Id\":1,\"Nickname\":\"nickname1\",\"words\":[{\"show\":true,\"Count\":0,\"word\":\"Слово0\",\"transfer\":\"Перевод0\"},{\"show\":true,\"Count\":0,\"word\":\"Слово1\",\"transfer\":\"Перевод1\"}]}]"; var users = new UserProfileRepositiryStub(userProfiles); var registrationService = new RegistrationService(users); var expectedUserId = 2; var newUserId = registrationService.RegisterUser("testUser"); Assert.AreEqual(expectedUserId, newUserId); }
private readonly RegistrationService _regService; //backend model for registration services /// <summary> /// Login presenter constructor, which creates the interface between the frontend views and backend models /// </summary> /// <param name="view"></param> /// <param name="service"></param> /// <param name="regService"></param> public LoginPresenter(ILoginView view, LoginService service, RegistrationService regService) { //object instances declared in the constructor method call, passed into the presenter fields declared above //allows the presenter to interface between the backend model and the front end UI view _view = view; _service = service; _regService = regService; //button sign-in event handling, passing view properties to the lcoal Login method _view.Login += () => Login(_view.StaffID, _view.Password); //, _view.Role); }
public RegistrationController( RegistrationService registrationService, RegistrationCreation registrationCreation, RegistrationCancelation registrationCancelation, RegistrationConclusion registrationConclusion) { _registrationService = registrationService; _registrationCreation = registrationCreation; _registrationCancelation = registrationCancelation; _registrationConclusion = registrationConclusion; }
public override async Task OnClick() { var response = await RegistrationService.TryToRegister(); await Task.Delay(1000); if (response.response == RegisterAccountResponseType.Success) { await ScreenChangerService.ChangeScreen(ScreenId.Login); } }
public void WhenITryToLoginWithWrongAccount(string wichAccount) { if (wichAccount == "right") { LoginService.Login(RegistrationService.RegisterNewUser(AccountBuilder.CreateAccount())); } else { LoginService.Login(AccountBuilder.CreateAccount()); } }
public void Initialise() { var connection = Effort.DbConnectionFactory.CreateTransient(); _mockContext = new PortalEntityModel(connection); _mockContext.Database.CreateIfNotExists(); _userService = new UserService(_mockContext); _registrationService = new RegistrationService(_mockContext); _tokenService = new TokenService(_mockContext, _userService, _registrationService); }
public ActionResult Navigation() { var regService = new RegistrationService(); var config = regService.FindConfiguration(User.Identity.Name); var model = new NavigationViewModel { UserPicPath = config.ProfilePicturePath, OrgName = config.OrgName }; return(View(model)); }
public ActionResult Configuration() { var regService = new RegistrationService(); var config = regService.FindConfiguration(User.Identity.Name); var model = new ConfigViewModel { Config = config }; return(View(model)); }
public ActionResult DeleteCourseFromEnrollments(int id) { String userId = User.Identity.GetUserId(); var selectedEnrollmentId = id; var context = HttpContext.GetOwinContext().Get <ApplicationDbContext>(); RegistrationService.DeleteCourseService(selectedEnrollmentId, currentEnrollments, context); return(RedirectToAction("StudentAccount", "Courses")); }
public ActionResult Login(LoginViewModel model) { var result = new RegistrationService().Login(model.Login, model.Password); if (result == ELoginResult.OK) { new CookieService(HttpContext.Request, HttpContext.Response).AddUserCookie(model.Login); return(RedirectToAction("Index", "Home")); } CreateErrorMessage(l10n.Translation.LoginErrorMessage); return(View(model)); }
public void InstructorCreateNewCourse() //[email protected] { //Q: can an instructor create a new course? //prep var _context = new MackTechGroupProject.Models.ApplicationDbContext(); var InstructorId = "70575558-0756-4469-bab7-f1a0efbb327d";//[email protected] var currentInstructor = _context.Users.Where(x => x.Id == InstructorId).FirstOrDefault(); var instructorName = currentInstructor.FirstName + " " + currentInstructor.LastName; //create a Course Object var course = new Course { Department = "Psych", CourseNumber = 3010, CourseName = "Advanced Psychology", Instructor = currentInstructor, InstructorName = instructorName, CreditHours = 3, ClassLocation = "WSU", MaxCapacity = 90 }; //Perform Operations //check if the class already exists var hasCourse = RegistrationService.hasCourse(course, InstructorId, _context); //If the class exists delete it if (hasCourse) { RegistrationService.DeleteDuplicateCourse(course, InstructorId, _context); } //check again if class exists var notCurrentCourse = RegistrationService.hasCourse(course, InstructorId, _context); //display result for class not existing Assert.IsFalse(notCurrentCourse); //Add Course using business logic class var CourseAdded = RegistrationService.addNewCourse(course, _context); //display result for sending course to business logic Assert.IsTrue(CourseAdded); //check database that course was actually added var added = _context.Courses.Any(x => x.CourseName == course.CourseName && x.CourseNumber == course.CourseNumber && x.Instructor.Id == InstructorId); Assert.IsTrue(added); }
public void Registering_invalid_customer_should_have_correct_error() { // Arrange var sut = new RegistrationService(_customerRepository, _mailService); // Act var result = sut.RegisterNewCustomer_Error_Handling2(""); // Assert result.Should() .BeEquivalentTo(RegistrationResponse.Fail("invalid name")); }
public JsonResult Index(UserLoginView userToCheck) { //User.Identity.Name отсюда доставешь инфу кто залогинен и показываешь ему инфу основанную на этом if (!ModelState.IsValid) { return(new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { IsSuccess = false } }); } //using (RegistrationService registry = new RegistrationService(SignInManager)) //{ // try // { RegistrationService registry = new RegistrationService(SignInManager); var existedUser = registry.UserValid(userToCheck.Email, userToCheck.Password); if (existedUser != null) { SignInManager.PasswordSignIn(existedUser.UserName, userToCheck.Password, false, false); //SignInManager.SignOut(); var asd = User.Identity.Name; return(new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { IsSuccess = true } }); } ; //} //catch //{ // return new JsonResult() // { // JsonRequestBehavior = JsonRequestBehavior.AllowGet, // Data = new { IsSuccess = false} // }; //return View("Querylist", registry.UserQueries(userToCheck.Id)); //} return(new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { IsSuccess = false } }); //} }
public void MyService_WhenRegistered_InstantiatedAsConcrete_ReturnsValue() { var service = new RegistrationService(); service.Register <MyService1>(); SystemBootstrapper.Init(service, typeof(SimpleInjectorTests).Assembly); var srv = SystemBootstrapper.GetInstance <MyService1>(); Assert.Equal(3, srv.Add(1, 2)); }
public void Registering_valid_customer_happy_path_works() { // Arrange var sut = new RegistrationService(_customerRepository, _mailService); // Act var result = sut.RegisterNewCustomer_Error_Handling2("valid"); // Assert result.Should() .BeEquivalentTo(RegistrationResponse.Success(_customer)); }
public static RegistrationService GetRegistrationService( AbstractValidator<Registration> validator = null, IUserAuthRepository authRepo=null) { var requestContext = new MockRequestContext(); var service = new RegistrationService { RegistrationValidator = validator ?? new RegistrationValidator { UserAuthRepo = GetStubRepo() }, UserAuthRepo = authRepo ?? GetStubRepo(), RequestContext = requestContext }; return service; }
public ActionResult Index() { try { var regService = new RegistrationService(); var config = regService.FindConfiguration(User.Identity.Name); return(View()); } catch (AuthException) { return(RedirectToAction("Login", "Account")); } }
private static RegistrationService GetRegistrationService(AbstractValidator <Registration> validator = null) { var requestContext = new MockRequestContext(); var service = new RegistrationService { RegistrationValidator = validator ?? new RegistrationValidator { UserAuthRepo = GetStubRepo() }, UserAuthRepo = GetStubRepo(), RequestContext = requestContext }; return(service); }
public void Then_Returns_Expected_Results() { BlobService.Received(1).DownloadFileAsync(Arg.Any <BlobStorageData>()); CsvService.Received(1).ReadAndParseFileAsync(Arg.Any <RegistrationCsvRecordRequest>()); RegistrationService.Received(1).ValidateRegistrationTlevelsAsync(AoUkprn, Arg.Any <IEnumerable <RegistrationCsvRecordResponse> >()); CsvService.Received(1).WriteFileAsync(Arg.Any <List <BulkProcessValidationError> >()); BlobService.Received(1).UploadFromByteArrayAsync(Arg.Any <BlobStorageData>()); BlobService.Received(1).MoveFileAsync(Arg.Any <BlobStorageData>()); DocumentUploadHistoryService.Received(1).CreateDocumentUploadHistory(Arg.Any <DocumentUploadHistoryDetails>()); Response.IsSuccess.Should().BeFalse(); Response.BlobUniqueReference.Should().Be(BlobUniqueRef); }
/// <summary> /// constructor of the mangerial presenter /// </summary> /// <param name="view">the interface instance used for the UI</param> /// <param name="serviceRegistration">the instance of the registration service backend class</param> /// <param name="serviceManagerial">instance of the mangerial service backend class</param> /// <param name="staff">staff obect created by a login to the managerial UI</param> public ManagerViewPresenter(IManagerView view, RegistrationService serviceRegistration, ManagerialService serviceManagerial, Staff staff) { //assign the instances of each class from the parameter to the attributes of the presenter //allows the presenter to then interface between the backend and the frontend _view = view; _serviceRegistration = serviceRegistration; _serviceManagerial = serviceManagerial; _staff = staff; //declare the methods that handle events raised by the interface instance _view.SignOut += SignOut; _view.LoadData += LoadData; }
public void Register_GivenAnExistingTeam_ShouldRegisterTeam() { //Given var registration = new Registration(2, 2, 500.00); var registrationRepository = Substitute.For <IRegistrationRepository>(); var registrationService = new RegistrationService(registrationRepository); //When registrationService.Register(registration); //Then registrationRepository.Received(1).Register(registration); }
public void Register_GivenAmountIsLessThanZero_ShouldNotRegiterTeam() { //Given var registration = new Registration(2, 2, -500.00); var registrationRepository = Substitute.For <IRegistrationRepository>(); var registrationService = new RegistrationService(registrationRepository); //When registrationService.Register(registration); //Then registrationRepository.DidNotReceive().Register(registration); }
public RegistrationViewModel( IMvxLogProvider mvxLogProvider, IAppSettings settings, IUserDialogs userDialogs, UserService userService, RegistrationService registrationService) { _mvxLogProvider = mvxLogProvider; _settings = settings; _userDialogs = userDialogs; _userService = userService; _registrationService = registrationService; }
private async void RegisterUser() { if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(confirmPassword)) { await JsRuntime.InvokeAsync <object>("Register.OpenError"); errorMessage = " Please enter all fields"; this.StateHasChanged(); return; } if (password != confirmPassword) { await JsRuntime.InvokeAsync <object>("Register.OpenError"); errorMessage = "Passwords don't matchs"; this.StateHasChanged(); return; } //save the user here var user = new Registration { userName = userName, password = password, confirmPassword = confirmPassword, UserRole = userRole }; var errors = await RegistrationService.RegisterUser(user); if (errors != null && errors.ModelState.Any()) { modelStateErrors = errors.ModelState; await JsRuntime.InvokeAsync <object>("Register.OpenError"); //get the page in sync with the server- like refreshing a page in a traditional app. This is necessary because without it, the div opens without the populated error message //in Blazor, every single thing seems to cause the page to fire again- even making an an API call this.StateHasChanged(); } else { errorMessage = "Registered!"; await JsRuntime.InvokeAsync <object>("Register.OpenError"); this.StateHasChanged(); } }
public ResponseBaseDto <OutsourcerRegistrationResponseDto> RegisterOutsourcer(OutsourcerRegistrationRequestDto dto) { var requestDomain = RegistrationMapper.Map(dto); var responseDomain = RegistrationService.RegisterOutsourcer(requestDomain); var responseDto = RegistrationMapper.Map(responseDomain); return(responseDto.Id == 0 ? new ResponseBaseDto <OutsourcerRegistrationResponseDto> { Error = responseDomain.Message } : new ResponseBaseDto <OutsourcerRegistrationResponseDto> { Data = responseDto, IsSuccess = true }); }
public ActionResult Querylist() { using (RegistrationService registry = new RegistrationService(_manager)) { if (User.Identity.IsAuthenticated) { return(View(registry.UserQueries(User.Identity.Name))); } else { return(View("~/Views/CreateAjax/Index.cshtml")); } } }
public ActionResult TestAccount() { var regService = new RegistrationService(); if (regService.Login(ConfigurationSettings.TestLogin, ConfigurationSettings.TestPassword)) { FormsAuthentication.SetAuthCookie(ConfigurationSettings.TestLogin, true); return(RedirectToAction("Index", "Manager")); } else { return(RedirectToAction("Login", "Account")); } }
/// <summary> /// SCORM Engine Service constructor that takes a single configuration parameter /// </summary> /// <param name="config">The Configuration object to be used to configure the Scorm Engine Service client</param> public ScormEngineService(Configuration config) { System.Net.ServicePointManager.Expect100Continue = false; configuration = config; courseService = new CourseService(configuration, this); dispatchService = new DispatchService(configuration, this); registrationService = new RegistrationService(configuration, this); invitationService = new InvitationService(configuration, this); uploadService = new UploadService(configuration, this); ftpService = new FtpService(configuration, this); exportService = new ExportService(configuration, this); reportingService = new ReportingService(configuration, this); debugService = new DebugService(configuration, this); }
public void Empty_Registration_is_invalid() { var service = new RegistrationService { RegistrationValidator = new RegistrationValidator { UserAuthRepo = GetStubRepo() }, UserAuthRepo = GetStubRepo() }; var response = (HttpError)service.Post(new Registration()); var errors = response.GetFieldErrors(); Assert.That(errors.Count, Is.EqualTo(3)); Assert.That(errors[0].ErrorCode, Is.EqualTo("NotEmpty")); Assert.That(errors[0].FieldName, Is.EqualTo("Password")); Assert.That(errors[1].ErrorCode, Is.EqualTo("NotEmpty")); Assert.That(errors[1].FieldName, Is.EqualTo("UserName")); Assert.That(errors[2].ErrorCode, Is.EqualTo("NotEmpty")); Assert.That(errors[2].FieldName, Is.EqualTo("Email")); }
public static RegistrationService GetRegistrationService( AbstractValidator<Registration> validator = null, IUserAuthRepository authRepo=null) { var requestContext = new MockRequestContext(); var userAuthRepository = authRepo ?? GetStubRepo(); var service = new RegistrationService { RegistrationValidator = validator ?? new RegistrationValidator { UserAuthRepo = userAuthRepository }, UserAuthRepo = userAuthRepository, RequestContext = requestContext, }; var appHost = GetAppHost(); appHost.Register(userAuthRepository); service.SetAppHost(appHost); return service; }
public void Accepts_valid_registration() { var service = new RegistrationService { RegistrationValidator = new RegistrationValidator { UserAuthRepo = GetStubRepo() }, UserAuthRepo = GetStubRepo() }; var request = new Registration { DisplayName = "DisplayName", Email = "*****@*****.**", FirstName = "FirstName", LastName = "LastName", Password = "******", UserName = "******", }; var response = service.Post(request); Assert.That(response as RegistrationResponse, Is.Not.Null); }
public static RegistrationService GetRegistrationService( IUserAuthRepository userAuthRepository, AuthUserSession oAuthUserSession = null, MockRequestContext requestContext = null) { if (requestContext == null) requestContext = new MockRequestContext(); if (oAuthUserSession == null) oAuthUserSession = requestContext.ReloadSession(); var httpReq = requestContext.Get<IHttpRequest>(); var httpRes = requestContext.Get<IHttpResponse>(); oAuthUserSession.Id = httpRes.CreateSessionId(httpReq); httpReq.Items[ServiceExtensions.RequestItemsSessionKey] = oAuthUserSession; var mockAppHost = new BasicAppHost { Container = requestContext.Container }; requestContext.Container.Register(userAuthRepository); var authService = new AuthService { RequestContext = requestContext, }; authService.SetAppHost(mockAppHost); mockAppHost.Register(authService); var registrationService = new RegistrationService { UserAuthRepo = userAuthRepository, RequestContext = requestContext, RegistrationValidator = new RegistrationValidator { UserAuthRepo = RegistrationServiceTests.GetStubRepo() }, }; registrationService.SetAppHost(mockAppHost); return registrationService; }
public RiddleListViewModel(RegistrationService registrationService) { _registrationService = registrationService; Riddles = new ObservableCollection<riddle>(); }
// This function will be called when scene loaded: void Start() { //init components viewByName = new Hashtable (); loginService = (LoginService)gameObject.AddComponent("LoginService"); registrationService = (RegistrationService)gameObject.AddComponent("RegistrationService"); loginView = (LoginView)gameObject.AddComponent("LoginView"); registrationView = (RegistrationView)gameObject.AddComponent("RegistrationView"); // Setup of login view: loginView.guiSkin = guiSkin; loginView.header1Style = header1Style; loginView.header2Style = header2Style; loginView.header2ErrorStyle = header2ErrorStyle; loginView.formFieldStyle = formFieldStyle; // Handler of registration button click: loginView.registrationHandler = delegate(){ // Clear reistration fields: registrationView.data.clear(); // Set active view to registration: activeViewName = RegistrationView.NAME; }; // Setup of login view: registrationView.guiSkin = guiSkin; registrationView.header2Style = header2Style; registrationView.formFieldStyle = formFieldStyle; registrationView.errorMessageStyle = errorMessageStyle; // Handler of cancel button click: registrationView.cancelHandler = delegate() { // Clear reistration fields: loginView.data.clear(); // Set active view to registration: activeViewName = LoginView.NAME; }; viewByName = new Hashtable(); // Adding views to views by name map: viewByName[LoginView.NAME] = loginView; viewByName[RegistrationView.NAME] = registrationView; loginView.loginHandler = delegate() { blockUI = true; // Sending login request: loginService.sendLoginData(loginView.data, loginResponseHandler); }; // Handler of Register button: registrationView.registrationHandler = delegate() { blockUI = true; // Sending registration request: registrationService.sendRegistrationData(registrationView.data, registrationResponseHandler); }; }
public SyncViewModel(RegistrationService registrationService, ConnectionStore connectionStore) { _registrationService = registrationService; _connectionStore = connectionStore; Status = "未连接"; }
public void Requires_unique_UserName_and_Email() { var mock = new Mock<IUserAuthRepository>(); var mockExistingUser = new UserAuth(); mock.Expect(x => x.GetUserAuthByUserName(It.IsAny<string>())) .Returns(mockExistingUser); var service = new RegistrationService { RegistrationValidator = new RegistrationValidator { UserAuthRepo = mock.Object }, UserAuthRepo = mock.Object, }; var request = new Registration { DisplayName = "DisplayName", Email = "*****@*****.**", FirstName = "FirstName", LastName = "LastName", Password = "******", UserName = "******", }; var response = PostRegistrationError(service, request); var errors = response.GetFieldErrors(); Assert.That(errors.Count, Is.EqualTo(2)); Assert.That(errors[0].ErrorCode, Is.EqualTo("AlreadyExists")); Assert.That(errors[0].FieldName, Is.EqualTo("UserName")); Assert.That(errors[1].ErrorCode, Is.EqualTo("AlreadyExists")); Assert.That(errors[1].FieldName, Is.EqualTo("Email")); }
public void Can_login_with_user_created_CreateUserAuth(IUserAuthRepository userAuthRepository) { ((IClearable)userAuthRepository).Clear(); var request = new Registration { UserName = "******", Password = "******", Email = "*****@*****.**", DisplayName = "DisplayName", FirstName = "FirstName", LastName = "LastName", }; var loginService = new RegistrationService { UserAuthRepo = userAuthRepository, RegistrationValidator = new RegistrationValidator { UserAuthRepo = RegistrationServiceTests.GetStubRepo() }, }; var responseObj = loginService.Post(request); var httpResult = responseObj as IHttpResult; if (httpResult != null) { Assert.Fail("HttpResult found: " + httpResult.Dump()); } var response = (RegistrationResponse)responseObj; Assert.That(response.UserId, Is.Not.Null); var userAuth = userAuthRepository.GetUserAuth(response.UserId); AssertEqual(userAuth, request); userAuth = userAuthRepository.GetUserAuthByUserName(request.UserName); AssertEqual(userAuth, request); userAuth = userAuthRepository.GetUserAuthByUserName(request.Email); AssertEqual(userAuth, request); string userId; var success = userAuthRepository.TryAuthenticate(request.UserName, request.Password, out userId); Assert.That(success, Is.True); Assert.That(userId, Is.Not.Null); success = userAuthRepository.TryAuthenticate(request.Email, request.Password, out userId); Assert.That(success, Is.True); Assert.That(userId, Is.Not.Null); success = userAuthRepository.TryAuthenticate(request.UserName, "Bad Password", out userId); Assert.That(success, Is.False); Assert.That(userId, Is.Null); }
public static RegistrationService GetRegistrationService( IUserAuthRepository userAuthRepository, AuthUserSession oAuthUserSession = null, MockRequestContext requestContext = null) { if (requestContext == null) requestContext = new MockRequestContext(); if (oAuthUserSession == null) oAuthUserSession = requestContext.ReloadSession(); var httpReq = requestContext.Get<IHttpRequest>(); var httpRes = requestContext.Get<IHttpResponse>(); oAuthUserSession.Id = httpRes.CreateSessionId(httpReq); httpReq.Items[ServiceExtensions.RequestItemsSessionKey] = oAuthUserSession; var registrationService = new RegistrationService { UserAuthRepo = userAuthRepository, RequestContext = requestContext, RegistrationValidator = new RegistrationValidator { UserAuthRepo = RegistrationServiceTests.GetStubRepo() }, }; return registrationService; }
private static HttpError PostRegistrationError(RegistrationService service, Registration registration) { var response = (HttpError) service.RunAction(registration, (svc, req) => svc.Post(req)); return response; }