예제 #1
0
        [Test]       //!!
        public void AuthPresenterOnLoginPasswordNullTest()
        {
            var mockView = new Mock <IAuthView>(MockBehavior.Strict);

            VievLocaleSetup(mockView);
            mockView.Setup(t => t.ShowErrorMessage(It.IsAny <string>()));
            AuthPresenter presenter = new AuthPresenter(mockView.Object, new Mock <IAuthRouter>().Object);

            Assert.Throws <ArgumentNullException>(() => mockView.Raise(t => t.OnLoginBtnPressed += null, "Login", null));
            VievLocaleVerify(mockView);
        }
예제 #2
0
        [Test]//!!
        public void AuthPresenterConstructorPositiveTest()
        {
            var mockRouter = new Mock <IAuthRouter>(MockBehavior.Strict);
            var mockView   = new Mock <IAuthView>(MockBehavior.Strict);

            VievLocaleSetup(mockView);

            IAuthPresenter prsenter = new AuthPresenter(mockView.Object, mockRouter.Object);

            VievLocaleVerify(mockView);
        }
예제 #3
0
        [Test]//!!
        public void AuthPresenterOnLoginPasswordEmptyTest()
        {
            var mockView = new Mock <IAuthView>(MockBehavior.Strict);

            VievLocaleSetup(mockView);
            mockView.Setup(t => t.ShowErrorMessage(It.IsAny <string>()));
            AuthPresenter presenter = new AuthPresenter(mockView.Object, new Mock <IAuthRouter>().Object);

            mockView.Raise(t => t.OnLoginBtnPressed += null, "Login", "");
            VievLocaleVerify(mockView);
            mockView.Verify(t => t.ShowErrorMessage(It.IsAny <string>()), Times.Once);
        }
예제 #4
0
        [Test]        //!!
        public void AuthPresenterOnLoginEventHandlingTest()
        {
            var mockView = new Mock <IAuthView>(MockBehavior.Strict);

            VievLocaleSetup(mockView);
            AuthPresenter presenter = new AuthPresenter(mockView.Object, new Mock <IAuthRouter>().Object);

            //presenter.OnLogInAttempt += (l, p) => onLoginCalled++;
            presenter.OnLogInAttempt += (l, p) => Assert.Pass();
            mockView.Raise(t => t.OnLoginBtnPressed += null, "Login", "Password");
            VievLocaleVerify(mockView);
            //Assert.That(onLoginCalled,Is.EqualTo(1));
            Assert.Fail("Don't invoke");
        }
예제 #5
0
        private void buttonLogin_Click(object sender, EventArgs e) // аутентификация
        {
            string login    = textBoxLogin.Text;
            string password = textBoxPassword.Text;

            AuthPresenter.activeUser = AuthPresenter.authenticate(AuthPresenter.activeUser, login, password);
            if (AuthPresenter.activeUser == null)
            {
                MessageBox.Show("Login or password is invalid!");
                return;
            }
            textBoxPassword.Clear();
            if (AuthPresenter.activeUser.isAdmin)
            {
                adminAccess();
            }
            else
            {
                workerAccess();
            }
        }
예제 #6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            View view = LayoutInflater.Inflate(Resource.Layout.AuthorizationLayout, null, false);


            //Initializing Viper
            AuthorizationView authView = view as AuthorizationView;

            authView.InitializeAuthView();



            /*   DetailedInfoFacadeView detailedInfoView = view as DetailedInfoFacadeView;
             * string entityId = Intent.GetStringExtra(EntityId_ExtraKey);
             * IDetailsPresenter presenter = new DetailedInfoPresenter(detailedInfoView, new DetailedInfoInteractor(RepositoryFactory.service, entityId), new DetailedInfoRouter(this));
             * detailedInfoView.InitializeView(presenter, entityId == "TempEntityId");*/
            IAuthPresenter  authPresenter  = new AuthPresenter(authView, new AuthRouter(this));
            IAuthInteractor authInteractor = new AuthInteractor(new UserDataService(), authPresenter);

            SetContentView(view);
        }
예제 #7
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            _app = (AuthApp)Application;
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var request    = new Request();
            var interactor = new AuthInteractor(request);

            var btnLogin  = FindViewById <Button>(Resource.Id.button_login);
            var txtLogin  = FindViewById <EditText>(Resource.Id.editText_login);
            var txtPass   = FindViewById <EditText>(Resource.Id.editText_pass);
            var presenter = new AuthPresenter(interactor, this, this);

            btnLogin.Click += (sender, args) =>
            {
                presenter.Authorize(txtLogin.Text, txtPass.Text);
            };
            // Get our button from the layout resource,
            // and attach an event to it
        }
예제 #8
0
 private void InitializeViper()
 {
     IAuthPresenter  presenter  = new AuthPresenter(_authPageView, new AuthRouter(NavigationController));
     IAuthInteractor interactor = new AuthInteractor(new UserDataService(), presenter);
 }