예제 #1
0
        public void TestRegisterNewUserWithId()
        {
            RunAndAwait(() =>
            {
                Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY, Defaults.TEST_VERSION);
                Backendless.UserService.Register(GetRandomNotRegisteredUser(),
                                                 new ResponseCallback <BackendlessUser>(this)
                {
                    ResponseHandler = response =>
                    {
                        BackendlessUser fakeUser = GetRandomNotRegisteredUser();
                        fakeUser.UserId          = response.UserId;

                        Backendless.UserService.Register(fakeUser,
                                                         new ResponseCallback <BackendlessUser>(
                                                             this)
                        {
                            ResponseHandler =
                                user =>
                                FailCountDownWith(
                                    "Server accepted a user with id value"),
                            ErrorHandler =
                                fault =>
                                CheckErrorCode(3039, fault)
                        });
                    }
                });
            });
        }
예제 #2
0
        public void TestRestoreUserPassword()
        {
            Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
            BackendlessUser user = GetRandomLoggedInUser();

            Backendless.UserService.RestorePassword((string)user.GetProperty(LOGIN_KEY));
        }
예제 #3
0
    void Awake()
    {
        DontDestroyOnLoad(this);

#if UNITY_WEBPLAYER
#error WEBPLAYER PROXY IMPLEMENT
        Backendless.setUrl("");
        string proxyIp   = "";
        int    proxyPort = 0;
        Security.PrefetchSocketPolicy(proxyIp, proxyPort);
#else
        if (Server == SERVER.GMO_MBAAS)
        {
            Backendless.setUrl("https://api.gmo-mbaas.com");
        }
        else
        {
            Backendless.setUrl("https://api.backendless.com");
        }
#endif

        Backendless.InitApp(applicationId, RestSecretKey, version);
#if ENABLE_PUSH_PLUGIN
        Backendless.Messaging.SetUnityRegisterDevice(UnityRegisterDevice, UnityUnregisterDevice);
#if UNITY_ANDROID
        AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        activity = jc.GetStatic <AndroidJavaObject>("currentActivity");
        activity.Call("setUnityGameObject", this.gameObject.name);
#elif UNITY_IPHONE
        setListenerGameObject(this.gameObject.name);
#endif
#endif
    }
예제 #4
0
        public void TestRegisterNewUser()
        {
            RunAndAwait(() =>
            {
                Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
                BackendlessUser user = GetRandomNotRegisteredUser();
                string propertyKey   = "property_key#" + Random.Next();
                string propertyValue = "property_value#" + Random.Next();
                user.SetProperty(propertyKey, propertyValue);
                Backendless.UserService.Register(user,
                                                 new ResponseCallback <BackendlessUser>(this)
                {
                    ResponseHandler = response =>
                    {
                        UsedProperties.Add(propertyKey);
                        Assert.IsNotNull(response.GetProperty("id"),
                                         "UserService.register didn't set user ID");

                        foreach (String key in user.Properties.Keys)
                        {
                            Assert.IsTrue(response.Properties.ContainsKey(key),
                                          "Registered user didn`t contain expected property " +
                                          key);
                            Assert.AreEqual(user.GetProperty(key), response.GetProperty(key),
                                            "UserService.register changed property " + key);
                        }

                        CountDown();
                    }
                });
            });
        }
예제 #5
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(Defaults.APPLICATION_ID) || string.IsNullOrEmpty(Defaults.SECRET_KEY) ||
                string.IsNullOrEmpty(Defaults.VERSION))
            {
                NavigationService.Navigate(new Uri("/ErrorPage.xaml", UriKind.Relative));
                return;
            }

            Backendless.InitApp(Defaults.APPLICATION_ID, Defaults.SECRET_KEY, Defaults.VERSION);
            DataStore = Backendless.Persistence.Of <ToDoEntity>();

            EntitiesDataGrid.DataContext = _toDoList;
            _toDoList.CollectionChanged +=
                (senderObj, args) => Footer.Visibility = _toDoList.Count == 0 ? Visibility.Collapsed : Visibility.Visible;

            AsyncStartedEvent += () =>
            {
                ProgressBar.Visibility = Visibility.Visible;
                ContentPanel.Opacity   = 0.1;
            };
            AsyncFinishedEvent += () =>
            {
                ProgressBar.Visibility = Visibility.Collapsed;
                ContentPanel.Opacity   = 1;
            };

            AsyncStartedEvent.Invoke();
            DataStore.Find(new AsyncCallback <BackendlessCollection <ToDoEntity> >(response => Dispatcher.BeginInvoke(() =>
            {
                _toDoList.AddAll(response.GetCurrentPage());
                AsyncFinishedEvent.Invoke();
            }), fault => Dispatcher.BeginInvoke(() => AsyncFinishedEvent.Invoke())));
        }
