示例#1
0
        public void EditAlbumValid()
        {
            // ACT
            var actual = (Album)controller.Edit(1).Model;

            // ASSERT
            Assert.AreEqual(albums.ToList()[0], actual);
        }
        public void EditInvalidNoId()
        {
            // Arrange
            int?id = null;

            // Act
            ViewResult actual = controller.Edit(id);

            //Assert
            Assert.AreEqual("Error", actual.ViewName);
        }
        public void EditLoadPass()
        {
            // act
            ViewResult actual = controller.Edit(1) as ViewResult;

            // assert
            Assert.AreEqual("Edit", actual.ViewName);
        }
示例#4
0
        public void Edit_Miss_Required_Album()
        {
            FakeDataStore dataStore = MusicStoreEntitiesFactory.GetEmpty();

            dataStore.GenerateAndAddGenre(1);
            dataStore.GenerateAndAddArtist(10);
            Album test = dataStore.GenerateAndAddAlbum(100, 10, 1, 19.99M);
            StoreManagerController controller = ControllerFactory.GetWiredUpController((s) => new StoreManagerController(s), store: dataStore);

            test.Title = null;
            RedirectToRouteResult result = controller.Edit(test) as RedirectToRouteResult;

            Assert.IsTrue(result.RouteValues.ContainsValue("InvalidRequest"));
        }
示例#5
0
        public void Edit()
        {
            createTestObject();

            // Arrange
            StoreManagerController controller = new StoreManagerController();

            // Act
            ViewResult result = controller.Edit(beanBag.id) as ViewResult;

            // Assert
            Assert.IsNotNull(result);

            deleteTestObject(beanBag.id);
        }
示例#6
0
        public void Edit_Valid_Album()
        {
            FakeDataStore dataStore = MusicStoreEntitiesFactory.GetEmpty();

            dataStore.GenerateAndAddGenre(1, "Nhe nhang");
            dataStore.GenerateAndAddArtist(10);
            // Generate a new album before updating
            Album test = dataStore.GenerateAndAddAlbum(100, 10, 1, 19.99M);
            StoreManagerController controller = ControllerFactory.GetWiredUpController((s) => new StoreManagerController(s), store: dataStore);

            test.Title = "Tình khúc vượt thời gian";
            test.Price = 10M;
            RedirectToRouteResult result = controller.Edit(test) as RedirectToRouteResult;

            Assert.IsTrue(result.RouteValues.ContainsValue("Index"));
        }
示例#7
0
        public void Edit_NotExsiting_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 {
                Title = "Tình khúc vượt thời gian", Genre = new Genre {
                    Name = "Rock"
                },
                Price = 10M, Artist = new Artist {
                    Name = "Men At Work"
                }, AlbumArtUrl = "/Content/Images/placeholder.gif"
            };
            RedirectToRouteResult result = controller.Edit(album) as RedirectToRouteResult;

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