Пример #1
0
        public void GetNotesFromEmptyFile()
        {
            ClearNotesFile();
            List <Note> notesList = (List <Note>)notesRepository.GetAll();

            Assert.IsFalse(notesList.Any());
        }
        public void TestGetAllFromEmptyStorage()
        {
            resetStorage();
            List <Note> notes = (List <Note>)notesRepository.GetAll();

            Assert.Empty(notes);
        }
Пример #3
0
        public void adding_note_in_russian_should_return_list_of_note_in_russian()
        {
            File.WriteAllText(GetAllTest.notesFilePath, string.Empty);
            notesRepository.AddNote("собаки и кошки");

            string[] requiredList = { "собаки и кошки" };
            string[] originalList = notesRepository.GetAll().Select(note => note.Data).ToArray();
            CollectionAssert.AreEqual(originalList, requiredList);
        }
Пример #4
0
 /// <summary>
 /// Get a list of <see cref="Note"/> objects
 /// </summary>
 /// <returns></returns>
 public IEnumerable <Note> GetAll()
 {
     using (var repo = new NotesRepository())
     {
         return(repo.GetAll());
     }
 }
Пример #5
0
        public async Task <IReadOnlyCollection <Note> > GetAsync()
        {
            var notes = await _notes.GetAll();

            return(notes.Select(Note.FromNote).ToList().AsReadOnly());
        }
Пример #6
0
 public IEnumerable <NoteRepositoryItem> GetAll()
 {
     return(_notesRepository.GetAll());
 }
Пример #7
0
        public NotesQuery(NotesRepository notes, AuthorsRepository authors)
        {
            FieldAsync <NonNullGraphType <ListGraphType <NonNullGraphType <NoteGraphType> > > >(
                name: "notes",
                description: "Returns all existing notes.",
                resolve: async ctx => await notes.GetAll(ctx.CancellationToken));

            FieldAsync <NoteGraphType>(
                name: "noteById",
                description: "Returns the note identified by the given id, if present.",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >()
            {
                Name        = "id",
                Description = "The id of the note you are looking for."
            }),
                resolve: async ctx =>
            {
                var prefixedId = ctx.GetRequiredArgument <string>("id");
                var id         = IdParser.ParsePrefixedId(prefixedId, NoteGraphType.IdPrefix);
                return(await notes.GetById(id, ctx.CancellationToken));
            });

            FieldAsync <NonNullGraphType <ListGraphType <NonNullGraphType <NoteGraphType> > > >(
                name: "notesByTitle",
                description: "Returns all notes whose titles start with the given prefix.",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> >()
            {
                Name        = "title",
                Description = "A prefix of the title of the notes you are looking for."
            }),
                resolve: async ctx =>
            {
                var titlePrefix = ctx.GetRequiredArgument <string>("title");
                return(await notes.GetByTitle(titlePrefix, ctx.CancellationToken));
            });

            FieldAsync <NonNullGraphType <ListGraphType <NonNullGraphType <NoteGraphType> > > >(
                name: "notesByAuthor",
                description: "Returns all notes manipulated by the given author.",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >()
            {
                Name        = "authorId",
                Description = "The id of the author whose notes you are looking for."
            }),
                resolve: async ctx =>
            {
                var prefixedId = ctx.GetRequiredArgument <string>("authorId");
                var authorId   = IdParser.ParsePrefixedId(prefixedId, AuthorGraphType.IdPrefix);
                var author     = await authors.GetById(authorId, ctx.CancellationToken);

                if (!author.HasValue)
                {
                    return(Errors.InvalidArgumentException <object>("authorId", "Author could not be found"));
                }

                return(notes.GetByAuthor(author.Value, ctx.CancellationToken));
            });

            FieldAsync <NonNullGraphType <ListGraphType <NonNullGraphType <NoteGraphType> > > >(
                name: "notesForKeyword",
                description: "Returns all notes with the given keyword.",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <KeywordGraphType> >()
            {
                Name        = "keyword",
                Description = "The keyword of the notes your are looking for."
            }),
                resolve: async ctx =>
            {
                var keyword = ctx.GetRequiredArgument <Keyword>("keyword");
                return(await notes.GetByKeyword(keyword, ctx.CancellationToken));
            });

            FieldAsync <NonNullGraphType <ListGraphType <NonNullGraphType <AuthorGraphType> > > >(
                name: "authors",
                description: "Returns all existing authors.",
                resolve: async ctx => await authors.GetAll(ctx.CancellationToken));

            FieldAsync <AuthorGraphType>(
                name: "authorById",
                description: "Returns the author identified by the given id, if present.",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >()
            {
                Name        = "id",
                Description = "The id of the author you are looking for."
            }),
                resolve: async ctx =>
            {
                var prefixedId = ctx.GetRequiredArgument <string>("id");
                var id         = IdParser.ParsePrefixedId(prefixedId, AuthorGraphType.IdPrefix);
                return(await authors.GetById(id, ctx.CancellationToken));
            });
        }
Пример #8
0
        public async Task <IActionResult> GetAllNotes()
        {
            var notes = await _notes.GetAll(_cancellation);

            return(new RestResult(notes.Select(NoteOverviewDTO.FromNote)));
        }
Пример #9
0
 public List <Note> GetNotes()
 {
     return(NotesRepo.GetAll());
 }
Пример #10
0
 private ValueTask <IEnumerable <Models.Note> > GetAllNotes(ServerCallContext ctx)
 => _notes.GetAll(ctx.CancellationToken);
Пример #11
0
        // GET: Notes
        public ActionResult Index()
        {
            var notes = _notesRepository.GetAll();

            return(View(notes));
        }