public void The_PictureController_can_return_the_next_TopSlidePicture_file() { //Arrange var pictureController = new PictureController(_pictureViewModelManagerMock.Object); //Act var actionResult = pictureController.GetNextTopSlidePicture(_referencePictureIDs); //Assert _pictureViewModelManagerMock.Verify(mgr => mgr.GetNextTopSlidePicture(_referencePictureIDs), Times.Once()); var viewModel = ((ViewResult)actionResult).Model; //Assert the json data returned from the controller is the same as the viewModel returned from the view model manager. viewModel.GetType() .GetProperties() .ToList() .ForEach(modelProp => Assert.AreEqual(typeof(PictureViewModel) .GetProperties() .Single(picProp => picProp.Name == modelProp.Name) .GetValue(_randomPictureViewModel, null), modelProp.GetValue(viewModel, null))); Assert.AreNotEqual(_referencePictureIDs, ((PictureViewModel)viewModel).ID); }
public void The_PictureController_can_return_a_random_picture_unequal_to_reference_picture_in_request() { //Arrange var pictureController = new PictureController(_pictureViewModelManager); var referencePictureIDs = UnitOfWork.GetAll<Picture>(pic => pic.ID != _testPic3.ID).Select(pic => pic.ID); //Act var actionResult = pictureController.GetNextTopSlidePicture(referencePictureIDs); var viewModel = ((ViewResult)actionResult).Model as PictureViewModel; //Assert Assert.NotNull(viewModel); Assert.NotNull(viewModel.ID); Assert.NotNull(viewModel.Alt); Assert.NotNull(viewModel.ImageType); Assert.NotNull(viewModel.OrdinalIndex); Assert.NotNull(viewModel.Url); Assert.False(referencePictureIDs.Contains(viewModel.ID)); Assert.AreEqual(_testPic3.ID, viewModel.ID); }