Ejemplo n.º 1
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();
                    }
                });
            });
        }
Ejemplo n.º 2
0
        public void TestCurrentUserAfterLogin()
        {
            try
            {
                BackendlessUser notRegisteredUseruser = GetRandomNotRegisteredUser();
                string          propertyKey           = "propertykey" + Random.Next();
                string          propertyValue         = "property_value#" + Random.Next();
                notRegisteredUseruser.SetProperty(propertyKey, propertyValue);

                BackendlessUser user = Backendless.UserService.Register(notRegisteredUseruser);
                UsedProperties.Add(propertyKey);

                user = Backendless.UserService.Login((string)user.GetProperty(LOGIN_KEY), user.Password);

                Assert.IsNotNull(Backendless.UserService.CurrentUser, "Current user was null");

                foreach (string key in user.Properties.Keys)
                {
                    if (key.Equals("password"))
                    {
                        continue;
                    }

                    Assert.IsTrue(Backendless.UserService.CurrentUser.Properties.ContainsKey(key), "Current user didn`t contain expected property " + key);
                    Assert.AreEqual(user.GetProperty(key), Backendless.UserService.CurrentUser.GetProperty(key), "UserService.register changed property " + key);
                }
            }
            catch (System.Exception t)
            {
                Assert.Fail(t.Message);
            }
        }
Ejemplo n.º 3
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();
                                    }
                                });
                            }
                        });
                    }
                });
            });
        }
Ejemplo n.º 4
0
		// ----------------------------------------------------------------------------------------

		/// <summary>
		/// 
		/// </summary>
		/// <typeparam name="TProperty">property type</typeparam>
		/// <param name="expression">a lambda expression of the type s => s.PropertyName</param>
		/// <returns>if this property is populated</returns>
		protected bool IsUsedProperty<TProperty>(Expression<Func<TStepRow, TProperty>> expression)
		{
			var uses = false;
			var memberExpression = expression.Body as MemberExpression;

			// ReSharper disable once InvertIf
			if (memberExpression != null &&
				memberExpression.Member.MemberType == MemberTypes.Property)
			{
				var sPropertyName = memberExpression.Member.Name;
				uses = (UsedProperties.Contains(sPropertyName));
			}
			return uses;
		}
Ejemplo n.º 5
0
        public void TestCurrentUserAfterLogin()
        {
            RunAndAwait(() =>
            {
                BackendlessUser notRegisteredUseruser = GetRandomNotRegisteredUser();
                string propertyKey   = "propertykey" + Random.Next();
                string propertyValue = "property_value#" + Random.Next();
                notRegisteredUseruser.SetProperty(propertyKey, propertyValue);

                Backendless.UserService.Register(notRegisteredUseruser,
                                                 new ResponseCallback <BackendlessUser>(this)
                {
                    ResponseHandler = response =>
                    {
                        UsedProperties.Add(propertyKey);
                        Backendless.UserService.Login(
                            (string)response.GetProperty(LOGIN_KEY), response.Password,
                            new ResponseCallback <BackendlessUser>(this)
                        {
                            ResponseHandler = user =>
                            {
                                Assert.IsNotNull(Backendless.UserService.CurrentUser,
                                                 "Current user was null");
                                foreach (string key in user.Properties.Keys)
                                {
                                    if (key.Equals("password"))
                                    {
                                        continue;
                                    }

                                    Assert.IsTrue(
                                        Backendless.UserService.CurrentUser.Properties.ContainsKey(
                                            key),
                                        "Current user didn`t contain expected property " + key);
                                    Assert.AreEqual(user.GetProperty(key),
                                                    Backendless.UserService.CurrentUser
                                                    .GetProperty(key),
                                                    "UserService.register changed property " +
                                                    key);
                                }
                                CountDown();
                            }
                        });
                    }
                });
            });
        }
Ejemplo n.º 6
0
        public void TestRegisterNewUser()
        {
            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);
            BackendlessUser registeredUser = Backendless.UserService.Register(user);

            UsedProperties.Add(propertyKey);

            Assert.IsNotNull(registeredUser.GetProperty("id"), "UserService.register didn't set user ID");

            foreach (string key in user.Properties.Keys)
            {
                Assert.IsTrue(registeredUser.Properties.ContainsKey(key),
                              "Registered user didn`t contain expected property " + key);
                Assert.AreEqual(user.GetProperty(key), registeredUser.GetProperty(key),
                                "UserService.register changed property " + key);
            }
        }
