public void SendRateAmountUpdateWithRatesListCallPPCGateway() { //Arrange const long businessId = 5002; const string businessShortname = "TestBus2"; const int baseRatePlanId = 1; RoomType roomType = new RoomType(); BaseRatePlan baseRatePlan = new BaseRatePlan(); baseRatePlan.Id = baseRatePlanId; baseRatePlan.MaxOccupancy = 1; roomType.BaseRatePlan = baseRatePlan; var ppcGatewayMock = new Mock<IPPCGateway>(); var roomTypeManagerStub = new Mock<IRoomTypeManager>(); var rateCacheManagerStub = new Mock<IRateCacheManager>(); rateCacheManagerStub.Setup(r => r.GetAllByRoomTypeAndRatePlanId(businessId, 1, baseRatePlanId, RatePlanTypeEnum.Unknown)) .Returns(new List<RateCache>() { new RateCache() { Rate = new decimal(1.0), Date = DateTime.Now, MinStay = 1 } }); roomTypeManagerStub.Setup(m => m.GetRoomType(1, businessId, "")) .Returns(roomType); var rateAmountUpdate = new RateAmountUpdate(); rateAmountUpdate.PPCGateway = ppcGatewayMock.Object; rateAmountUpdate.RateCacheManager = rateCacheManagerStub.Object; rateAmountUpdate.RoomTypeManager = roomTypeManagerStub.Object; //Act rateAmountUpdate.SendRateAmountUpdate(businessShortname, businessId, 1, baseRatePlanId); //Assert ppcGatewayMock.Verify(g => g.Publish(It.IsAny<IPartitionable>()), Times.AtLeastOnce); }
public void SendRateAmountUpdateWithEmptyRatesListDoNotCallPPCGateway() { //Arrange const long businessId = 5002; const string businessShortname = "TestBus2"; var ppcGatewayMock = new Mock<IPPCGateway>(); var roomTypeManagerStub = new Mock<IRoomTypeManager>(); var rateCacheManagerStub = new Mock<IRateCacheManager>(); rateCacheManagerStub.Setup(r => r.GetAllByRoomTypeAndRatePlanId(businessId, 1, 1, RatePlanTypeEnum.Unknown)) .Returns(new List<RateCache>()); var rateAmountUpdate = new RateAmountUpdate(); rateAmountUpdate.PPCGateway = ppcGatewayMock.Object; rateAmountUpdate.RateCacheManager = rateCacheManagerStub.Object; rateAmountUpdate.RoomTypeManager = roomTypeManagerStub.Object; //Act rateAmountUpdate.SendRateAmountUpdate(businessShortname, businessId, 1, 1); //Assert ppcGatewayMock.Verify(g => g.Publish(It.IsAny<IPartitionable>()), Times.Never()); }