public async Task NoteControllerGetExistsTrue() { var model = NoteData.GetFirst(); var master = UserData.GetFirst(); var data = new NoteApiDataHandler() { ResultNotable = master }; data.Result.Setup(m => m.Execute(It.IsAny <NotesByRefId>())).Returns(model); var controller = new NoteController(data, Logic) { CurrentUser = StandardUser }; var result = await controller.Get(NoteData.FirstId) as OkObjectResult; result.Should().NotBeNull(); result.Should().BeOfType <OkObjectResult>(); result.Value.Should().BeOfType <NotableViewModel>(); var check = result.Value as NotableViewModel; check.Should().NotBeNull(); check.Notable.Should().NotBeNull(); check.Message.Should().BeNull(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <NotesByRefId>()), Times.Once()); }
public async Task NoteControllerPostDelete() { var data = new NoteApiDataHandler(); var model = NoteData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <NotesByRefId>())).Returns(model); data.Result.Setup(m => m.Execute(It.IsAny <Persist <Notes> >())).Returns(model); var controller = new NoteController(data, Logic) { CurrentUser = StandardUser }; var result = await controller.Delete(NoteData.FirstId, "0") as OkObjectResult; result.Should().NotBeNull(); result.Should().BeOfType <OkObjectResult>(); result.Value.Should().NotBeNull(); var check = result.Value as NotableViewModel; check.Notes.Name.Should().Be(model.Name); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeTrue(); data.Result.Verify(s => s.Execute(It.IsAny <NotesByRefId>()), Times.Once); data.Result.Verify(s => s.Execute(It.IsAny <Persist <Notes> >()), Times.Once()); }
public async Task NoteControllerGetNotFound() { var data = new NoteApiDataHandler(); var controller = new NoteController(data, Logic) { CurrentUser = StandardUser }; var result = await controller.Get(NoteData.FirstId) as NotFoundResult; result.Should().NotBeNull(); result.Should().BeOfType <NotFoundResult>(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); }
public async Task NoteControllerPostNotFound() { var data = new NoteApiDataHandler(); var viewModel = new NoteViewModel(); var controller = new NoteController(data, Logic) { CurrentUser = StandardUser }; var result = await controller.Post(viewModel) as NotFoundResult; result.Should().NotBeNull(); result.Should().BeOfType <NotFoundResult>(); data.HasExecuted.Should().BeFalse(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <NotesByRefId>()), Times.Never); data.Result.Verify(s => s.Execute(It.IsAny <Persist <Notes> >()), Times.Never()); }
public async Task NoteControllerGetNoNotable() { var data = new NoteApiDataHandler(); var master = NoteData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <NotesByRefId>())).Returns(null); var controller = new NoteController(data, Logic) { CurrentUser = StandardUser }; var result = await controller.Get(NoteData.FirstId) as NotFoundResult; result.Should().NotBeNull(); result.Should().BeOfType <NotFoundResult>(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <NotesByRefId>()), Times.Once()); }
public async Task NoteControllerPostAddExisting() { var data = new NoteApiDataHandler(); var model = NoteData.GetFirst(); model.History.Add(new Note() { Counter = 1 }); var viewModel = new NoteViewModel { Id = NoteData.FirstId, Text = "New Note", Counter = 1, IsPrivate = false, ForceNotify = false }; data.Result.Setup(m => m.Execute(It.IsAny <NotesByRefId>())).Returns(model); data.Result.Setup(m => m.Execute(It.IsAny <Persist <Notes> >())).Returns(model); var controller = new NoteController(data, Logic) { CurrentUser = StandardUser }; var result = await controller.Post(viewModel) as OkObjectResult; result.Should().NotBeNull(); result.Should().BeOfType <OkObjectResult>(); result.Value.Should().NotBeNull(); var check = result.Value as NotableViewModel; check.Notes.Name.Should().Be(model.Name); check.Notes.History.Count().Should().Be(2); viewModel.ForceNotify.Should().BeFalse(); viewModel.IsPrivate.Should().BeFalse(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeTrue(); data.Result.Verify(s => s.Execute(It.IsAny <NotesByRefId>()), Times.Once); data.Result.Verify(s => s.Execute(It.IsAny <Persist <Notes> >()), Times.Once()); }