public async Task Handle_WhenCalled_ShouldCallSpecification(GetBenchmarkPriceQuery request) { // Arrange this.specification .Setup(x => x.ToExpression(request)) .Returns(It.IsAny <Expression <Func <Price, bool> > >()); // Act await this.sut.Handle(request, default); // Assert this.specification.VerifyAll(); }
public async Task Handle_WhenNoPrices_ReturnNotFound(GetBenchmarkPriceQuery request) { // Arrange this.specification .Setup(x => x.ToExpression(request)) .Returns(It.IsAny <Expression <Func <Price, bool> > >()); this.priceRepository .Setup(x => x.GetAllAsync(It.IsAny <Expression <Func <Price, bool> > >())) .ReturnsAsync(Array.Empty <Price>().ToList()); // Act var actual = await this.sut.Handle(request, default); // Assert actual.Should().BeOfType <NotFoundHandlerResult <BenchmarkPriceViewModel> >(); }
public void IsSatisfyBy_PortfolioNameInvalid_ReturnFalse(GetBenchmarkPriceQuery request) { // Arrange this.dateTimeConverterMock .Setup(c => c.DateTimeToTimeSlot(request.Date)) .Returns(It.IsAny <int>()); var price = new Price { Portfolio = new Portfolio { Name = string.Empty } }; // Act var actual = this.sut.IsSatisfiedBy(price, request); //Assert actual.Should().BeFalse(); }
public async Task Handle_WhenCalled_ShouldGetFilteredPrices( Expression <Func <Price, bool> > filter, GetBenchmarkPriceQuery request) { // Arrange this.specification .Setup(x => x.ToExpression(request)) .Returns(filter); this.priceRepository .Setup(x => x.GetAllAsync(filter)) .ReturnsAsync(Array.Empty <Price>().ToList()); // Act await this.sut.Handle(request, default); // Assert this.priceRepository.VerifyAll(); }
public void IsSatisfyBy_Valid_ReturnTrue(GetBenchmarkPriceQuery request, int timeslot) { // Arrange this.dateTimeConverterMock .Setup(c => c.DateTimeToTimeSlot(request.Date)) .Returns(timeslot); var price = new Price { Portfolio = new Portfolio { Name = request.Portfolio }, Timeslot = timeslot }; // Act var actual = this.sut.IsSatisfiedBy(price, request); //Assert actual.Should().BeTrue(); }