Exemplo n.º 1
0
        public async void InsertAndUpdatePage()
        {
            var expected = Mocks.Page;

            Assert.AreEqual(0, expected.PrimaryKey);
            var page = await _persistenceService.Get <Page> (expected.PrimaryKey);

            Assert.Null(page, "page is not null");

            await _persistenceService.Insert(expected);

            Assert.AreNotEqual(0, expected.PrimaryKey);
            page = await _persistenceService.Get <Page> (expected.PrimaryKey);

            AssertionHelper.AssertPage(expected, page);
            string updatedDescription = "Updated description";

            page.Description = updatedDescription;
            await _persistenceService.Insert(page);

            page = await _persistenceService.Get <Page> (expected.PrimaryKey);

            Assert.AreEqual(updatedDescription, page.Description);

            await _persistenceService.Delete(page);

            page = await _persistenceService.Get <Page> (expected.PrimaryKey);

            Assert.Null(page, "page should have been removed");
        }
Exemplo n.º 2
0
        public async void InsertAndGetMultiplePages()
        {
            var length = 10;

            for (var i = 1; i < length + 1; i++)
            {
                Mocks.Identifier = i;
                var expected = Mocks.Page;
                await _persistenceService.Insert(expected);

                var actual = await _persistenceService.Get <Page> (expected.PrimaryKey);

                AssertionHelper.AssertPage(expected, actual);
            }

            // check whether or not the "desired" entry exists
            var count = await _persistenceService.Connection.Table <Page> ().CountAsync();

            Assert.AreEqual(length, count);

            await _persistenceService.Connection.DeleteAllAsync <Page> ();

            count = await _persistenceService.Connection.Table <Page> ().CountAsync();

            Assert.AreEqual(0, count);
        }
Exemplo n.º 3
0
        public async void InsertAndGetDisclaimer()
        {
            var expected = Mocks.Disclaimer;

            Assert.AreEqual(0, expected.PrimaryKey);
            var disclaimer = await _persistenceService.Get <Disclaimer> (expected.PrimaryKey);

            Assert.Null(disclaimer, "disclaimer is not null");

            await _persistenceService.Insert(expected);

            Assert.AreNotEqual(0, expected.PrimaryKey);
            disclaimer = await _persistenceService.Get <Disclaimer> (expected.PrimaryKey);

            AssertionHelper.AssertPage(expected, disclaimer);

            await _persistenceService.Delete(disclaimer);

            disclaimer = await _persistenceService.Get <Disclaimer> (expected.PrimaryKey);

            Assert.Null(disclaimer, "disclaimer should have been removed");
        }
Exemplo n.º 4
0
        public async void InsertAndGetParentChildrenPages()
        {
            var page1 = Mocks.Page;

            Mocks.Identifier++;
            var page2 = Mocks.Page;


            page1.SubPages = new List <Page> {
                page2
            };
            Assert.AreEqual(0, page1.PrimaryKey);
            Assert.AreEqual(0, page2.PrimaryKey);
            await _persistenceService.Insert(page1);

            Assert.AreNotEqual(0, page1.PrimaryKey);
            Assert.AreNotEqual(0, page2.PrimaryKey);

            var actual = await _persistenceService.Get <Page> (page1.PrimaryKey);

            Assert.AreEqual(1, actual.SubPages.Count);
            AssertionHelper.AssertPage(page2, actual.SubPages [0]);
        }
 public void DeserializationTest()
 {
     AssertionHelper.AssertPage(Mocks.Page, JsonConvert.DeserializeObject <Page>(_serializedPage));
 }
        public new void DeserializationTest()
        {
            var page = JsonConvert.DeserializeObject <EventPage> (_serializedPage);

            AssertionHelper.AssertPage(Mocks.Page, page);
        }