Пример #1
0
        public void B_Get()
        {
            RestController api = new RestController(GetConnectionString());

            ApplicationResultRecords result1 = api.Get();

            Assert.IsTrue(result1.Success);
            Assert.IsTrue(result1.Records.Count() >= 2);

            ApplicationResultRecord result2 = api.Get(result1.Records[0].ID);

            Assert.IsTrue(result2.Success);
            Assert.IsNotNull(result2.Record);
            Assert.IsTrue(result2.Record.ID == result1.Records[0].ID);

            ApplicationResultRecords result3 = api.Get("Test", null);

            Assert.IsTrue(result3.Success);
            Assert.IsNotNull(result3.Records);
            Assert.IsTrue(result3.Records.Count() == 2);
            Assert.IsTrue(result3.Records[0].FirstName == "Test");

            ApplicationResultRecords result4 = api.Get(null, "Two");

            Assert.IsTrue(result4.Success);
            Assert.IsNotNull(result4.Records);
            Assert.IsTrue(result4.Records.Count() == 1);
            Assert.IsTrue(result4.Records[0].LastName == "Two");
        }
Пример #2
0
        public ApplicationResultRecords Get(string firstName, string lastName)
        {
            ApplicationResultRecords result = null;

            try
            {
                IEnumerable <AgeRanger> list;
                string error = _Storage.List(out list, firstName, lastName);

                if (string.IsNullOrEmpty(error))
                {
                    result = new ApplicationResultRecords(list?.ToArray());
                }
                else
                {
                    result = new ApplicationResultRecords("Fail to read records!");
                }
            }
            catch (Exception ex)
            {
                result = new ApplicationResultRecords("Fail to read record!", ex);
            }

            return(result);
        }
Пример #3
0
        public void C_Delete()
        {
            RestController api = new RestController(GetConnectionString());

            ApplicationResultRecords result1 = api.Get();

            ApplicationResultBase result2 = api.Delete(result1.Records[0].ID);

            Assert.IsTrue(result2.Success);

            ApplicationResultBase result3 = api.Delete(result1.Records[1].ID);

            Assert.IsTrue(result3.Success);

            ApplicationResultRecords result4 = api.Get();

            Assert.IsTrue(result4.Success);
            Assert.IsNull(result4.Records);
        }