public GetBudgetFixture() { RepoMock = new Mock <IBudgetRepository>(); MapperMock = new Mock <IMapper>(); AuthenticationProviderMock = new Mock <IAuthenticationProvider>(); RepositoryResult = new Domain.Entities.Budget() { Id = It.IsAny <int>(), Name = It.IsAny <string>(), CurrencyCode = It.IsAny <eCurrency>(), StartingDate = It.IsAny <DateTime>() }; MapperResult = new BudgetDto() { BudgetId = It.IsAny <int>(), Name = It.IsAny <string>(), Currency = It.IsAny <Currency>(), StartingDate = It.IsAny <DateTime>() }; var mockUser = new Mock <User>(); var mockUserDto = new Mock <UserDto>(); RepoMock.Setup(x => x.GetByIdAsync(It.IsInRange(int.MinValue, 0, Range.Inclusive))) .ReturnsAsync(default(Domain.Entities.Budget)); RepoMock.Setup(x => x.GetByIdAsync(It.IsInRange(1, int.MaxValue, Range.Inclusive))) .ReturnsAsync(RepositoryResult); MapperMock.Setup(m => m.Map <BudgetDto>(It.IsAny <Domain.Entities.Budget>())) .Returns(MapperResult); AuthenticationProviderMock.Setup(m => m.User).Returns(mockUserDto.Object); AuthenticationProviderMock.Setup(m => m.IsAuthenticated).Returns(true); RequestHandler = new GetBudget.Handler(RepoMock.Object, MapperMock.Object, AuthenticationProviderMock.Object); RequestResponse = RequestHandler.Handle(new GetBudget.Query() { BudgetId = 1 }, new CancellationToken()); IncorrectRequestResponse = RequestHandler.Handle(new GetBudget.Query() { BudgetId = 1 }, new CancellationToken()); }
public static Budget ToPersistence(Domain.Entities.Budget domain) { return(MapperInstance.Map <Domain.Entities.Budget, Budget>(domain)); }