Beispiel #1
0
        public void CallUpdateMethod_WhenParamsMatch()
        {
            // Arrange
            var user     = new User();
            var username = "******";

            user.UserName = username;
            var individual = new Individual();

            individual.User = user;
            var data = new List <Individual>();

            data.Add(individual);

            var mockedEfWrappert = new Mock <IEfDbSetWrapper <Individual> >();

            mockedEfWrappert.SetupGet(m => m.All).Returns(data.AsQueryable());
            mockedEfWrappert.Setup(x => x.Update(It.IsAny <Individual>())).Verifiable();
            var mockedDbContext = new Mock <IUnitOfWork>();

            var service = new IndividualService(mockedEfWrappert.Object, mockedDbContext.Object);

            // Act
            service.CreateEvent(new Event(), username);

            // Assert
            mockedEfWrappert.Verify(x => x.Update(It.IsAny <Individual>()), Times.Once);
        }
Beispiel #2
0
        public void NotCallAllMethod_WhenPassedEventIsNull()
        {
            // Arrange
            var mockedEfWrappert = new Mock <IEfDbSetWrapper <Individual> >();

            mockedEfWrappert.Setup(x => x.All).Verifiable();
            var mockedDbContext = new Mock <IUnitOfWork>();

            var service = new IndividualService(mockedEfWrappert.Object, mockedDbContext.Object);

            // Act
            service.CreateEvent(null, "testUserId");

            // Assert
            mockedEfWrappert.Verify(x => x.All, Times.Never);
        }
Beispiel #3
0
        public void NotCallUpdateMethod_WhenParamsDoesntMatch()
        {
            // Arrange
            var data = new List <Individual>();

            var mockedEfWrappert = new Mock <IEfDbSetWrapper <Individual> >();

            mockedEfWrappert.SetupGet(m => m.All).Returns(data.AsQueryable());
            mockedEfWrappert.Setup(x => x.Update(It.IsAny <Individual>())).Verifiable();
            var mockedDbContext = new Mock <IUnitOfWork>();

            var service = new IndividualService(mockedEfWrappert.Object, mockedDbContext.Object);

            // Act
            service.CreateEvent(new Event(), "testUserId");

            // Assert
            mockedEfWrappert.Verify(x => x.Update(It.IsAny <Individual>()), Times.Never);
        }