Ejemplo n.º 1
0
        public void Verify_Update_Should_SetUpdatedDate()
        {
            // Arrange
            var mockConceptVolume            = ConceptVolumesMockingSetup.DoMockingSetupForConceptVolume(1);
            var mockConceptVolumesRepository = ConceptVolumesMockingSetup.DoMockingSetupForRepository();

            mockConceptVolumesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockConceptVolume.Object);
            var businessWorkflow = new ConceptVolumesBusinessWorkflow(mockConceptVolumesRepository.Object, new ConceptVolumeMapper());
            var expectedName     = "Stephen King (2)";
            var model            = ConceptVolumesMockingSetup.DoMockingSetupForConceptVolumeModel(1, expectedName);

            // Act
            businessWorkflow.Update(model.Object);
            // Assert
            mockConceptVolume.Verify(m => m.UpdatedDate, Times.Once);
        }
Ejemplo n.º 2
0
        public void Verify_Update_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var entity = ConceptVolumesMockingSetup.DoMockingSetupForConceptVolume(1);
            var mockConceptVolumesRepository = ConceptVolumesMockingSetup.DoMockingSetupForRepository();

            mockConceptVolumesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => entity.Object);
            var businessWorkflow       = new ConceptVolumesBusinessWorkflow(mockConceptVolumesRepository.Object, new ConceptVolumeMapper());
            var model                  = ConceptVolumesMockingSetup.DoMockingSetupForConceptVolumeModel(1);
            IConceptVolumeModel result = null;

            // Act
            try { result = businessWorkflow.Update(model.Object); }
            catch { /* ignored, the Get call at the end doesn't work because don't get a real entity with id on it */ }
            // Assert
            Assert.NotNull(result);
            Assert.Equal("/TEST/KING-STEPHEN", result.ApiDetailUrl);
            Assert.Null(result.UpdatedDate);
        }
Ejemplo n.º 3
0
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockConceptVolumesRepository = ConceptVolumesMockingSetup.DoMockingSetupForRepository();
            var mockConceptVolume            = ConceptVolumesMockingSetup.DoMockingSetupForConceptVolume(1);

            mockConceptVolumesRepository.Setup(m => m.Search(It.IsAny <IConceptVolumeSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <IConceptVolume> {
                mockConceptVolume.Object
            });
            mockConceptVolumesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockConceptVolume.Object);
            var businessWorkflow = new ConceptVolumesBusinessWorkflow(mockConceptVolumesRepository.Object, new ConceptVolumeMapper());
            var model            = ConceptVolumesMockingSetup.DoMockingSetupForConceptVolumeModel();

            // Act
            try { businessWorkflow.Create(model.Object); }
            catch { /* ignored, the Get call at the end doesn't work because don't get a real entity with id on it */ }
            // Assert
            mockConceptVolumesRepository.Verify(m => m.Add(It.IsAny <IConceptVolume>()), Times.Never);
        }