コード例 #1
0
ファイル: ServiceTests.cs プロジェクト: Blackjack92/TrainFit
        public void DatabaseServiceStoreLoadUri()
        {
            var expectedPseudoObject = new PseudoClass()
            {
                Source1 = new Uri(defaultUriString),
                Source2 = new Uri(defaultUriString2),
                Source3 = new Uri(defaultUriString)
            };

            var dbService = new DatabaseService();
            dbService.CreateTable<PseudoClass>();

            // Insert into database
            dbService.InsertIntoDatabase(expectedPseudoObject);

            // Read from database
            var actualPseudoObjectList = dbService.ReadListFromDatabase<PseudoClass>();
            var actualPseudoObject = actualPseudoObjectList.FirstOrDefault();

            // Check result
            PseudoComparer comparer = new PseudoComparer();
            Assert.AreEqual(1, actualPseudoObjectList.Count);
            Assert.IsNotNull(actualPseudoObject);
            Assert.IsNotNull(actualPseudoObject.Source1);
            Assert.IsNotNull(actualPseudoObject.Source2);
            Assert.IsNotNull(actualPseudoObject.Source3);
            Assert.IsTrue(comparer.Equals(expectedPseudoObject, actualPseudoObject));

            // Delete pseudo object from database
            dbService.DeleteFromDatabase(actualPseudoObject);

            // Read pseudo object from database. No objects should be found
            actualPseudoObjectList = dbService.ReadListFromDatabase<PseudoClass>();
            Assert.AreEqual(0, actualPseudoObjectList.Count);
        }