Skip to content

SliceFixture with AutoMapper #54

Open
@TDK1964

Description

@TDK1964

My Create handler uses AutoMapper to map from command to entity.

public async Task<int> Handle(Command command, CancellationToken cancellationToken)
            {
                var entity = _mapper.Map<ExampleEntity>(command);
                await _db.ExampleEntity.AddAsync(entity, cancellationToken);
                await _db.SaveChangesAsync(cancellationToken);
                return entity.Id;
            }

My test looks like this

var command = new Create.Command
{
    Name = "Example 1",
     ...
};
var id = await _fixture.SendAsync(command, mapper);
id.ShouldNotBeNull();

When I run the test I get "Object reference not set to an instance of an object." because _maper is null;
I know I probably need to modify the SliceFixture but can't figure out what to do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions