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

            user.UserName = username;
            var organization = new Organization();

            organization.User = user;
            var data = new List <Organization>();

            data.Add(organization);

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

            mockedEfWrappert.Setup(x => x.All).Returns(data.AsQueryable());
            mockedEfWrappert.Setup(x => x.Update(It.IsAny <Organization>())).Verifiable();
            var mockedDbContext         = new Mock <IUnitOfWork>();
            var mockedIndividualService = new Mock <IIndividualService>();

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

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

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

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

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

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

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

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

            mockedEfWrappert.Setup(x => x.All).Returns(data.AsQueryable());
            mockedEfWrappert.Setup(x => x.Update(It.IsAny <Organization>())).Verifiable();
            var mockedDbContext         = new Mock <IUnitOfWork>();
            var mockedIndividualService = new Mock <IIndividualService>();

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

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

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