示例#1
0
        public void TestSaveChanges_WhenDoesNotHaveChanges()
        {
            var mockOfTogglesDbContext   = new MockOfTogglesDbContext();
            var mockOfITogglesRepository = new MockOfITogglesRepository();
            var mockOfIClientApplicationToggleValuesRepository = new MockOfIClientApplicationToggleValuesRepository();
            var unitOfWork = new TogglesUnitOfWork(mockOfTogglesDbContext.Object, mockOfITogglesRepository.Object,
                                                   mockOfIClientApplicationToggleValuesRepository.Object);

            int numberOfSavedChanges = unitOfWork.SaveChanges();

            Assert.IsTrue(numberOfSavedChanges == 0);
        }
示例#2
0
        public void TestSaveChanges()
        {
            int targetNumberOfChanges = 0;
            IList <ToggleDbEntity> mockedToggleDbEntities = this.mockedToggleDbEntitiesCreator.CreateList();
            var mockOfTogglesDbContext   = new MockOfTogglesDbContext(mockedToggleDbEntities);
            var mockOfITogglesRepository = new MockOfITogglesRepository();
            var mockOfIClientApplicationToggleValuesRepository = new MockOfIClientApplicationToggleValuesRepository();

            targetNumberOfChanges += this.SetupTogglesChanges(mockOfITogglesRepository, mockedToggleDbEntities);
            targetNumberOfChanges += this.SetupToggleValuesChanges(mockOfIClientApplicationToggleValuesRepository,
                                                                   mockedToggleDbEntities);
            var unitOfWork = new TogglesUnitOfWork(mockOfTogglesDbContext.Object, mockOfITogglesRepository.Object,
                                                   mockOfIClientApplicationToggleValuesRepository.Object);

            int numberOfSavedChanges = unitOfWork.SaveChanges();

            Assert.IsTrue(targetNumberOfChanges == numberOfSavedChanges);
        }