Ejemplo n.º 7
0
        public void TestUpdateUserForVersionWithEnabledDynamicPropertis()
        {
            Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
            BackendlessUser user          = GetRandomLoggedInUser();
            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);

            UsedProperties.Add(propertyKey);

            List <UserProperty> userProperties = Backendless.UserService.DescribeUserClass();

            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");
        }
Ejemplo n.º 8
0
		// ----------------------------------------------------------------------------------------

		/// <summary>
		/// use reflection to perform the check for valid fields in the DERIVED class
		/// </summary>
		/// <param name="other">the other instance with which to compare</param>
		protected bool HelperEquals(TStepRow other)
		{
			var type = typeof(TStepRow);
			other.Should().NotBeNull(Resources.StepRow_EqualsOverrideNullMessage);

			var equals = true;

			// ReSharper disable once InvertIf
			if (!ReferenceEquals(this, other))
			{
				// ReSharper disable once PossibleNullReferenceException
				var usedProperties = UsedProperties.Union(other.UsedProperties).ToList();

				foreach (var propertyName in usedProperties)
				{
					var propertyInfo = type.GetProperty(propertyName);

					// this should perform a check against the type, not the object
					dynamic thisValue = propertyInfo.GetValue(this, null);
					dynamic otherValue = propertyInfo.GetValue(other, null);

					var isCollection = propertyInfo.PropertyType.IsConstructedGenericType
						&& typeof(IEnumerable).IsAssignableFrom(propertyInfo.PropertyType);

					if (!isCollection)
					{
						equals = (thisValue == otherValue);
						if (!equals) break;
					}
					else // check that the collections' contents are equal
					{
						var bothNull = (thisValue == null && otherValue == null);
						var bothNotNull = (thisValue != null && otherValue != null);

						equals = bothNull || bothNotNull;
						if (!equals) break;
						if (bothNull) break;

						// ReSharper disable PossibleNullReferenceException
						equals = (thisValue.Count == otherValue.Count);
						// ReSharper restore PossibleNullReferenceException
						if (!equals) break;

						//equals = Enumerable.SequenceEqual(thisValue, otherValue);
						//if (!equals) break;

						for (var index = 0; index < thisValue.Count; ++index)
						{
							equals = (otherValue.Contains(thisValue[index]));
							if (!equals) break;
						}
						if (!equals) break;

						for (var index = 0; index < otherValue.Count; ++index)
						{
							equals = (thisValue.Contains(otherValue[index]));
							if (!equals) break;
						}
						if (!equals) break;
					}
				}
			}
			return equals;
		}
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (PathDescField != null)
         {
             hashCode = hashCode * 59 + PathDescField.GetHashCode();
         }
         if (PathChildField != null)
         {
             hashCode = hashCode * 59 + PathChildField.GetHashCode();
         }
         if (PathParentField != null)
         {
             hashCode = hashCode * 59 + PathParentField.GetHashCode();
         }
         if (PathExactField != null)
         {
             hashCode = hashCode * 59 + PathExactField.GetHashCode();
         }
         if (CatchAllField != null)
         {
             hashCode = hashCode * 59 + CatchAllField.GetHashCode();
         }
         if (CollapsedPathField != null)
         {
             hashCode = hashCode * 59 + CollapsedPathField.GetHashCode();
         }
         if (PathDepthField != null)
         {
             hashCode = hashCode * 59 + PathDepthField.GetHashCode();
         }
         if (CommitPolicy != null)
         {
             hashCode = hashCode * 59 + CommitPolicy.GetHashCode();
         }
         if (Rows != null)
         {
             hashCode = hashCode * 59 + Rows.GetHashCode();
         }
         if (PathRestrictions != null)
         {
             hashCode = hashCode * 59 + PathRestrictions.GetHashCode();
         }
         if (PropertyRestrictions != null)
         {
             hashCode = hashCode * 59 + PropertyRestrictions.GetHashCode();
         }
         if (PrimarytypesRestrictions != null)
         {
             hashCode = hashCode * 59 + PrimarytypesRestrictions.GetHashCode();
         }
         if (IgnoredProperties != null)
         {
             hashCode = hashCode * 59 + IgnoredProperties.GetHashCode();
         }
         if (UsedProperties != null)
         {
             hashCode = hashCode * 59 + UsedProperties.GetHashCode();
         }
         if (TypeMappings != null)
         {
             hashCode = hashCode * 59 + TypeMappings.GetHashCode();
         }
         if (PropertyMappings != null)
         {
             hashCode = hashCode * 59 + PropertyMappings.GetHashCode();
         }
         if (CollapseJcrcontentNodes != null)
         {
             hashCode = hashCode * 59 + CollapseJcrcontentNodes.GetHashCode();
         }
         return(hashCode);
     }
 }
        /// <summary>
        /// Returns true if OrgApacheJackrabbitOakPluginsIndexSolrOsgiOakSolrConfigurationProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheJackrabbitOakPluginsIndexSolrOsgiOakSolrConfigurationProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheJackrabbitOakPluginsIndexSolrOsgiOakSolrConfigurationProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     PathDescField == other.PathDescField ||
                     PathDescField != null &&
                     PathDescField.Equals(other.PathDescField)
                     ) &&
                 (
                     PathChildField == other.PathChildField ||
                     PathChildField != null &&
                     PathChildField.Equals(other.PathChildField)
                 ) &&
                 (
                     PathParentField == other.PathParentField ||
                     PathParentField != null &&
                     PathParentField.Equals(other.PathParentField)
                 ) &&
                 (
                     PathExactField == other.PathExactField ||
                     PathExactField != null &&
                     PathExactField.Equals(other.PathExactField)
                 ) &&
                 (
                     CatchAllField == other.CatchAllField ||
                     CatchAllField != null &&
                     CatchAllField.Equals(other.CatchAllField)
                 ) &&
                 (
                     CollapsedPathField == other.CollapsedPathField ||
                     CollapsedPathField != null &&
                     CollapsedPathField.Equals(other.CollapsedPathField)
                 ) &&
                 (
                     PathDepthField == other.PathDepthField ||
                     PathDepthField != null &&
                     PathDepthField.Equals(other.PathDepthField)
                 ) &&
                 (
                     CommitPolicy == other.CommitPolicy ||
                     CommitPolicy != null &&
                     CommitPolicy.Equals(other.CommitPolicy)
                 ) &&
                 (
                     Rows == other.Rows ||
                     Rows != null &&
                     Rows.Equals(other.Rows)
                 ) &&
                 (
                     PathRestrictions == other.PathRestrictions ||
                     PathRestrictions != null &&
                     PathRestrictions.Equals(other.PathRestrictions)
                 ) &&
                 (
                     PropertyRestrictions == other.PropertyRestrictions ||
                     PropertyRestrictions != null &&
                     PropertyRestrictions.Equals(other.PropertyRestrictions)
                 ) &&
                 (
                     PrimarytypesRestrictions == other.PrimarytypesRestrictions ||
                     PrimarytypesRestrictions != null &&
                     PrimarytypesRestrictions.Equals(other.PrimarytypesRestrictions)
                 ) &&
                 (
                     IgnoredProperties == other.IgnoredProperties ||
                     IgnoredProperties != null &&
                     IgnoredProperties.Equals(other.IgnoredProperties)
                 ) &&
                 (
                     UsedProperties == other.UsedProperties ||
                     UsedProperties != null &&
                     UsedProperties.Equals(other.UsedProperties)
                 ) &&
                 (
                     TypeMappings == other.TypeMappings ||
                     TypeMappings != null &&
                     TypeMappings.Equals(other.TypeMappings)
                 ) &&
                 (
                     PropertyMappings == other.PropertyMappings ||
                     PropertyMappings != null &&
                     PropertyMappings.Equals(other.PropertyMappings)
                 ) &&
                 (
                     CollapseJcrcontentNodes == other.CollapseJcrcontentNodes ||
                     CollapseJcrcontentNodes != null &&
                     CollapseJcrcontentNodes.Equals(other.CollapseJcrcontentNodes)
                 ));
        }