コード例 #1
0
        public void CanAddNote()
        {
            // ARRANGE
            string expectedName     = "Verbose Notes";
            string expectedNoteText = "This is just a reminder to go to the store.";
            var    expectedNote     = Substitute.For <INote>();
            var    subjectUnderTest = new Category(expectedName, _noteFactory, _subscriberFactory);

            _noteFactory.Create(expectedNoteText).Returns(expectedNote);

            // ACT
            var result = subjectUnderTest.AddNote(expectedNoteText);

            // ASSERT
            Assert.That(result, Is.InstanceOf(typeof(INote)));
            Assert.That(result, Is.SameAs(expectedNote));
            Assert.That(subjectUnderTest.Notes, Is.Not.Null);
            Assert.That(subjectUnderTest.Notes.Count, Is.EqualTo(1));
            _noteFactory.Received(1).Create(expectedNoteText);
        }
コード例 #2
0
        public INote AddNote(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentException("Note text required.", nameof(text));
            }

            var note = _noteFactory.Create(text);

            if (null == Notes)
            {
                Notes = new List <INote>();
            }

            Notes.Add(note);

            return(note);
        }