Ejemplo n.º 1
0
 public TopicControllerSpecs(TestDiscussionWebApp app)
 {
     _app = app.Reset();
     _app.DeleteAll <Topic>();
     _app.DeleteAll <WeChatAccount>();
     _author = _app.CreateUser();
 }
Ejemplo n.º 2
0
        public ChatHistoryImporterSpecs(TestDiscussionWebApp app)
        {
            var urlHelper = new Mock <IUrlHelper>();

            urlHelper.Setup(url => url.Action(It.IsAny <UrlActionContext>())).Returns("http://mock-url/");

            var currentUser = new Mock <ICurrentUser>();

            currentUser.SetupGet(u => u.DiscussionUser).Returns(new User {
                Id = 42
            });

            var chatyApiService = new Mock <ChatyApiServiceMock>();

            chatyApiService.Setup(chaty => chaty.DownloadChatFile(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(Task.FromResult((Stream) new MemoryStream()));

            _fileRepo          = app.GetService <IRepository <FileRecord> >();
            _weChatAccountRepo = app.GetService <IRepository <WeChatAccount> >();
            _importer          = new DefaultChatHistoryImporter(app.GetService <IClock>(),
                                                                urlHelper.Object,
                                                                _fileRepo,
                                                                _weChatAccountRepo,
                                                                app.GetService <IFileSystem>(),
                                                                currentUser.Object,
                                                                chatyApiService.Object);

            app.DeleteAll <FileRecord>();
            app.DeleteAll <WeChatAccount>();
        }
        public ChatHistoryImporterSpecs(TestDiscussionWebApp app)
        {
            var urlHelper = new Mock <IUrlHelper>();

            urlHelper.Setup(url => url.Action(It.IsAny <UrlActionContext>())).Returns("http://mock-url/");

            var httpClient = StubHttpClient.Create().When(req =>
            {
                var ms = new MemoryStream();
                ms.Write(Encoding.UTF8.GetBytes("This is file content"));
                ms.Seek(0, SeekOrigin.Begin);

                return(new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StreamContent(ms)
                    {
                        Headers =
                        {
                            ContentType = new MediaTypeHeaderValue("application/octet-stream")
                        }
                    }
                });
            });

            var currentUser = new Mock <ICurrentUser>();

            currentUser.SetupGet(u => u.DiscussionUser).Returns(new User {
                Id = 42
            });

            var options = new ChatyOptions
            {
                ServiceBaseUrl = "http://chaty/"
            };
            var optionsMock = new Mock <IOptions <ChatyOptions> >();

            optionsMock.SetupGet(o => o.Value).Returns(options);

            _fileRepo          = app.GetService <IRepository <FileRecord> >();
            _weChatAccountRepo = app.GetService <IRepository <WeChatAccount> >();
            _importer          = new DefaultChatHistoryImporter(app.GetService <IClock>(),
                                                                httpClient,
                                                                urlHelper.Object,
                                                                _fileRepo,
                                                                _weChatAccountRepo,
                                                                app.GetService <IFileSystem>(),
                                                                currentUser.Object,
                                                                optionsMock.Object);

            app.DeleteAll <FileRecord>();
            app.DeleteAll <WeChatAccount>();
        }
Ejemplo n.º 4
0
 public UserManagerSpecs(TestDiscussionWebApp app)
 {
     _app         = app;
     _userManager = app.GetService <UserManager <User> >();
     _userRepo    = app.GetService <IRepository <User> >();
     _app.DeleteAll <User>();
 }
Ejemplo n.º 5
0
 public UserControllerSpecs(TestDiscussionWebApp theApp)
 {
     _theApp          = theApp;
     _userRepo        = _theApp.GetService <IRepository <User> >();
     _phoneVerifyRepo = theApp.GetService <IRepository <PhoneNumberVerificationRecord> >();
     _phoneRepo       = theApp.GetService <IRepository <VerifiedPhoneNumber> >();
     _theApp.DeleteAll <User>();
 }
Ejemplo n.º 6
0
        public CommonControllerSpecs(TestDiscussionWebApp app)
        {
            _app        = app.Reset();
            _fileRepo   = _app.GetService <IRepository <FileRecord> >();
            _fs         = _app.GetService <IFileSystem>();
            _tagBuilder = _app.GetService <ITagBuilder>();

            _app.DeleteAll <FileRecord>();
        }
Ejemplo n.º 7
0
 public UserRelatedPageSpecs(TestDiscussionWebApp app)
 {
     _app = app.Reset();
     _app.DeleteAll <User>();
 }
Ejemplo n.º 8
0
 public ExternalSigninManagerSpecs(TestDiscussionWebApp app)
 {
     _app = app.Reset();
     app.DeleteAll <User>();
 }