示例#1
0
        public void ShouldReturnFalseIfNotUpdated()
        {
            var model = new MemoModel()
            {
                Id       = 1,
                Title    = "title",
                DateTime = DateTime.UtcNow,
            };

            var noteRepositoryMock = MockRepository.GenerateMock <INoteRepository>();

            noteRepositoryMock.Expect(repo => repo.Update(Arg <Note> .Matches(x => x.Id == model.Id))).Return(false);

            IMemoService memoService = new MemoService(noteRepositoryMock);

            var result = memoService.Update(model);

            Assert.IsFalse(result);
            noteRepositoryMock.VerifyAllExpectations();
        }
示例#2
0
        public void ShouldUpdate()
        {
            var model = new MemoModel()
            {
                Id       = 1,
                Title    = "title",
                DateTime = DateTime.UtcNow,
            };

            var noteRepositoryMock = MockRepository.GenerateMock <INoteRepository>();

            noteRepositoryMock.Expect(repo => repo.Update(Arg <Note> .Matches(x => x.Id == model.Id && x.Title == model.Title && x.DateTime == model.DateTime && x.Type == NoteType.Memo))).Return(true);

            IMemoService memoService = new MemoService(noteRepositoryMock);

            var result = memoService.Update(model);

            Assert.IsTrue(result);
            noteRepositoryMock.VerifyAllExpectations();
        }