public void RemoveOneElementFromCollection_WhenValitEntityIsPassed() { // Arrange var carAdsServices = new CarAdServices( this.carAdsRepoMock.Object, this.carBrandsRepoMock, this.carModelsRepoMock, this.carFeatureServicesMock, this.unitOfWorkMocked.Object); var countBeforeDelete = carAds.Count(); var carAdsAllAsEnumerable = carAds.ToList(); this.carAdsRepoMock.Setup(x => x.Delete(It.IsAny <CarAd>())) .Callback(() => { carAdsAllAsEnumerable.Remove(carAds.ToList().First()); }); // Act carAdsServices.DeleteAd(It.IsAny <Guid>()); var countAfterDelete = carAdsAllAsEnumerable.Count(); // Assert Assert.AreEqual(countBeforeDelete - 1, countAfterDelete); }
public void Call_CommitFromUnitOfWorkOnce() { // Arrange var carAdsServices = new CarAdServices( this.carAdsRepoMock.Object, this.carBrandsRepoMock, this.carModelsRepoMock, this.carFeatureServicesMock, this.unitOfWorkMocked.Object); // Act carAdsServices.DeleteAd(It.IsAny <Guid>()); // Assert this.unitOfWorkMocked.Verify(x => x.Commit(), Times.Once); }
public void Call_GetByIdMethodFromRepositoryOnce() { // Arrange var carAdsServices = new CarAdServices( this.carAdsRepoMock.Object, this.carBrandsRepoMock, this.carModelsRepoMock, this.carFeatureServicesMock, this.unitOfWorkMocked.Object); // Act carAdsServices.DeleteAd(It.IsAny <Guid>()); // Assert this.carAdsRepoMock.Verify(x => x.GetById(It.IsAny <Guid>()), Times.Once); }