コード例 #1
0
        public void C_UpdateCategory()
        {
            A_CreateCategory();

            IRepository<Category> categoryRep = new CategoryRepository();

            Category category = categoryRep.Read(2);
            category.Name = "updatedName";
            categoryRep.Update(category);

            Assert.AreEqual("updatedName", categoryRep.Read(2).Name);
        }
コード例 #2
0
        public void E_DeleteCategory()
        {
            IRepository<Category> categoryRep = new CategoryRepository();

            Category category = categoryRep.Read(2);
            categoryRep.Delete(category);
        }
コード例 #3
0
        public void B_ReadCategory()
        {
            IRepository<Category> categoryRep = new CategoryRepository();

            Category category = categoryRep.Read(1);
            Assert.IsNotNull(category);
        }
コード例 #4
0
        public void A_CreateArticle()
        {
            IRepository<Category> categoryRep = new CategoryRepository();
            Category category = categoryRep.Read(1);

            IRepository<Author> authorRep = new AuthorRepository();
            Author author = authorRep.Read(1);

            #region Read photo from file

            FileInfo fileInfo = new FileInfo(@"..\..\..\..\..\DAL\Resources\Chrysanthemum.jpg");
            FileStream fileStream = fileInfo.OpenRead();
            long length = fileStream.Length;

            byte[] photoData = null;

            if (length > 0)
            {
                photoData = new byte[length];
            }

            fileStream.Read(photoData, 0, Convert.ToInt32(length));
            fileStream.Close();

            #endregion

            Photo photo1 = new Photo(PhotoType.Large, "testName", photoData);
            Photo photo2 = new Photo(PhotoType.Medium, "testName", photoData);
            Photo photo3 = new Photo(PhotoType.Small, "testName", photoData);
            List<Photo> photos = new List<Photo>();
            photos.Add(photo1);
            photos.Add(photo2);
            photos.Add(photo3);

            Article article = new Article("testName", "testName", "testName", "testName", "testName", "testName", "testName", true, true, true, category, author, photos);

            IRepository<Article> articleRep = new ArticleRepository();
            articleRep.Create(article);
        }