public async void TestPutById() { // Arrange Note testNote = await mockDbHelper.GetTestResultData(); Mock <IKeepService> mockRepo = new Mock <IKeepService>(); mockRepo.Setup(repo => repo.UpdateNote(1, testNote)).Returns(mockDbHelper.GetTestResultData()); NotesController controller = new NotesController(mockRepo.Object); // Act var result = await controller.Put(1, testNote); OkObjectResult objectResult = result as OkObjectResult; //Note objectResultValue = objectResult.Value as Note; // Assert //Assert.True(Assert.Equal(title,result.Result)) Assert.Equal(200, objectResult.StatusCode); // var note = new Note() // { // ID = 2, // Title = "SECOND NOTE", // PlainText = "Text in the second Note", // PinnedStatus = true, // Labels = new List<Label> // { // new Label{LabelText="label 1 in second NOte"}, // new Label{LabelText="label 2 in second NOte"} // }, // CheckList = new List<CheckListItem> // { // new CheckListItem{CheckListText="checklist 1 in second NOte"}, // new CheckListItem {CheckListText="checklist 2 in second NOte"} // } // }; // var _controller = GetController(); // var result = await _controller.PutById(2, note); // var objectresult = result as OkObjectResult; // var notes = objectresult.Value as Note; // Assert.Equal(2, notes.ID); }
public async void TestDeleteNoteById() { // Arrange Mock <IKeepService> mockRepo = new Mock <IKeepService>(); MockDB mockDbHelper = new MockDB(); mockRepo.Setup(service => service.DeleteNote(1)).Returns(mockDbHelper.GetTestResultData()); NotesController controller = new NotesController(mockRepo.Object); // Act var result = await controller.Delete(1); OkObjectResult objectResult = result as OkObjectResult; Note objectResultValue = objectResult.Value as Note; // Assert Assert.Equal(200, objectResult.StatusCode); // var _controller = GetController(); // var result = _controller.Delete(1); // Assert.True(result.IsCompletedSuccessfully); // //result.StatusCode.Should().Be(System.Net.HttpStatusCode.BadRequest); }