示例#1
0
 public TopicControllerSpecs(TestDiscussionWebApp app)
 {
     _app = app.Reset();
     _app.DeleteAll <Topic>();
     _app.DeleteAll <WeChatAccount>();
     _author = _app.CreateUser();
 }
示例#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 AccountRelatedPageSpecs(TestDiscussionWebApp app)
 {
     _app = app.Reset();
     _antiForgeryTokens = _app.GetAntiForgeryTokens();
     _userRepo          = _app.GetService <IRepository <User> >();
     _userManager       = _app.GetService <UserManager <User> >();
 }
示例#4
0
 public UserManagerSpecs(TestDiscussionWebApp app)
 {
     _app         = app;
     _userManager = app.GetService <UserManager <User> >();
     _userRepo    = app.GetService <IRepository <User> >();
     _app.DeleteAll <User>();
 }
示例#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>();
 }
示例#6
0
        public TopicBuilder(TestDiscussionWebApp app)
        {
            _app = app;

            _topic.Title   = "dummy topic title " + StringUtility.Random(6);
            _topic.Content = "**dummy topic**\n\n content " + StringUtility.Random(12);
            _topic.Type    = TopicType.Discussion;
        }
        public CommonControllerSpecs(TestDiscussionWebApp app)
        {
            _app        = app.Reset();
            _fileRepo   = _app.GetService <IRepository <FileRecord> >();
            _fs         = _app.GetService <IFileSystem>();
            _tagBuilder = _app.GetService <ITagBuilder>();

            _app.DeleteAll <FileRecord>();
        }
        public void should_use_temporary_database_when_no_database_connection_string_specified()
        {
            var app = TestDiscussionWebApp.BuildTestApplication <Startup>(new TestDiscussionWebApp(initialize: false), "UnitTest");

            var logs = app.GetLogs();

            logs.ShouldNotBeNull();
            logs.ShouldContain(item => item.Message.Contains("数据库结构创建并更新完成"));

            (app as IDisposable).Dispose();
        }
        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>();
        }
示例#10
0
        public static TopicBuilder NewTopic(this TestDiscussionWebApp app,
                                            string title   = null,
                                            string content = null,
                                            TopicType type = TopicType.Discussion)
        {
            var tb = new TopicBuilder(app).WithType(type);

            if (title != null)
            {
                tb.WithTitle(title);
            }
            if (content != null)
            {
                tb.WithContent(content);
            }

            return(tb);
        }
        public void should_use_iis_platform()
        {
            var app = TestDiscussionWebApp.BuildTestApplication <Startup>(new TestDiscussionWebApp(initialize: false), "UnitTest", host =>
            {
                host.UseSetting("PORT", "5000");
                host.UseSetting("APPL_PATH", "/");
                host.UseSetting("TOKEN", "dummy-token");
            });

            var filters = app.Server.Host
                          .Services
                          .GetServices <IStartupFilter>()
                          .ToList();

            filters.ShouldContain(f => f.GetType().FullName.Contains("IISSetupFilter"));

            (app as IDisposable).Dispose();
        }
 public ReplyControllerSpecs(TestDiscussionWebApp app)
 {
     _app = app.Reset();
 }
示例#13
0
 public NotFoundSpecs(TestDiscussionWebApp app)
 {
     _app = app;
 }
 public ChangePasswordViewModelSpecs(TestDiscussionWebApp app)
 {
     _app = app;
 }
示例#15
0
 public ReplyPageSpecs(TestDiscussionWebApp app)
 {
     _app = app.Reset();
 }
示例#16
0
 public DefaultUserServiceSpecs(TestDiscussionWebApp app)
 {
     _app = app;
 }
示例#17
0
 public UserRelatedPageSpecs(TestDiscussionWebApp app)
 {
     _app = app.Reset();
     _app.DeleteAll <User>();
 }
示例#18
0
 public TopicRelatedPagesSpecs(TestDiscussionWebApp app)
 {
     _app = app.Reset();
 }
示例#19
0
 public HomePageSpecs(TestDiscussionWebApp app)
 {
     _app = app;
 }
 public AccountControllerSpecs(TestDiscussionWebApp app)
 {
     _app      = app.Reset();
     _userRepo = _app.GetService <IRepository <User> >();
 }
示例#21
0
 public HomeControllerSpecs(TestDiscussionWebApp app)
 {
     _theApp = app;
 }
示例#22
0
 public ArticleRepoSpecs(TestDiscussionWebApp app)
 {
     _applicationServices = app.ApplicationServices;
 }
 public IdentityUserActionHttpFilterSpecs(TestDiscussionWebApp app)
 {
     _app = app;
 }
示例#24
0
 public ExternalSigninManagerSpecs(TestDiscussionWebApp app)
 {
     _app = app.Reset();
     app.DeleteAll <User>();
 }
 public MiddlewareConfigureSpecs(TestDiscussionWebApp app)
 {
     this._app = app;
     server    = app.Server;
 }
 public SigninUserModelSpecs(TestDiscussionWebApp app)
 {
     _app = app;
 }
示例#27
0
 public AccountRelatedPageSpecs(TestDiscussionWebApp app)
 {
     _app = app.Reset();
     _antiForgeryTokens = _app.GetAntiForgeryTokens();
 }
示例#28
0
 public CommonRelatedApiSpecs(TestDiscussionWebApp app)
 {
     _app = app.Reset();
 }
示例#29
0
 public CreateTopicModelSpecs(TestDiscussionWebApp app)
 {
     _app = app;
 }
 public ReplyCreationModelSpecs(TestDiscussionWebApp app)
 {
     _app = app;
 }