public async Task Sucess_PriceServices_Create() { //Arrange mockedDao.Invocations.Clear(); mockedDao.Setup(s => s.AddAsync(It.IsAny <Price>())); //Act service = new PriceServices(mockedUnitOfWork.Object, mockedDao.Object); int priceId = await service.Create(this.price); //Assert Assert.AreEqual(1, priceId); mockedDao.Verify(s => s.AddAsync(It.IsAny <Price>()), Times.Once); }
public async Task Sucess_PriceServices_GetBestProductPrice() { //Arrange mockedDao.Invocations.Clear(); mockedDao.Setup(s => s.GetBestProductPrice(It.IsAny <long>())) .ReturnsAsync(this.price); //Act service = new PriceServices(mockedUnitOfWork.Object, mockedDao.Object); Price price = await service.GetBestProductPrice(2); //Assert Assert.AreSame(this.price, price); mockedDao.Verify(s => s.GetBestProductPrice(It.IsAny <long>()), Times.Once); }
public async Task Sucess_PriceServices_GetByName() { //Arrange mockedDao.Invocations.Clear(); mockedDao.Setup(s => s.GetByName(It.IsAny <string>())) .ReturnsAsync(this.price); //Act service = new PriceServices(mockedUnitOfWork.Object, mockedDao.Object); IEnumerable <Price> priceList = await service.GetByName("Pan"); //Assert Assert.AreEqual(priceList.ToList().Count, 1); mockedDao.Verify(s => s.GetByName(It.IsAny <string>()), Times.Once); }
public async Task Sucess_PriceServices_CheckIfExists() { //Arrange mockedDao.Invocations.Clear(); mockedDao.Setup(s => s.CheckIfExists(It.IsAny <long>(), It.IsAny <int>())) .ReturnsAsync(this.price); //Act service = new PriceServices(mockedUnitOfWork.Object, mockedDao.Object); int?priceId = await service.CheckIfExists(2, 1); //Assert Assert.AreEqual(priceId, 1); mockedDao.Verify(s => s.CheckIfExists(It.IsAny <long>(), It.IsAny <int>()), Times.Once); }