Create() public method

public Create ( ) : System.Web.Mvc.ActionResult
return System.Web.Mvc.ActionResult
コード例 #1
0
 public void CreateTest()
 {
     StoreManagerController target = new StoreManagerController(); // TODO: Initialize to an appropriate value
     Album album = null; // TODO: Initialize to an appropriate value
     ActionResult expected = null; // TODO: Initialize to an appropriate value
     ActionResult actual;
     actual = target.Create(album);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
コード例 #2
0
        public void CreateTest()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                StoreManagerController target = new StoreManagerController();
                Album album = new Album()
                {
                    GenreId = 1,
                    ArtistId = 1,
                    Title = "New Album",
                    Price = 10,
                    AlbumArtUrl = "/Content/Images/placeholder.gif"
                };
                ActionResult actual;
                actual = target.Create(album);

                Assert.IsTrue(album.AlbumId != 0);

                MusicStoreEntities storeDB = new MusicStoreEntities();

                var newAlbum = storeDB.Albums.SingleOrDefault(a => a.AlbumId == album.AlbumId);

                Assert.AreEqual(album.GenreId, newAlbum.GenreId);
                Assert.AreEqual(album.ArtistId, newAlbum.ArtistId);
                Assert.AreEqual(album.Title, newAlbum.Title);
                Assert.AreEqual(album.Price, newAlbum.Price);
                Assert.AreEqual(album.AlbumArtUrl, newAlbum.AlbumArtUrl);
            }
        }