Esempio n. 1
0
        public void CreateViewLoads()
        {
            // act - cast the return type as ViewResult
            ViewResult actual = (ViewResult)controller.Create();

            // assert
            Assert.AreEqual("Create", actual.ViewName);
            Assert.IsNotNull(actual.ViewBag.ArtistId);
            Assert.IsNotNull(actual.ViewBag.GenreId);
        }
        public void CreateLoadsArtists()
        {
            // act
            ViewResult actual = (ViewResult)controller.Create();

            // assert
            Assert.IsNotNull(actual.ViewBag.ArtistId);
        }
Esempio n. 3
0
        public void Create()
        {
            // Arrange
            StoreManagerController controller = new StoreManagerController();

            // Act
            ViewResult result = controller.Create() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
Esempio n. 4
0
        public void CreateAlbumAdded()
        {
            // arrange
            var album = new Album()
            {
                AlbumId = 4,
                Title   = "Album 4",
                Price   = 44
            };

            // act
            //var actual = (RedirectToRouteResult)controller.Create(album);

            //// assert
            //Assert.AreEqual("Index", actual.RouteValues["action"]);
            // act
            RedirectToRouteResult actual = (RedirectToRouteResult)controller.Create(album);

            // assert
            Assert.AreEqual("Index", actual.RouteValues["action"]);
        }
Esempio n. 5
0
        public void Create_Miss_Required_Album()
        {
            FakeDataStore dataStore = MusicStoreEntitiesFactory.GetEmpty();

            dataStore.GenerateAndAddGenre(1);
            dataStore.GenerateAndAddArtist(10);
            StoreManagerController controller = ControllerFactory.GetWiredUpController((s) => new StoreManagerController(s), store: dataStore);
            Album album = new Album {
                Genre = new Genre {
                    Name = "Rock"
                }, Artist = new Artist {
                    Name = "Men At Work"
                },
                AlbumArtUrl = "/Content/Images/placeholder.gif"
            };
            RedirectToRouteResult result = controller.Create(album) as RedirectToRouteResult;

            Assert.IsTrue(result.RouteValues.ContainsValue("InvalidRequest"));
        }