예제 #6
0
        public void TestRegisterNewUserWithDuplicateIdentity()
        {
            RunAndAwait(() =>
            {
                Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
                Backendless.UserService.Register(GetRandomNotRegisteredUser(),
                                                 new ResponseCallback <BackendlessUser>(this)
                {
                    ResponseHandler = response =>
                    {
                        BackendlessUser fakeUser = GetRandomNotRegisteredUser();
                        fakeUser.SetProperty(LOGIN_KEY, response.GetProperty(LOGIN_KEY));

                        Backendless.UserService.Register(fakeUser,
                                                         new ResponseCallback <BackendlessUser>(
                                                             this)
                        {
                            ResponseHandler =
                                user =>
                                FailCountDownWith(
                                    "Server accepted a user with id value"),
                            ErrorHandler =
                                fault =>
                                CheckErrorCode(3033, fault)
                        });
                    }
                });
            });
        }
예제 #7
0
        public void TestDescribeUserProperties()
        {
            Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
            BackendlessUser user             = GetRandomNotRegisteredUser();
            string          propertyKeySync  = "property_key#Sync";
            string          propertyKeyAsync = "property_key#Async";

            user.SetProperty(propertyKeySync, "porperty_value#" + Random.Next());
            Backendless.UserService.Register(user);
            Backendless.UserService.Login((string)user.GetProperty(LOGIN_KEY), user.Password);
            List <UserProperty> userProperties = Backendless.UserService.DescribeUserClass();

            Assert.IsNotNull(userProperties, "Server returned null user properties");
            Assert.IsTrue(userProperties.Count != 0, "Server returned empty user properties");

            var properties = new List <string> {
                propertyKeySync, propertyKeyAsync, ID_KEY, LOGIN_KEY, PASSWORD_KEY, EMAIL_KEY
            };

            foreach (UserProperty userProperty in userProperties)
            {
                Assert.IsNotNull(userProperty, "User property was null");
                Assert.IsTrue(properties.Contains(userProperty.Name),
                              "User properties contained unexpected property " + userProperty.Name);
                Assert.IsNotNull(userProperty.Type, "User properties type was null");
            }
        }
예제 #8
0
        public void TestUpdateRegisteredUserEmailAndPassword()
        {
            RunAndAwait(() =>
            {
                string newpassword = "******";
                string newemail    = "*****@*****.**";
                Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY, Defaults.TEST_VERSION);
                GetRandomLoggedInUser(new ResponseCallback <BackendlessUser>(this)
                {
                    ResponseHandler = user =>
                    {
                        user.Password = newpassword;
                        user.SetProperty(EMAIL_KEY, newemail);

                        Backendless.UserService.Update(user,
                                                       new ResponseCallback <BackendlessUser>(this)
                        {
                            ResponseHandler = response =>
                            {
                                Assert.AreEqual(newpassword, user.Password,
                                                "Updated used has a wrong password");
                                Assert.AreEqual(newemail, user.GetProperty(EMAIL_KEY),
                                                "Updated used has a wrong email");
                                CountDown();
                            }
                        });
                    }
                });
            });
        }
예제 #9
0
        public void TestUpdateUserForVersionWithEnabledDynamicPropertis()
        {
            RunAndAwait(() =>
            {
                Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY, Defaults.TEST_VERSION);
                GetRandomLoggedInUser(new ResponseCallback <BackendlessUser>(this)
                {
                    ResponseHandler = user =>
                    {
                        string propertyKey   = "somePropertyKey" + Random.Next();
                        string propertyValue = "somePropertyValue" + Random.Next();
                        user.SetProperty(propertyKey, propertyValue);

                        foreach (String usedProperty in UsedProperties)
                        {
                            user.SetProperty(usedProperty, "someValue");
                        }

                        Backendless.UserService.Update(user,
                                                       new ResponseCallback <BackendlessUser>(this)
                        {
                            ResponseHandler = response =>
                            {
                                UsedProperties.Add(propertyKey);
                                Backendless.UserService.Login(response.Email, response.Password);
                                Backendless.UserService.DescribeUserClass(
                                    new ResponseCallback <List <UserProperty> >(this)
                                {
                                    ResponseHandler = userProperties =>
                                    {
                                        Assert.IsNotNull(userProperties,
                                                         "Server returned null user properties");
                                        Assert.IsTrue(userProperties.Count != 0,
                                                      "Server returned empty user properties");

                                        bool flag = false;
                                        foreach (UserProperty userProperty in userProperties)
                                        {
                                            if (userProperty.Name.Equals(propertyKey))
                                            {
                                                flag = true;
                                                Assert.IsTrue(
                                                    userProperty.Type.Equals(DateTypeEnum.STRING),
                                                    "Property had wrong type");
                                            }
                                        }

                                        Assert.IsTrue(flag, "Expected property was not found");
                                        CountDown();
                                    }
                                });
                            }
                        });
                    }
                });
            });
        }
