Beispiel #1
0
            public TestEnvironment()
            {
                UserSecrets = new MemoryRepository <UserSecret>(new[]
                {
                    new UserSecret
                    {
                        Id             = "user01",
                        ParatextTokens = new Tokens
                        {
                            AccessToken  = TokenHelper.CreateAccessToken(IssuedAt),
                            RefreshToken = "refresh_token"
                        }
                    }
                });

                RealtimeService = new MemoryRealtimeService();
                RealtimeService.AddRepository("users", OTType.Json0, new MemoryRepository <User>(new[]
                {
                    new User
                    {
                        Id         = "user01",
                        AvatarUrl  = "http://example.com/avatar.png",
                        AuthId     = "auth01",
                        ParatextId = "paratext01"
                    },
                    new User
                    {
                        Id        = "user02",
                        AvatarUrl = "http://example.com/avatar2.png",
                        AuthId    = "auth02"
                    }
                }));

                var options = Substitute.For <IOptions <SiteOptions> >();

                options.Value.Returns(new SiteOptions
                {
                    Id     = "xf",
                    Name   = "xForge",
                    Origin = new Uri("http://localhost")
                });

                Service = new UserService(RealtimeService, options, UserSecrets, AuthService, ProjectService,
                                          BetaMigration);
            }
Beispiel #2
0
            public TestEnvironment(bool isResetLinkExpired = false)
            {
                RealtimeService = new MemoryRealtimeService();
                RealtimeService.AddRepository("users", OTType.Json0,
                                              new MemoryRepository <User>(new[]
                {
                    new User
                    {
                        Id    = User01,
                        Email = "*****@*****.**",
                        Sites = new Dictionary <string, Site>
                        {
                            { SiteId, new Site()
                              {
                                  Projects = new List <String>()
                                  {
                                      Project01,
                                      Project02
                                  }
                              } }
                        }
                    },
                    new User
                    {
                        Id    = User02,
                        Email = "*****@*****.**",
                        Sites = new Dictionary <string, Site>
                        {
                            { SiteId, new Site()
                              {
                                  Projects = new List <String>()
                                  {
                                      Project01,
                                      Project02
                                  }
                              } }
                        }
                    },
                    new User
                    {
                        Id    = User03,
                        Email = "*****@*****.**",
                        Sites = new Dictionary <string, Site> {
                            { SiteId, new Site() }
                        }
                    }
                }));
                RealtimeService.AddRepository("projects", OTType.Json0,
                                              new MemoryRepository <TestProject>(new[]
                {
                    new TestProject
                    {
                        Id        = Project01,
                        Name      = "Project 1",
                        UserRoles =
                        {
                            { User01, TestProjectRole.Administrator },
                            { User02, TestProjectRole.Reviewer      }
                        }
                    },
                    new TestProject
                    {
                        Id        = Project02,
                        Name      = "Project 2",
                        UserRoles =
                        {
                            { User01, TestProjectRole.Administrator },
                            { User02, TestProjectRole.Reviewer      }
                        },
                        SyncDisabled = true
                    },
                }));

                var siteOptions = Substitute.For <IOptions <SiteOptions> >();

                siteOptions.Value.Returns(new SiteOptions
                {
                    Id      = SiteId,
                    Name    = "xForge",
                    Origin  = new Uri("http://localhost"),
                    SiteDir = "site"
                });
                AudioService = Substitute.For <IAudioService>();

                ProjectSecrets = new MemoryRepository <TestProjectSecret>(new[]
                {
                    new TestProjectSecret {
                        Id = Project01
                    }
                });

                FileSystemService = Substitute.For <IFileSystemService>();

                Service = new TestProjectService(RealtimeService, siteOptions, AudioService, ProjectSecrets,
                                                 FileSystemService);
            }