示例#1
0
文件: ArtistTest.cs 项目: amigobv/UFO
        void InsertDummyData(IArtistDao dao)
        {
            CreateTestData();

            foreach (var item in items)
            {
                dao.Insert(item);
            }
        }
        public Artist SaveArtist(Artist artist)
        {
            IArtistDao dao = DALFactory.CreateArtistDao(database);

            if (artist.Id != null && artist.Id > 0)
            {
                dao.Update(artist);
                return(artist);
            }
            artist = dao.Insert(artist);
            return(artist);
        }
        private static void CreateArtists()
        {
            Console.WriteLine("Insert Artists ");
            Random       r = new Random();
            RootObject   generatedEntries = FetchPersons();
            IArtistDao   dao         = DALFactory.CreateArtistDao(DALFactory.CreateDatabase());
            ICatagoryDao catagoryDao = DALFactory.CreateCatagoryDao(DALFactory.CreateDatabase());

            generatedEntries.results.ToList().ForEach(x => {
                Console.WriteLine(x.user.name.first);
                Artist artist   = new Artist();
                artist.Catagory = catagoryDao.findById(r.Next(1, 10));
                artist.Name     = x.user.name.first + " " + x.user.name.last;
                artist.Email    = x.user.email;
                artist.Country  = "AUT";
                artist.Picture  = GetBase64EncodedImageFromUrl(x.user.picture.thumbnail);
                dao.Insert(artist);
                Console.WriteLine("Inserted ");
            });
        }
示例#4
0
        public void TestInsert()
        {
            PropertyInfo info   = typeof(Artist).GetProperty("Email");
            Artist       artist = new Artist();

            artist.Email   = "*****@*****.**";
            artist.Name    = "UnitTestArtist";
            artist.Link    = "I do not have any Link";
            artist.Country = "AUT";

            IArtistDao dao = DALFactory.CreateArtistDao(DALFactory.CreateDatabase());

            dao.Insert(artist);

            Artist result = dao.findByUniqueProperty(info, "*****@*****.**");

            Assert.AreEqual(result.Email, artist.Email);
            Assert.AreEqual(result.Name, artist.Name);
            Assert.AreEqual(result.Link, artist.Link);
            Assert.AreEqual(result.Country, artist.Country);
        }