예제 #10
0
        public void TestUserLogout()
        {
            Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
            BackendlessUser user = GetRandomLoggedInUser();

            Backendless.UserService.Logout();

            Assert.IsTrue(Backendless.UserService.CurrentUser == null, "Current user was not empty");
        }
예제 #11
0
        public void TestUpdateRegisteredUserIdentity()
        {
            Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
            BackendlessUser user = GetRandomLoggedInUser();

            user.SetProperty(LOGIN_KEY, "some_new_login_" + user.GetProperty(LOGIN_KEY));

            Backendless.UserService.Update(user);
        }
예제 #12
0
        public void SetUp()
        {
            Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);

            messageStatus = null;
            latch         = null;
            message       = null;
            publisher     = null;
            headers       = null;
            testResult    = null;
        }
예제 #13
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(Defaults.APPLICATION_ID) || string.IsNullOrEmpty(Defaults.SECRET_KEY) ||
                string.IsNullOrEmpty(Defaults.VERSION))
            {
                NavigationService.Navigate(new Uri("/ErrorPage.xaml", UriKind.Relative));
                return;
            }

            Backendless.InitApp(Defaults.APPLICATION_ID, Defaults.SECRET_KEY, Defaults.VERSION);
        }
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                );

            Backendless.InitApp("89076717-7C81-9CCB-FF27-212BF1C56C00", "89F7667F-FDD9-4668-FFE1-831793BDB000", "v1");
        }
예제 #15
0
 public void TestRegisterNewUserFromNull()
 {
     try
     {
         Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY, Defaults.TEST_VERSION);
         Backendless.UserService.Register(null);
         Assert.Fail("UserService accepted a null user");
     }
     catch (System.Exception t)
     {
         CheckErrorCode(ExceptionMessage.NULL_USER, t);
     }
 }
예제 #16
0
        public void TestUpdateRegisteredUserIdentity()
        {
            Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY, Defaults.TEST_VERSION);
            GetRandomLoggedInUser(new ResponseCallback <BackendlessUser>(this)
            {
                ResponseHandler = user =>
                {
                    user.SetProperty(LOGIN_KEY, "some_new_login_" + user.GetProperty(LOGIN_KEY));

                    Backendless.UserService.Update(user, new ResponseCallback <BackendlessUser>(this));
                }
            });
        }
예제 #17
0
 public void TestLoginWithNullPassword()
 {
     try
     {
         Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY, Defaults.TEST_VERSION);
         Backendless.UserService.Login((string)GetRandomRegisteredUser().Email, null);
         Assert.Fail("UserService accepted null password");
     }
     catch (System.Exception t)
     {
         CheckErrorCode(BackendlessAPI.Exception.ExceptionMessage.NULL_PASSWORD, t);
     }
 }
예제 #18
0
 public void TestRegisterNewUserFromEmptyUser()
 {
     try
     {
         Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
         Backendless.UserService.Register(new BackendlessUser());
         Assert.Fail("UserService accepted a null user");
     }
     catch (System.Exception t)
     {
         CheckErrorCode(ExceptionMessage.NULL_PASSWORD, t);
     }
 }
예제 #19
0
 public void TestRestoreUserPassword()
 {
     RunAndAwait(() =>
     {
         Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY, Defaults.TEST_VERSION);
         GetRandomRegisteredUser(new ResponseCallback <BackendlessUser>(this)
         {
             ResponseHandler =
                 response =>
                 Backendless.UserService.RestorePassword((string)response.Email,
                                                         new ResponseCallback <object>(this))
         });
     });
 }
예제 #20
0
 public void TestLoginWithProperCredentials()
 {
     try
     {
         Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY, Defaults.TEST_VERSION);
         BackendlessUser user = GetRandomRegisteredUser();
         Backendless.UserService.Login((string)user.Email, user.Password);
         Backendless.UserService.DescribeUserClass();
     }
     catch (System.Exception t)
     {
         Assert.Fail(t.Message);
     }
 }
예제 #21
0
 public void TestRestoreUserPassword()
 {
     RunAndAwait(() =>
     {
         Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
         GetRandomLoggedInUser(new ResponseCallback <BackendlessUser>(this)
         {
             ResponseHandler =
                 response =>
                 Backendless.UserService.RestorePassword((string)response.GetProperty(LOGIN_KEY),
                                                         new ResponseCallback <object>(this))
         });
     });
 }
예제 #22
0
 public void TestLoginWithNullLogin()
 {
     try
     {
         Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY, Defaults.TEST_VERSION);
         Backendless.UserService.Login(null, GetRandomRegisteredUser().Password);
         Backendless.UserService.Logout();
         Assert.Fail("UserService accepted null Login");
     }
     catch (System.Exception t)
     {
         CheckErrorCode(Exception.ExceptionMessage.NULL_LOGIN, t);
     }
 }
예제 #23
0
        private void InitApi()
        {
            String appId     = "A3D96FA2-7314-2543-FF66-0B60549D7300";
            String secretKey = "97ABCC00-2E19-E4F9-FFCA-B3721842F100";

            Backendless.URL = "http://api.backendless.com";
            try
            {
                Backendless.InitApp(appId, secretKey);
            }
            catch (Exception e)
            {
            }
        }
예제 #24
0
 public void TestRestoreUserPasswordWithWrongLogin()
 {
     try
     {
         Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY, Defaults.TEST_VERSION);
         BackendlessUser user = GetRandomLoggedInUser();
         Backendless.UserService.RestorePassword("fake_login_" + user.Email);
         Assert.Fail("Server accepted wrong login.");
     }
     catch (System.Exception t)
     {
         CheckErrorCode(3020, t);
     }
 }
예제 #25
0
 public void TestLoginWithWrongCredentials()
 {
     try
     {
         Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY, Defaults.TEST_VERSION);
         var user = GetRandomRegisteredUser();
         Backendless.UserService.Login(user.Email + "foobar", user.Password + "foobar");
         Assert.Fail("Server accepted wrong credentials");
     }
     catch (System.Exception t)
     {
         CheckErrorCode(3003, t);
     }
 }
예제 #26
0
        public void TestRegisterNewUserAtAppWithDisabledRegistration()
        {
            try
            {
                Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);

                Backendless.UserService.Register(GetRandomNotRegisteredUser());

                Assert.Fail("Server accepted registration for an application with disabled registration");
            }
            catch (System.Exception t)
            {
                CheckErrorCode(3009, t);
            }
        }
예제 #27
0
        private void InitApi()
        {
            String appId     = "9BA31C05-1D39-4DE3-FF50-38EED1144E00";
            String secretKey = "2BC1BACF-E7BC-7EDD-FF99-41B49CF02700";

            Backendless.URL = "http://api.backendless.com";
            try
            {
                Backendless.InitApp(appId, secretKey);
            }
            catch (Exception e)
            {
                Console.Write($"Error {e.Message}");
            }
        }
예제 #28
0
        public void TestUpdateUserWithWrongUserId()
        {
            try
            {
                Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
                BackendlessUser user = GetRandomLoggedInUser();
                user.SetProperty("id", "foobar");

                Backendless.UserService.Update(user);
                Assert.Fail("User with wrong id accepted");
            }
            catch (BackendlessException t)
            {
                CheckErrorCode(3029, t);
            }
        }
예제 #29
0
        public void TestUpdateUserWithEmptyUserId()
        {
            try
            {
                Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
                BackendlessUser user = GetRandomLoggedInUser();
                user.SetProperty("id", "");

                Backendless.UserService.Update(user);
                Assert.Fail("User with empty id accepted");
            }
            catch (System.Exception t)
            {
                CheckErrorCode(ExceptionMessage.WRONG_USER_ID, t);
            }
        }
예제 #30
0
        public void TestUpdateRegisteredUserEmailAndPassword()
        {
            const string newpassword = "******";
            const string newemail    = "*****@*****.**";

            Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
            BackendlessUser user = GetRandomLoggedInUser();

            user.Password = newpassword;
            user.SetProperty(EMAIL_KEY, newemail);

            Backendless.UserService.Update(user);

            Assert.AreEqual(newpassword, user.Password, "Updated used has a wrong password");
            Assert.AreEqual(newemail, user.GetProperty(EMAIL_KEY), "Updated used has a wrong email");
        }