コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }