Ejemplo n.º 1
0
        public bool UpdateNote(string noteReference, Note note)
        {
            Check.If(noteReference).IsNotNullOrEmpty();
            Check.If(note).IsNotNull();

            return _noteRepository.UpdateNote(noteReference, note);
        }
Ejemplo n.º 2
0
        public bool UpdateNote(string noteReference, Note note)
        {
            var existingNote = _noteContext.Notes.Active().FirstOrDefault(n => n.NoteReference == noteReference);

            if (existingNote == null)
                return false;

            _noteMapper.Map(note, existingNote);

            return _noteContext.SaveChanges() > 0;
        }
Ejemplo n.º 3
0
        public void SoftDelete_Sets_Date_Deleted()
        {
            //arrange
            var note = new Note();

            //act
            note.SoftDelete();

            //assert
            note.DateDeleted.Should().HaveValue();
        }
Ejemplo n.º 4
0
        public bool CreateNote(Note note)
        {
            if (string.IsNullOrEmpty(note.NoteReference))
                return false;

            if (string.IsNullOrEmpty(note.ApplicationReference))
                return false;

            _noteContext.Notes.Add(note);

            return _noteContext.SaveChanges() > 0;
        }
Ejemplo n.º 5
0
        public void NoteMapper_DoesNotMap_DateDeleted()
        {
            //arrange
            var dateDeleted = DateTime.Now;
            var note1 = new Note { DateDeleted = dateDeleted };
            var note2 = new Note { DateDeleted = DateTime.MinValue };

            //act
            _noteMapper.Map(note2, note1);

            //assert
            note1.DateDeleted.Should().Be(dateDeleted);
        }
Ejemplo n.º 6
0
        public void NoteMapper_DoesNotMap_CustomerReference()
        {
            //arrange
            const string reference = "ABCD1234";
            var note1 = new Note { CustomerReference = reference };
            var note2 = new Note { CustomerReference = string.Empty };

            //act
            _noteMapper.Map(note2, note1);

            //assert
            note1.CustomerReference.Should().Be(reference);
        }
Ejemplo n.º 7
0
        public string CreateNote(Note note)
        {
            Check.If(note).IsNotNull();

            if(!string.IsNullOrEmpty(note.NoteReference))
                throw new ArgumentException("NoteReference must be empty", "Note.NoteReference");

            if (string.IsNullOrEmpty(note.ApplicationReference))
            {
                return null;
            }

            var result = _noteRepository.CreateNote(note.CreateReference(_referenceGenerator));

            return result ? note.NoteReference : null;
        }
Ejemplo n.º 8
0
        public void CreateReference_Sets_NoteReference()
        {
            //arrange
            const string reference = "ABCDE12345";
            var mockReferenceGenerator = new Mock<IReferenceGenerator>();
            var note = new Note();

            mockReferenceGenerator.Setup(x => x.CreateReference(It.IsAny<int>())).Returns(reference);

            //act
            note.CreateReference(mockReferenceGenerator.Object);

            //assert
            note.NoteReference.Should().NotBeNullOrWhiteSpace();
            note.NoteReference.Should().Be(reference);

            mockReferenceGenerator.Verify(x => x.CreateReference(It.IsAny<int>()), Times.Once);
        }
Ejemplo n.º 9
0
        public void NoteMapper_DoesNotMap_NoteId()
        {
            //arrange
            const int noteId = 123;
            var note1 = new Note {NoteId = noteId};
            var note2 = new Note {NoteId = 0};

            //act
            _noteMapper.Map(note2, note1);

            //assert
            note1.NoteId.Should().Be(noteId);
        }
Ejemplo n.º 10
0
        public void NoteMapper_Maps_Text()
        {
            //arrange
            const string text = "This is a test";
            var note1 = new Note { Text = text };
            var note2 = new Note {Text = string.Empty};

            //act
            _noteMapper.Map(note2, note1);

            //assert
            note1.Text.Should().NotBe(text);
        }
Ejemplo n.º 11
0
        public void NoteMapper_DoesNotMap_Username()
        {
            //arrange
            const string username = "******";
            var note1 = new Note { Username = username };
            var note2 = new Note { Username = string.Empty };

            //act
            _noteMapper.Map(note2, note1);

            //assert
            note1.Username.Should().Be(username);
        }