Beispiel #1
0
        public async System.Threading.Tasks.Task DeleteEntryCommandHandler_Fail()
        {
            var phoneBook = new PhoneBookAggregateRoot {
                Name = _phoneBookName
            };
            await _phoneBookRepositoryMock.AddAsync(phoneBook);

            var deleteEntryCommandHandler = new DeleteEntryCommandHandler(_phoneBookRepositoryMock);
            var deleteEntryCommand        = new DeleteEntryCommand {
                PhoneBookId = phoneBook.Id, EntryId = Guid.NewGuid()
            };

            await Assert.ThrowsAsync <ValidateException>(() => deleteEntryCommandHandler.HandleAsync(deleteEntryCommand));
        }
Beispiel #2
0
        public async System.Threading.Tasks.Task DeleteEntryCommandHandler_Success()
        {
            //Given
            var phoneBook = new PhoneBookAggregateRoot {
                Name = _phoneBookName
            };

            phoneBook.InsertEntry("TestUser", "0817810008");
            var entryId = phoneBook.Entries.FirstOrDefault().Id;

            await _phoneBookRepositoryMock.AddAsync(phoneBook);

            var deleteEntryCommandHandler = new DeleteEntryCommandHandler(_phoneBookRepositoryMock);
            var deleteEntryCommand        = new DeleteEntryCommand {
                PhoneBookId = phoneBook.Id, EntryId = entryId
            };

            //When
            await deleteEntryCommandHandler.HandleAsync(deleteEntryCommand);

            //Then
            Assert.Empty(((PhoneBookRepositoryMock)_phoneBookRepositoryMock).phoneBookAggregates.FirstOrDefault().Entries);
        }