ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,166 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
i have below code for xunit testing in asp .net core
using AutoFixture.Xunit2;using AutoMapper;using FluentAssertions;using Moq;using MyRBV.AppService.Cars;using MyRBV.AppService.Contract.Cars;using MyRBV.DomainService.Cruds;using MyRBV.Model.Cars;namespace AppService.Test.Cars;public class CarServiceTest{ private readonly ICarService _service; private readonly IMapper _mapper; public CarServiceTest([Frozen] Func<IMapper> mapper) { _mapper = mapper(); _service = new CarService(GetDomain(), _mapper); } //[Fact] [Theory, AutoData] public async Task Add_CheckInvalidCarName_ThrowsValidationException(Func<IMapper> mapper) { var car = new CarDto("abghjkl;jhl;kjhkl;'lkjh" + "sdfghjksdfgsfghgfdsfghdsfg" + "sdfgdsfgsfgdsfgdsfghdsfgdsfg" + "sadfgdsfgdsfgsfgdsfgdsfgdsfg" + "sdfghdfsghdsfgdsfghdfgdghdfg"); var action = new Func<Task<CarDto>>(() => _service.Add(car)); await action.Should().ThrowAsync<ArgumentOutOfRangeException>(); } private ICrudDomainService<Car> GetDomain() { var domainMock = new Mock<ICrudDomainService<Car>>(); domainMock.Setup(domain => domain.Add(It.IsAny<Car>())); return domainMock.Object; }}
when i run my text i get below error
AutoFixture.ObjectCreationExceptionWithPath: AutoFixture was unable to create an instance from AutoMapper.IMapper because it's an interface. There's n...
anyone have any idea to help me?