Esempio n. 1
0
        public void Handle_GivenInvalidId_ShouldThrowException()
        {
            // Arrange

            var command = new UpdatePersonPhotoCommand()
            {
                PersonId = 999,
                Photo    = Encoding.ASCII.GetBytes("somestring")
            };

            var sut = new UpdatePersonPhotoCommand.UpdatePersonPhotoCommandHandler(Context);

            // Act
            // Assert
            Should.ThrowAsync <NotFoundException>(() =>
                                                  sut.Handle(command, CancellationToken.None));
        }
Esempio n. 2
0
        public async Task Handle_GivenValidId_ShouldPersistPhoto()
        {
            // Arrange

            var command = new UpdatePersonPhotoCommand()
            {
                PersonId = 1,
                Photo    = Encoding.ASCII.GetBytes("somestring")
            };

            var handler = new UpdatePersonPhotoCommand.UpdatePersonPhotoCommandHandler(Context);

            // Act
            await handler.Handle(command, CancellationToken.None);

            // Assert
            var entity = Context.Persons.Find(command.PersonId);

            entity.ShouldNotBeNull();

            entity.Photo.ShouldNotBeNull();
        }