public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockEpisodePeopleRepository = EpisodePeopleMockingSetup.DoMockingSetupForRepository();
     mockEpisodePeopleRepository.Setup(m => m.Search(It.IsAny<IEpisodePersonSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<IEpisodePerson>>().Object);
     var businessWorkflow = new EpisodePeopleBusinessWorkflow(mockEpisodePeopleRepository.Object, new EpisodePersonMapper());
     var model = EpisodePeopleMockingSetup.DoMockingSetupForEpisodePersonModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockEpisodePeopleRepository.Verify(m => m.Add(It.IsAny<IEpisodePerson>()), Times.Once);
 }
Beispiel #2
0
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockEpisodePeopleRepository = EpisodePeopleMockingSetup.DoMockingSetupForRepository();

            mockEpisodePeopleRepository.Setup(m => m.Search(It.IsAny <IEpisodePersonSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <IEpisodePerson> >().Object);
            var businessWorkflow = new EpisodePeopleBusinessWorkflow(mockEpisodePeopleRepository.Object, new EpisodePersonMapper());
            var model            = EpisodePeopleMockingSetup.DoMockingSetupForEpisodePersonModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockEpisodePeopleRepository.Verify(m => m.Add(It.IsAny <IEpisodePerson>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockEpisodePeopleRepository = EpisodePeopleMockingSetup.DoMockingSetupForRepository();
     var mockEpisodePerson = EpisodePeopleMockingSetup.DoMockingSetupForEpisodePerson(1);
     mockEpisodePeopleRepository.Setup(m => m.Search(It.IsAny<IEpisodePersonSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<IEpisodePerson> { mockEpisodePerson.Object } );
     mockEpisodePeopleRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockEpisodePerson.Object);
     var businessWorkflow = new EpisodePeopleBusinessWorkflow(mockEpisodePeopleRepository.Object, new EpisodePersonMapper());
     var model = EpisodePeopleMockingSetup.DoMockingSetupForEpisodePersonModel();
     // 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
     mockEpisodePeopleRepository.Verify(m => m.Add(It.IsAny<IEpisodePerson>()), Times.Never);
 }
Beispiel #4
0
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockEpisodePeopleRepository = EpisodePeopleMockingSetup.DoMockingSetupForRepository();
            var mockEpisodePerson           = EpisodePeopleMockingSetup.DoMockingSetupForEpisodePerson(1);

            mockEpisodePeopleRepository.Setup(m => m.Search(It.IsAny <IEpisodePersonSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <IEpisodePerson> {
                mockEpisodePerson.Object
            });
            mockEpisodePeopleRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockEpisodePerson.Object);
            var businessWorkflow = new EpisodePeopleBusinessWorkflow(mockEpisodePeopleRepository.Object, new EpisodePersonMapper());
            var model            = EpisodePeopleMockingSetup.DoMockingSetupForEpisodePersonModel();

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