public void PostNoteShouldBeFullFilledNote()
        {
            // Arange
            var time1     = new DateTime(2020, 02, 03);
            var dueDate   = DateTime.Today.Add(TimeSpan.FromDays(3));
            var listNote  = Data.AddListNote();
            var noteValue = NoteValueBuilder.CreateDefaultBuilder().Build();

            noteValue.ListNoteId  = listNote.Id;
            noteValue.DueDate     = dueDate;
            noteValue.IsPublic    = true;
            noteValue.IsCompleted = true;

            // Act
            Date.SetCurrentDateTime(time1);
            var result = Facade.PostNote(noteValue).Value;

            // Assert
            result.Text.Should().Be("Text");
            result.DueDate.Should().Be(dueDate);
            result.IsCompleted.Should().BeTrue();
            result.IsPublic.Should().BeTrue();
            result.CreatedDate.Should().Be(time1);
            result.ModifiedDate.Should().BeNull();
            result.DueDate.Should().Be(dueDate);
        }
        public Note AddNote(NoteValue noteValue = null, int?listNoteId = null)
        {
            listNoteId ??= AddListNote().Id;
            noteValue ??= NoteValueBuilder
            .CreateDefaultBuilder()
            .Configure(i =>
            {
                i.ListNoteId = listNoteId.Value;
            })
            .Build();
            var note = _mapper.Map <NoteValue, Note>(noteValue);

            _repo.Add(note).GetAwaiter().GetResult();
            return(note);
        }
Exemplo n.º 3
0
        public void PutNoteShouldBeReturnNotFoundError()
        {
            // Assert
            var noteValue = NoteValueBuilder.CreateDefaultBuilder().Build();

            noteValue.ListNoteId = 1;

            // Act
            var result = Facade.PutNote(noteValue);

            // Assert
            result.Errors.Should().BeEquivalentTo(new List <string>()
            {
                ErrorMessages.NotFound
            });
        }
Exemplo n.º 4
0
        public void PostNoteShouldBeReturnListNoteNotExistError()
        {
            // Arange
            var newItemValue = NoteValueBuilder
                               .CreateDefaultBuilder()
                               .Configure(i => i.ListNoteId = 1)
                               .Build();
            // Act
            var result = Facade.PostNote(newItemValue);

            // Assert
            result.Errors.Should().BeEquivalentTo(new List <string>()
            {
                ErrorMessages.ListNoteNotExist
            });
        }
Exemplo n.º 5
0
        public void PostNoteShouldBeReturnNoteNotUniqueError()
        {
            // Arange
            var listId = Data.AddListNote().Id;

            Data.AddNote(listNoteId: listId);
            var newItemValue = NoteValueBuilder
                               .CreateDefaultBuilder()
                               .Configure(i => i.ListNoteId = listId)
                               .Build();

            // Act
            var result = Facade.PostNote(newItemValue);

            // Assert
            result.Errors.Should().BeEquivalentTo(new List <string>()
            {
                ErrorMessages.NoteNotUnique
            });
        }
Exemplo n.º 6
0
        public void PostNoteShouldBeReturnNoteDueDateLessCurrentDateError()
        {
            // Arange
            var list      = Data.AddListNote();
            var noteValue = NoteValueBuilder
                            .CreateDefaultBuilder()
                            .Configure(i =>
            {
                i.ListNoteId = list.Id;
                i.DueDate    = DateTime.Today - TimeSpan.FromDays(1);
            })
                            .Build();

            // Act
            var result = Facade.PostNote(noteValue);

            // Assert
            result.Errors.Should().BeEquivalentTo(new List <string> {
                ErrorMessages.NoteDueDateLessCurrentDate
            });
        }
Exemplo n.º 7
0
        public void PostNoteShouldBeReturnNoteEmptyError()
        {
            // Arange
            var list      = Data.AddListNote();
            var noteValue = NoteValueBuilder
                            .CreateDefaultBuilder()
                            .Configure(i =>
            {
                i.Text       = "";
                i.ListNoteId = list.Id;
            })
                            .Build();

            // Act
            var result = Facade.PostNote(noteValue);

            // Assert
            result.Errors.Should().BeEquivalentTo(new List <string> {
                ErrorMessages.NoteEmpty
            });
        }
        public void PostNoteShouldBeCreateNoteWithSpecifiedDate()
        {
            // Arange
            var time1     = new DateTime(2020, 02, 03);
            var listNote  = Data.AddListNote();
            var noteValue = NoteValueBuilder
                            .CreateDefaultBuilder()
                            .Configure(i => i.ListNoteId = listNote.Id)
                            .Build();

            // Act
            Date.SetCurrentDateTime(time1);
            var result = Facade.PostNote(noteValue).Value;

            // Assert
            result.Text.Should().Be("Text");
            result.DueDate.Should().BeNull();
            result.IsCompleted.Should().BeFalse();
            result.IsPublic.Should().BeFalse();
            result.CreatedDate.Should().Be(time1);
            result.ModifiedDate.Should().BeNull();
        }
        public void GetAllPublicNotesShouldBeReturnPublicNotes()
        {
            // Arange
            var list1 = Data.AddListNote();
            var list2 = Data.AddListNote();
            var note1 = NoteValueBuilder.CreateDefaultBuilder().Configure(n => n.IsPublic = true).Build();
            var note2 = NoteValueBuilder.CreateDefaultBuilder().Configure(n => n.IsPublic = false).Build();
            var note3 = NoteValueBuilder.CreateDefaultBuilder().Configure(n => n.IsPublic = true).Build();
            var note4 = NoteValueBuilder.CreateDefaultBuilder().Configure(n => n.IsPublic = true).Build();
            var note5 = NoteValueBuilder.CreateDefaultBuilder().Configure(n => n.IsPublic = false).Build();

            Data.AddNote(note1, list1.Id);
            Data.AddNote(note2, list1.Id);
            Data.AddNote(note3, list1.Id);
            Data.AddNote(note4, list1.Id);
            Data.AddNote(note5, list1.Id);

            // Act
            var result = Facade.GetAllPublicNotes().Value;

            // Assert
            result.Count.Should().Be(3);
        }
Exemplo n.º 10
0
        public void PutNoteShouldBeReturnNoteNotUniqueError()
        {
            // Arange
            var listId = Data.AddListNote().Id;

            Data.AddNote(listNoteId: listId);
            var item = NoteValueBuilder
                       .CreateDefaultBuilder()
                       .Configure(i => i.Text = "New Text")
                       .Build();
            var itemId    = Data.AddNote(item, listNoteId: listId).Id;
            var itemValue = Facade.GetNoteById(itemId).Value;

            itemValue.Text = "Text";

            // Act
            var result = Facade.PutNote(itemValue);

            // Assert
            result.Errors.Should().BeEquivalentTo(new List <string>()
            {
                ErrorMessages.NoteNotUnique
            });
        }