Esempio n. 1
0
        public void GetByDomain()
        {
            var options = new DbContextOptionsBuilder <TestingCenterDbContext>()
                          .UseInMemoryDatabase(databaseName: "Add_writes_to_database")
                          .Options;
            var context = new TestingCenterDbContext(options);

            context.Projects.Add(new Project()
            {
                Name           = "Test",
                IsActive       = true,
                ProjectDomains = new List <ProjectDomain>()
                {
                    new ProjectDomain()
                    {
                        Domain   = "test.com",
                        IsActive = true
                    }
                },
                UserInProject = new List <UserInProject>()
                {
                    new UserInProject()
                    {
                        IsActive  = true,
                        UserModel = new UserModel()
                        {
                            IsActive = true
                        },
                        UserProjectStatus = new UserProjectStatus()
                        {
                            Name = "Pending"
                        }
                    }
                }
            });
            context.SaveChanges();
            var user = context.UserModel.FirstOrDefault(x => x.IsActive);
            var projectRepository = new ProjectRepository(context);
            var userHelper        = new Mock <IUserHelper>();
            var unitOfWork        = new Mock <IUnitOfWork>();
            var userRepository    = new Mock <IUserRepository>();
            var utilHelper        = new Mock <IUtilHelper>();

            userHelper.Setup(x => x.GetGuid(It.IsAny <ClaimsPrincipal>())).Returns(() => user.Guid.ToString());


            var controller = new ProjectController(projectRepository, userHelper.Object, unitOfWork.Object, userRepository.Object, utilHelper.Object);

            var result = controller.Get("test.com");

            Assert.NotNull(result);
        }
Esempio n. 2
0
 public int SaveChanges()
 {
     return(_context.SaveChanges(this));;
 }