public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockResourceTypesRepository = ResourceTypesMockingSetup.DoMockingSetupForRepository();
     mockResourceTypesRepository.Setup(m => m.Search(It.IsAny<IResourceTypeSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<IResourceType>>().Object);
     var businessWorkflow = new ResourceTypesBusinessWorkflow(mockResourceTypesRepository.Object, new ResourceTypeMapper());
     var model = ResourceTypesMockingSetup.DoMockingSetupForResourceTypeModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockResourceTypesRepository.Verify(m => m.Add(It.IsAny<IResourceType>()), Times.Once);
 }
示例#2
0
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockResourceTypesRepository = ResourceTypesMockingSetup.DoMockingSetupForRepository();

            mockResourceTypesRepository.Setup(m => m.Search(It.IsAny <IResourceTypeSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <IResourceType> >().Object);
            var businessWorkflow = new ResourceTypesBusinessWorkflow(mockResourceTypesRepository.Object, new ResourceTypeMapper());
            var model            = ResourceTypesMockingSetup.DoMockingSetupForResourceTypeModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockResourceTypesRepository.Verify(m => m.Add(It.IsAny <IResourceType>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockResourceTypesRepository = ResourceTypesMockingSetup.DoMockingSetupForRepository();
     var mockResourceType = ResourceTypesMockingSetup.DoMockingSetupForResourceType(1);
     mockResourceTypesRepository.Setup(m => m.Search(It.IsAny<IResourceTypeSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<IResourceType> { mockResourceType.Object } );
     mockResourceTypesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockResourceType.Object);
     var businessWorkflow = new ResourceTypesBusinessWorkflow(mockResourceTypesRepository.Object, new ResourceTypeMapper());
     var model = ResourceTypesMockingSetup.DoMockingSetupForResourceTypeModel();
     // 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
     mockResourceTypesRepository.Verify(m => m.Add(It.IsAny<IResourceType>()), Times.Never);
 }
示例#4
0
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockResourceTypesRepository = ResourceTypesMockingSetup.DoMockingSetupForRepository();
            var mockResourceType            = ResourceTypesMockingSetup.DoMockingSetupForResourceType(1);

            mockResourceTypesRepository.Setup(m => m.Search(It.IsAny <IResourceTypeSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <IResourceType> {
                mockResourceType.Object
            });
            mockResourceTypesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockResourceType.Object);
            var businessWorkflow = new ResourceTypesBusinessWorkflow(mockResourceTypesRepository.Object, new ResourceTypeMapper());
            var model            = ResourceTypesMockingSetup.DoMockingSetupForResourceTypeModel();

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