public async Task SuccessfullyEditNote() { var options = TestUtils.GetOptions(nameof(SuccessfullyEditNote)); using (var arrangeContext = new ManagerLogbookContext(options)) { await arrangeContext.Notes.AddAsync(TestHelpersNote.TestNote1()); await arrangeContext.NoteCategories.AddAsync(TestHelpersNote.TestNoteCategory1()); await arrangeContext.SaveChangesAsync(); } using (var assertContext = new ManagerLogbookContext(options)) { var mockedValidator = new Mock <IBusinessValidator>(); var sut = new NoteService(assertContext, mockedValidator.Object); var noteDTO = await sut.EditNoteAsync(TestHelpersNote.TestNote1().Id, TestHelpersNote.TestUser1().Id, "The room is clean", "710f8fd0-c90f-4d6a-b421-3aef173d9cf4", TestHelpersNote.TestNoteCategory1().Id); Assert.AreEqual(noteDTO.Description, "The room is clean"); Assert.AreEqual(noteDTO.Image, "710f8fd0-c90f-4d6a-b421-3aef173d9cf4"); Assert.AreEqual(noteDTO.CategoryName, TestHelpersNote.TestNoteCategory1().Name); } }
public async Task Return_RightCollectionWhenNoDatesSelected() { var options = TestUtils.GetOptions(nameof(Return_RightCollectionWhenNoDatesSelected)); using (var arrangeContext = new ManagerLogbookContext(options)) { await arrangeContext.Notes.AddAsync(TestHelpersNote.TestNote1()); await arrangeContext.Notes.AddAsync(TestHelpersNote.TestNote2()); await arrangeContext.Notes.AddAsync(TestHelpersNote.TestNote3()); await arrangeContext.NoteCategories.AddAsync(TestHelpersNote.TestNoteCategory1()); await arrangeContext.UsersLogbooks.AddAsync(TestHelpersNote.TestUsersLogbooks1()); await arrangeContext.SaveChangesAsync(); } using (var assertContext = new ManagerLogbookContext(options)) { var mockedValidator = new Mock <IBusinessValidator>(); var sut = new NoteService(assertContext, mockedValidator.Object); var notesDTO = await sut.SearchNotesAsync(TestHelpersNote.TestUser1().Id, TestHelpersNote.TestLogbook1().Id, DateTime.MinValue, DateTime.MinValue, 2, "room37", null); Assert.AreEqual(notesDTO.Count, 2); } }
public async Task Return_RightCollection() { var options = TestUtils.GetOptions(nameof(Return_RightCollection)); using (var arrangeContext = new ManagerLogbookContext(options)) { await arrangeContext.NoteCategories.AddAsync(TestHelpersNote.TestNoteCategory1()); await arrangeContext.NoteCategories.AddAsync(TestHelpersNote.TestNoteCategory2()); await arrangeContext.SaveChangesAsync(); } using (var assertContext = new ManagerLogbookContext(options)) { var mockedValidator = new Mock <IBusinessValidator>(); var sut = new NoteService(assertContext, mockedValidator.Object); var noteCategoriesDTO = await sut.GetNoteCategoriesAsync(); Assert.AreEqual(noteCategoriesDTO.Count, 2); } }