Ejemplo n.º 1
0
        public async void DetailsReturnsPartialViewWithNoteViewModel()
        {
            var note = new Note
            {
                Id          = 3,
                Date        = new DateTime(),
                Description = "test note"
            };
            var testStore = new List <Note> {
                note
            };
            var userManager = TestUserManager <AppUser>();
            var repoMock    = new Mock <IRepository <Note> >();

            repoMock.Setup(x => x.GetByIdAsync(3)).Returns(async() => await Task.FromResult(note));
            var repository     = repoMock.Object;
            var noteController = new NoteController(userManager, repository);

            var result = await noteController.Details(3);

            var viewResult = Assert.IsType <PartialViewResult>(result);
            var model      = Assert.IsAssignableFrom <NoteViewModel>(viewResult.Model);

            Assert.Equal("test note", model.Description);
        }