コード例 #1
0
        public async Task Return_RightCollection()
        {
            var options = TestUtils.GetOptions(nameof(Return_RightCollection));

            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.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.ShowLogbookNotesForDaysBeforeAsync(TestHelpersNote.TestUser1().Id, TestHelpersNote.TestLogbook1().Id, 3);

                Assert.AreEqual(notesDTO.Count, 2);
            }
        }
        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);
            }
        }