public TopicControllerSpecs(TestDiscussionWebApp app) { _app = app.Reset(); _app.DeleteAll <Topic>(); _app.DeleteAll <WeChatAccount>(); _author = _app.CreateUser(); }
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> >(); }
public UserManagerSpecs(TestDiscussionWebApp app) { _app = app; _userManager = app.GetService <UserManager <User> >(); _userRepo = app.GetService <IRepository <User> >(); _app.DeleteAll <User>(); }
public UserControllerSpecs(TestDiscussionWebApp theApp) { _theApp = theApp; _userRepo = _theApp.GetService <IRepository <User> >(); _phoneVerifyRepo = theApp.GetService <IRepository <PhoneNumberVerificationRecord> >(); _phoneRepo = theApp.GetService <IRepository <VerifiedPhoneNumber> >(); _theApp.DeleteAll <User>(); }
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>(); }
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(); }
public NotFoundSpecs(TestDiscussionWebApp app) { _app = app; }
public ChangePasswordViewModelSpecs(TestDiscussionWebApp app) { _app = app; }
public ReplyPageSpecs(TestDiscussionWebApp app) { _app = app.Reset(); }
public DefaultUserServiceSpecs(TestDiscussionWebApp app) { _app = app; }
public UserRelatedPageSpecs(TestDiscussionWebApp app) { _app = app.Reset(); _app.DeleteAll <User>(); }
public TopicRelatedPagesSpecs(TestDiscussionWebApp app) { _app = app.Reset(); }
public HomePageSpecs(TestDiscussionWebApp app) { _app = app; }
public AccountControllerSpecs(TestDiscussionWebApp app) { _app = app.Reset(); _userRepo = _app.GetService <IRepository <User> >(); }
public HomeControllerSpecs(TestDiscussionWebApp app) { _theApp = app; }
public ArticleRepoSpecs(TestDiscussionWebApp app) { _applicationServices = app.ApplicationServices; }
public IdentityUserActionHttpFilterSpecs(TestDiscussionWebApp app) { _app = app; }
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; }
public AccountRelatedPageSpecs(TestDiscussionWebApp app) { _app = app.Reset(); _antiForgeryTokens = _app.GetAntiForgeryTokens(); }
public CommonRelatedApiSpecs(TestDiscussionWebApp app) { _app = app.Reset(); }
public CreateTopicModelSpecs(TestDiscussionWebApp app) { _app = app; }
public ReplyCreationModelSpecs(TestDiscussionWebApp app) { _app = app; }