Beispiel #1
0
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockConceptAliasesRepository = ConceptAliasesMockingSetup.DoMockingSetupForRepository();

            mockConceptAliasesRepository.Setup(m => m.Search(It.IsAny <IConceptAliasSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <IConceptAlias> >().Object);
            var businessWorkflow = new ConceptAliasesBusinessWorkflow(mockConceptAliasesRepository.Object, new ConceptAliasMapper());
            var model            = ConceptAliasesMockingSetup.DoMockingSetupForConceptAliasModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockConceptAliasesRepository.Verify(m => m.Add(It.IsAny <IConceptAlias>()), Times.Once);
        }
Beispiel #2
0
        public void Verify_Update_Should_SetUpdatedDate()
        {
            // Arrange
            var mockConceptAlias             = ConceptAliasesMockingSetup.DoMockingSetupForConceptAlias(1);
            var mockConceptAliasesRepository = ConceptAliasesMockingSetup.DoMockingSetupForRepository();

            mockConceptAliasesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockConceptAlias.Object);
            var businessWorkflow = new ConceptAliasesBusinessWorkflow(mockConceptAliasesRepository.Object, new ConceptAliasMapper());
            var expectedName     = "Stephen King (2)";
            var model            = ConceptAliasesMockingSetup.DoMockingSetupForConceptAliasModel(1, expectedName);

            // Act
            businessWorkflow.Update(model.Object);
            // Assert
            mockConceptAlias.Verify(m => m.UpdatedDate, Times.Once);
        }
Beispiel #3
0
        public void Verify_Update_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var entity = ConceptAliasesMockingSetup.DoMockingSetupForConceptAlias(1);
            var mockConceptAliasesRepository = ConceptAliasesMockingSetup.DoMockingSetupForRepository();

            mockConceptAliasesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => entity.Object);
            var businessWorkflow      = new ConceptAliasesBusinessWorkflow(mockConceptAliasesRepository.Object, new ConceptAliasMapper());
            var model                 = ConceptAliasesMockingSetup.DoMockingSetupForConceptAliasModel(1);
            IConceptAliasModel 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);
        }
Beispiel #4
0
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockConceptAliasesRepository = ConceptAliasesMockingSetup.DoMockingSetupForRepository();
            var mockConceptAlias             = ConceptAliasesMockingSetup.DoMockingSetupForConceptAlias(1);

            mockConceptAliasesRepository.Setup(m => m.Search(It.IsAny <IConceptAliasSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <IConceptAlias> {
                mockConceptAlias.Object
            });
            mockConceptAliasesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockConceptAlias.Object);
            var businessWorkflow = new ConceptAliasesBusinessWorkflow(mockConceptAliasesRepository.Object, new ConceptAliasMapper());
            var model            = ConceptAliasesMockingSetup.DoMockingSetupForConceptAliasModel();

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