public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockVideoTypesRepository = VideoTypesMockingSetup.DoMockingSetupForRepository();
     mockVideoTypesRepository.Setup(m => m.Search(It.IsAny<IVideoTypeSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<IVideoType>>().Object);
     var businessWorkflow = new VideoTypesBusinessWorkflow(mockVideoTypesRepository.Object, new VideoTypeMapper());
     var model = VideoTypesMockingSetup.DoMockingSetupForVideoTypeModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockVideoTypesRepository.Verify(m => m.Add(It.IsAny<IVideoType>()), Times.Once);
 }
Esempio n. 2
0
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockVideoTypesRepository = VideoTypesMockingSetup.DoMockingSetupForRepository();

            mockVideoTypesRepository.Setup(m => m.Search(It.IsAny <IVideoTypeSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <IVideoType> >().Object);
            var businessWorkflow = new VideoTypesBusinessWorkflow(mockVideoTypesRepository.Object, new VideoTypeMapper());
            var model            = VideoTypesMockingSetup.DoMockingSetupForVideoTypeModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockVideoTypesRepository.Verify(m => m.Add(It.IsAny <IVideoType>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockVideoTypesRepository = VideoTypesMockingSetup.DoMockingSetupForRepository();
     var mockVideoType = VideoTypesMockingSetup.DoMockingSetupForVideoType(1);
     mockVideoTypesRepository.Setup(m => m.Search(It.IsAny<IVideoTypeSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<IVideoType> { mockVideoType.Object } );
     mockVideoTypesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockVideoType.Object);
     var businessWorkflow = new VideoTypesBusinessWorkflow(mockVideoTypesRepository.Object, new VideoTypeMapper());
     var model = VideoTypesMockingSetup.DoMockingSetupForVideoTypeModel();
     // 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
     mockVideoTypesRepository.Verify(m => m.Add(It.IsAny<IVideoType>()), Times.Never);
 }
Esempio n. 4
0
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockVideoTypesRepository = VideoTypesMockingSetup.DoMockingSetupForRepository();
            var mockVideoType            = VideoTypesMockingSetup.DoMockingSetupForVideoType(1);

            mockVideoTypesRepository.Setup(m => m.Search(It.IsAny <IVideoTypeSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <IVideoType> {
                mockVideoType.Object
            });
            mockVideoTypesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockVideoType.Object);
            var businessWorkflow = new VideoTypesBusinessWorkflow(mockVideoTypesRepository.Object, new VideoTypeMapper());
            var model            = VideoTypesMockingSetup.DoMockingSetupForVideoTypeModel();

            // 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
            mockVideoTypesRepository.Verify(m => m.Add(It.IsAny <IVideoType>()), Times.Never);
        }