예제 #1
0
 public void TestDeleteObjectWithWrongId()
 {
     RunAndAwait(() =>
     {
         WPPersonAsync wpPerson = GetRandomWPPerson();
         Backendless.Persistence.Save(wpPerson,
                                      new ResponseCallback <WPPersonAsync>(this)
         {
             ResponseHandler = response =>
             {
                 wpPerson.ObjectId = "foobar";
                 Backendless.Persistence.Of <WPPersonAsync>()
                 .Remove(wpPerson,
                         new AsyncCallback <long>(
                             l => Assert.Fail("Server didn't throw an exception"),
                             fault => CheckErrorCode(1000, fault)));
             }
         });
     });
 }
예제 #2
0
        public void TestRetrieveEntityProperties()
        {
            RunAndAwait(() =>
            {
                WPPersonAsync wpPerson = GetRandomWPPerson();
                Backendless.Persistence.Save(wpPerson,
                                             new ResponseCallback <WPPersonAsync>(this)
                {
                    ResponseHandler =
                        response =>
                        Backendless.Persistence.Describe(typeof(WPPersonAsync).Name,
                                                         new ResponseCallback <List <ObjectProperty> >
                                                             (this)
                    {
                        ResponseHandler = properties =>
                        {
                            Assert.IsNotNull(properties,
                                             "Server returned null");
                            Assert.AreEqual(
                                properties.Count, 6,
                                "Server returned unexpected amount of properties");

                            foreach (
                                ObjectProperty property in
                                properties)
                            {
                                if (property.Name.Equals("Age"))
                                {
                                    Assert.AreEqual(
                                        DateTypeEnum.INT,
                                        property.Type,
                                        "Property was of unexpected type");
                                    Assert.IsFalse(
                                        property.IsRequired,
                                        "Property had a wrong required value");
                                }
                                else if (
                                    property.Name.Equals("Name"))
                                {
                                    Assert.AreEqual(
                                        DateTypeEnum.STRING,
                                        property.Type,
                                        "Property was of unexpected type");
                                    Assert.IsFalse(
                                        property.IsRequired,
                                        "Property had a wrong required value");
                                }
                                else if (
                                    property.Name.Equals(
                                        "created"))
                                {
                                    Assert.AreEqual(
                                        DateTypeEnum.DATETIME,
                                        property.Type,
                                        "Property was of unexpected type");
                                    Assert.IsFalse(
                                        property.IsRequired,
                                        "Property had a wrong required value");
                                }
                                else if (
                                    property.Name.Equals(
                                        "objectId"))
                                {
                                    Assert.AreEqual(
                                        DateTypeEnum.STRING_ID,
                                        property.Type,
                                        "Property was of unexpected type");
                                    Assert.IsFalse(
                                        property.IsRequired,
                                        "Property had a wrong required value");
                                }
                                else if (
                                    property.Name.Equals(
                                        "updated"))
                                {
                                    Assert.AreEqual(
                                        DateTypeEnum.DATETIME,
                                        property.Type,
                                        "Property was of unexpected type");
                                    Assert.IsFalse(
                                        property.IsRequired,
                                        "Property had a wrong required value");
                                }
                                else if (
                                    property.Name.Equals(
                                        "ownerId"))
                                {
                                    Assert.AreEqual(
                                        DateTypeEnum.STRING,
                                        property.Type,
                                        "Property was of unexpected type");
                                    Assert.IsFalse(
                                        property.IsRequired,
                                        "Property had a wrong required value");
                                }
                                else
                                {
                                    Assert.Fail(
                                        "Got unexpected property: " +
                                        property.Name);
                                }
                            }

                            CountDown();
                        }
                    })
                });
            });
        }