public async Task TestGetNote_Success() { var response = await _controller.Get("6177A1C3-C17A-4E7C-83CD-A2D4CA62CDC1"); var negResult = response as OkNegotiatedContentResult <List <GetNotesOutput> >; Assert.IsNotNull(negResult); Assert.AreEqual(2, negResult.Content.Count); Assert.AreEqual("6177A1C3-C17A-4E7C-83CD-A2D4CA62CDC1", negResult.Content[0].AccountIdentifier); Assert.AreEqual("Gorden James", negResult.Content[0].CareAgentName); Assert.AreEqual("Test1", negResult.Content[0].ChangeBy); Assert.AreEqual(DateTime.MaxValue, negResult.Content[0].CreateDate); Assert.AreEqual("Note 1", negResult.Content[0].Note); Assert.AreEqual(1, negResult.Content[0].Notekey); }
public void NoteController_GetNoteByID_CountShouldBeCorrectInt() { var result = _controller.Get(1); Assert.AreEqual(1, _mockService.CallCount); Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult <NoteDetail>)); }
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 void GetLastPageOfUsers() { List <Note> expectedNotes = new List <Note> { notes[2] }; var controller = new NoteController(_edbContext); List <Note> result = controller.Get(account.AccountId, new Pagination(2, 2)).ToList(); Assert.True(expectedNotes.SequenceEqual(result)); }
public void Get_Returns_List_Of_Notes() { var expected = new List <Note>(); repo.GetAll().Returns(expected); var result = underTest.Get(); Assert.IsType <List <Note> >(result.Value); }
public void TestNoneRowInDb() { mock .Setup(x => x.GetAllNotes()) .Returns(new List <Note>()); noteController = new NoteController(mock.Object); var result = JsonSerializer.Deserialize <List <Note> >(noteController.Get()).FirstOrDefault(); Assert.IsNull(result); }
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 void Get_Not_Exists() { NoteControllerMockFacade mock = new NoteControllerMockFacade(); mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiNoteServerResponseModel>(null)); NoteController controller = new NoteController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); IActionResult response = await controller.Get(default(int)); response.Should().BeOfType <StatusCodeResult>(); (response as StatusCodeResult).StatusCode.Should().Be((int)HttpStatusCode.NotFound); mock.ServiceMock.Verify(x => x.Get(It.IsAny <int>())); }
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 void TestOneRowInDb() { mock .Setup(x => x.GetAllNotes()) .Returns(new List <Note>() { new Note() { Id = 0, Author = "Igor", Text = "Some random text" } }); noteController = new NoteController(mock.Object); var result = JsonSerializer.Deserialize <List <Note> >(noteController.Get()).FirstOrDefault(); Assert.IsNotNull(result); Assert.AreEqual(0, result.Id); Assert.AreEqual("Igor", result.Author); Assert.AreEqual("Some random text", result.Text); }