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; }
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); }