예제 #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
        private int SetupTogglesChanges(MockOfITogglesRepository mockOfITogglesRepository,
                                        IList <ToggleDbEntity> mockedToggleDbEntitiesInDbContext)
        {
            ToggleDbEntity updatedToggleDbEntity = mockedToggleDbEntitiesInDbContext[0];
            ToggleDbEntity deletedToggleDbEntity = mockedToggleDbEntitiesInDbContext[1];
            Toggle         addedToggle           = new Toggle();
            Toggle         updatedToggle         = this.ConvertToBusinessEntity(updatedToggleDbEntity);
            Toggle         deletedToggle         = this.ConvertToBusinessEntity(deletedToggleDbEntity);

            mockOfITogglesRepository.Object.Add(addedToggle);
            mockOfITogglesRepository.Object.Update(updatedToggle);
            mockOfITogglesRepository.Object.Delete(deletedToggle);
            return(mockOfITogglesRepository.NumberOfChanges);
        }
예제 #3
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);
        }