Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // namespace and your usings
- using Telerik.JustMock;
- // class name and private lists
- [Test]
- public void HomeIndexPicturesShouldWorkCorrectly()
- {
- // no idea just copy/paste
- var autoMapperConfig = new AutoMapperConfig();
- autoMapperConfig.Execute(typeof(HomeController).Assembly);
- // var mediaContentFetcherServiceMock = new Mock<IMediaContentFetcherService>();
- // mediaContentFetcherServiceMock
- // .Setup(x => x.GetLast(ContentType.Picture, 3)).Verifiable();
- // mocking
- var mediaContentFetcherServiceMock = Mock.Create<IMediaContentFetcherService>();
- // arrange mock - line below mean: this method with this param should be called once!
- Mock.Arrange(() => mediaContentFetcherServiceMock.GetLast(ContentType.Picture)).OccursOnce();
- // .MustBeCalled();
- // .OccoursExatly(1);
- // .OccoursAtLeast(1);
- // .OccoursAtMost(1);
- // hope you got the idea
- var controller = new HomeController(mediaContentFetcherServiceMock);
- // no idea what this do BUT here have to place your act without any assert
- // just in way you exapect to be called
- // controller.WithCallTo(x => x.Index())
- // .ShouldRenderView("Index")
- // .WithModel<HomeViewModel>(
- // viewModel =>
- // {
- // Assert.AreEqual(this.pictures, viewModel.Pictures);
- // }).AndNoModelErrors();
- Mock.Assert(() => mediaContentFetcherServiceMock);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement