private StoryService CreateStoryService() { var authorId = Guid.Parse(User.Identity.GetUserId()); var storyService = new StoryService(authorId); return(storyService); }
public void CallSaveChanges_WhenParamsAreValid() { // Arrange var contextMock = new Mock <ITravelGuideContext>(); var storyFactoryMock = new Mock <IStoryFactory>(); var likesFactoryMock = new Mock <IStoryLikeFactory>(); var commentsFactoryMock = new Mock <IStoryCommentFactory>(); var service = new StoryService(contextMock.Object, storyFactoryMock.Object, likesFactoryMock.Object, commentsFactoryMock.Object); var title = "title"; var content = "content"; var relatedDestination = "related"; var imageUrl = "url"; var userId = "id"; var user = new User(); contextMock.Setup(x => x.Users.Find(It.IsAny <string>())).Returns(user); var story = new Story(); storyFactoryMock.Setup(x => x.CreateStory(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <User>())).Returns(story); contextMock.Setup(x => x.Stories.Add(It.IsAny <Story>())); // Act service.CreateStory(title, content, relatedDestination, imageUrl, userId); // Assert contextMock.Verify(x => x.SaveChanges(), Times.Once); }
public async Task <IActionResult> Delete(string hashId) { if (!Guid.TryParse(CurrentUser.NameIdentifier, out Guid userId)) { return(Json(new { Status = false, Message = "Error deleting the story." })); } var model = await StoryService.Get(hashId, userId); if (model == null) { return(Json(new { Status = false, Message = "Error deleting the story." })); } if (!(CurrentUser.IsInRole(Roles.Admin) || CurrentUser.IsInRole(Roles.Moderator))) { if (!model.Summary.IsSubmitter) { return(Json(new { Status = false, Message = "You cannot deleted stories submitted by others." })); } var submitDate = DateTime.Parse(model.Summary.SubmittedDate); if (!model.Summary.IsDeletable) { return(Json(new { Status = false, Message = "Threshold for story deletion has expired. Moderator intervention is required to delete this story." })); } } var status = await StoryService.Delete(model.Summary.HashId); return(Json(new { Status = status })); }
public override void Create() { UserStoryDTO story = new UserStoryDTO { Name = this.EntityName, ProjectID = this.ProjectId }; if (IsDescriptionSet) { story.Description = this.Description; } if (!String.IsNullOrEmpty(this.State)) { story.EntityStateID = this.StateId; } int storyId = StoryService.Create(story); foreach (TargetProcessUser user in this.UsersToAssign) { StoryService.AssignUser(storyId, user.GetId()); } }
public CardController( StoryService storyService, MeredithDbContext meredithDbContext) { StoryService = storyService; MeredithDbContext = meredithDbContext; }
public override XmlDocument GenerateReport() { XmlDocument report = base.GenerateReport(); XmlElement rootElement = report.DocumentElement; UserStoryDTO story = StoryService.GetByID(this.UserStoryId); this.ProjectId = story.ProjectID.Value; this.TargetProcessProject = story.ProjectName; CustomFieldWebService.CustomFieldService fieldService = ServicesCF.GetService <CustomFieldWebService.CustomFieldService>(); CustomFieldWebService.CustomFieldDTO[] allCustomFields = fieldService.RetrieveAll(); List <CustomFieldWebService.CustomFieldDTO> customFields = allCustomFields.Where(field => field.EntityTypeName == this.EntityTypeName && field.ProcessID == this.ProcessId).ToList <CustomFieldWebService.CustomFieldDTO>(); foreach (CustomFieldWebService.CustomFieldDTO customField in customFields) { XmlNode customFieldNode = report.CreateNode(XmlNodeType.Element, null, "CustomField", null); XmlNode customFieldNameNode = report.CreateNode(XmlNodeType.Element, null, "Name", null); customFieldNameNode.InnerText = customField.Name; customFieldNode.AppendChild(customFieldNameNode); XmlNode customFieldValueNode = report.CreateNode(XmlNodeType.Element, null, "Value", null); PropertyInfo propertyInfo = story.GetType().GetProperty(customField.EntityFieldName); customFieldValueNode.InnerText = (String)propertyInfo.GetValue(story, null); customFieldNode.AppendChild(customFieldValueNode); rootElement.AppendChild(customFieldNode); } return(report); }
public InstructionTextDisplayElement() { this.storyService = App.Current.GetService <StoryService>(); this.builder = new InstructionTextBuilder(); TextOptions.SetTextHintingMode(this, TextHintingMode.Fixed); }
public ActionResult GetStoryList() { StoryService service = new StoryService(); var list = service.GetList().OrderBy(a => a.IndexSort).ToList(); return(Json(new { Code = "200", infolist = list })); }
public GlobalsViewModel( StoryService storyService, DebuggerService debuggerService, VariableViewService variableViewService) : base("GlobalsView") { this.storyService = storyService; this.debuggerService = debuggerService; this.debuggerService.MachineCreated += DebuggerService_MachineCreated; this.debuggerService.MachineDestroyed += DebuggerService_MachineDestroyed; this.debuggerService.StateChanged += DebuggerService_StateChanged; this.debuggerService.Stepped += DebuggerService_ProcessorStepped; this.variableViewService = variableViewService; variableViewService.GlobalViewChanged += VariableViewService_GlobalViewChanged; this.globals = new IndexedVariableViewModel[240]; for (int i = 0; i < 240; i++) { var newGlobal = new IndexedVariableViewModel(i, 0); newGlobal.Visible = false; globals[i] = newGlobal; } SetVariableViewCommand = RegisterCommand <KeyValuePair <VariableViewModel, VariableView> >( text: "Set Variable View", name: "SetVariableView", executed: SetVariableViewExecuted, canExecute: CanSetVariableViewExecute); }
public async Task <IActionResult> Index(string hashId) { StoryViewModel model = null; if (Guid.TryParse(CurrentUser.NameIdentifier, out Guid userId)) { model = await StoryService.Get(hashId, userId); if (CurrentUser.IsInRole(Roles.Moderator)) { model.Summary.IsDeletable = true; } } else { model = await StoryService.Get(hashId, null); } if (model == null) { return(NotFound()); } return(View(model)); }
public ActionResult Details(int id) { var service = new StoryService(); var model = service.GetStorybyID(id); return(View(model)); }
public void After_fetching_stories_that_number_of_stories_are_added_to_the_datastore() { //Arrange var addedStories = new List <Story>(); var dataStore = new Mock <IDataStore <Story> >(); dataStore .SetupGet(fake => fake.IsEmpty) .Returns(false); dataStore .Setup(mock => mock.AddOrUpdateAsync(It.IsAny <IEnumerable <Story> >())) .Callback <IEnumerable <Story> >(items => addedStories.AddRange(items)); var stories = new[] { new Mock <IStoryFromIntegration>().Object, new Mock <IStoryFromIntegration>().Object, new Mock <IStoryFromIntegration>().Object }; var integration = new Mock <IIntegration>(); integration .Setup(fake => fake.FetchAsync()) .ReturnsAsync(stories); var service = new StoryService(dataStore.Object, integration.Object); //Act service.GetAllAsync().Wait(); //Assert Assert.AreEqual(stories.Count(), addedStories.Count()); }
public StoryServiceFixture() { _factory = new Mock <IDomainObjectFactory>(); _categoryRepository = new Mock <ICategoryRepository>(); _tagRepository = new Mock <ITagRepository>(); _storyRepository = new Mock <IStoryRepository>(); _markAsSpamRepository = new Mock <IMarkAsSpamRepository>(); _eventAggregator = new Mock <IEventAggregator>(); _spamProtection = new Mock <ISpamProtection>(); _spamPostProcessor = new Mock <ISpamPostprocessor>(); _contentService = new Mock <IContentService>(); _htmlSanitizer = new Mock <IHtmlSanitizer>(); _voteStrategy = new Mock <IStoryWeightCalculator>(); _voteStrategy.SetupGet(s => s.Name).Returns("Vote"); _commentStrategy = new Mock <IStoryWeightCalculator>(); _commentStrategy.SetupGet(s => s.Name).Returns("Comment"); _viewStrategy = new Mock <IStoryWeightCalculator>(); _viewStrategy.SetupGet(s => s.Name).Returns("View"); _userScoreStrategy = new Mock <IStoryWeightCalculator>(); _userScoreStrategy.SetupGet(s => s.Name).Returns("User-Score"); _knownSourceStrategy = new Mock <IStoryWeightCalculator>(); _knownSourceStrategy.SetupGet(s => s.Name).Returns("Known-Source"); _freshnessStrategy = new Mock <IStoryWeightCalculator>(); _freshnessStrategy.SetupGet(s => s.Name).Returns("Freshness"); _storyService = new StoryService(settings.Object, _factory.Object, _categoryRepository.Object, _tagRepository.Object, _storyRepository.Object, _markAsSpamRepository.Object, _eventAggregator.Object, _spamProtection.Object, _spamPostProcessor.Object, _contentService.Object, _htmlSanitizer.Object, thumbnail.Object, new [] { _voteStrategy.Object, _commentStrategy.Object, _viewStrategy.Object, _userScoreStrategy.Object, _knownSourceStrategy.Object, _freshnessStrategy.Object }); }
// /// <summary> /// 编辑详情页 /// </summary> /// <returns></returns> public ActionResult EditStoryInfo(string id) { StoryService service = new StoryService(); var info = service.GetListById(id); return(View(info)); }
public void AddLineToStory_NullReference_Args1() { var mock = new Mock <Story>(); IStoryService service = new StoryService(); service.AddLineToStory(mock.Object, null); }
public ActionResult EditStory(Story info) { info.UpdateDate = DateTime.Now; StoryService service = new StoryService(); service.Update(info); return(Json(new { Code = "200", Message = "success" })); }
public MemoryMapViewModel( StoryService storyService) : base("MemoryMapView") { this.storyService = storyService; this.storyService.StoryOpened += StoryService_StoryOpened; this.storyService.StoryClosing += StoryService_StoryClosing; }
/// <summary> /// Initializes a new instance of the ApiService class /// </summary> /// <param name="apiPublicKey">The public API key provided by Marvel</param> /// <param name="apiPrivateKey">The private API key provided by Marvel</param> public ApiService(string apiPublicKey, string apiPrivateKey) { _characterService = ServiceLocator.GetCharacterService(apiPublicKey, apiPrivateKey); _comicService = ServiceLocator.GetComicService(apiPublicKey, apiPrivateKey); _creatorService = ServiceLocator.GetCreatorService(apiPublicKey, apiPrivateKey); _eventService = ServiceLocator.GetEventService(apiPublicKey, apiPrivateKey); _seriesService = ServiceLocator.GetSeriesService(apiPublicKey, apiPrivateKey); _storyService = ServiceLocator.GetStoryService(apiPublicKey, apiPrivateKey); }
public void ChangePriorityOfExistingStory() { ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities(); StoryService storyService = new StoryService(scrumTimeEntities); Story story = storyService.GetStoryById(2); story.Priority = 0; storyService.SaveStory(story); }
/// <summary> /// 保存 /// </summary> /// <param name="info"></param> /// <returns></returns> public ActionResult SaveStory(Story info) { info.StoryId = Guid.NewGuid().ToString(); info.CreateDate = DateTime.Now; info.UpdateDate = DateTime.Now; StoryService service = new StoryService(); service.Insert(info); return(Json(new { Code = "200", Message = "success" })); }
private async Task <IEnumerable <BestStory> > GetStoriesData() { MemoryCacheOptions options = new MemoryCacheOptions(); IMemoryCache memoryCache = new MemoryCache(options); IDataProvider dataProvider = new HackerNewsProvider(configurationMock.Object); IHackerNewsService hackerNewsService = new HackerNewsService(dataProvider); IStoryService storyService = new StoryService(hackerNewsService, configurationMock.Object, memoryCache); return(await storyService.GetBestStoriesAsync()); }
public MainWindowViewModel( StoryService storyService, GameScriptService gameScriptService, ProfilerService profilerService, ScreenViewModel screenViewModel, ProfilerViewModel profilerViewModel, GameInfoDialogViewModel gameInfoDialogViewModel, GameScriptDialogViewModel gameScriptDialogViewModel) : base("MainWindowView") { this.storyService = storyService; this.storyService.StoryOpened += StoryService_StoryOpened; this.storyService.StoryClosing += StoryService_StoryClosing; this.gameScriptService = gameScriptService; this.profilerService = profilerService; this.screenViewModel = screenViewModel; this.profilerViewModel = profilerViewModel; this.gameInfoDialogViewModel = gameInfoDialogViewModel; this.gameScriptDialogViewModel = gameScriptDialogViewModel; this.OpenStoryCommand = RegisterCommand( text: "Open", name: "Open", executed: OpenStoryExecuted, canExecute: OpenStoryCanExecute, inputGestures: new KeyGesture(Key.O, ModifierKeys.Control)); this.EditGameScriptCommand = RegisterCommand( text: "EditGameScript", name: "Edit Game Script", executed: EditGameScriptExecuted, canExecute: EditGameScriptCanExecute); this.ExitCommand = RegisterCommand( text: "Exit", name: "Exit", executed: ExitExecuted, canExecute: ExitCanExecute, inputGestures: new KeyGesture(Key.F4, ModifierKeys.Alt)); this.StopCommand = RegisterCommand( text: "Stop", name: "Stop", executed: StopExecuted, canExecute: StopCanExecute); this.AboutGameCommand = RegisterCommand( text: "AboutGame", name: "About Game", executed: AboutGameExecuted, canExecute: AboutGameCanExecute); }
public ProfilerViewModel( ProfilerService profilerService, StoryService storyService) : base("ProfilerView") { this.profilerService = profilerService; this.storyService = storyService; this.profilerService.Starting += ProfilerService_Starting; this.profilerService.Stopped += ProfilerService_Stopped; }
public void Get_Grouped_Stories_By_Date_InvalidSource() { // Arrange var section = "home"; var storyService = new StoryService(iLoggerFactory.Object.CreateLogger <IStoryService>(), serviceProvider.Object); sourceService.Setup(nt => nt.GetStoriesList(section)).Returns(Task.Run(() => new List <ArticleView>())); // Action, Assert Assert.ThrowsException <AggregateException>(() => storyService.GetGroupedStoriesByDate(StoriesSourceEnum.None, section).Result); }
public void AddLineToStory_AcceptTest() { var mock = new Mock <Story>(); IStoryService service = new StoryService(); var data = service.AddLineToStory(mock.Object, "TestLine"); var line = mock.Object.Lines.First(x => x.Content == "TestLine"); Assert.AreEqual(line, data.Data.Lines.First(x => x.Content == "TestLine")); }
public async Task Existing_stories_gets_their_title_updated() { //Arrange var existingStory = new Story { Id = 2718, Title = "Bar bar bar" }; var newTitle = "Foobar"; var addedOrUpdatedStories = new List <Story>(); var dataStore = new Mock <IDataStore <Story> >(); dataStore .SetupGet(fake => fake.IsEmpty) .Returns(false); dataStore .Setup(mock => mock.AddOrUpdateAsync(It.IsAny <IEnumerable <Story> >())) .Callback <IEnumerable <Story> >(items => addedOrUpdatedStories.AddRange(items)); dataStore .Setup(fake => fake.GetAllAsync()) .ReturnsAsync(new[] { existingStory }); var existingStoryInIntegration = new Mock <IStoryFromIntegration>(); existingStoryInIntegration .SetupGet(fake => fake.Id) .Returns(existingStory.Id); existingStoryInIntegration .SetupGet(fake => fake.Title) .Returns(newTitle); var stories = new[] { existingStoryInIntegration.Object, new Mock <IStoryFromIntegration>().Object, new Mock <IStoryFromIntegration>().Object }; var integration = new Mock <IIntegration>(); integration .Setup(fake => fake.FetchAsync()) .ReturnsAsync(stories); var service = new StoryService(dataStore.Object, integration.Object); //Act _ = await service.GetAllAsync(); //Assert var updatedVersionOfStory = addedOrUpdatedStories.Single(story => story.Id == existingStory.Id); Assert.AreEqual(newTitle, updatedVersionOfStory.Title); }
public HomeController() { var fileLoc = HostingEnvironment.MapPath("/"); _service = new StoryService(int.Parse(ConfigurationManager.ConnectionStrings["AgileProjectID"].ConnectionString), ConfigurationManager.ConnectionStrings["AgileKey"].ConnectionString, fileLoc); _tzService = new TimeZoneService(); _timeNotAssignedToStories = Math.Round(_tzService.EntriesNotAssignedToStories().Where(x => x.Role == "Senior Front End Developer" | x.Role == "Senior Developer" | x.Role == "Developer").Sum(x => x.Time) / 7,2); _overhead = Math.Round(_timeNotAssignedToStories / _service.GetStories().Sum(x => x.Actual) * 100, 2); }
public ScreenViewModel( StoryService storyService, GameScriptService gameScriptService) : base("ScreenView") { this.storyService = storyService; this.storyService.StoryOpened += StoryService_StoryOpened; this.storyService.StoryClosing += StoryService_StoryClosing; this.gameScriptService = gameScriptService; }
public async Task CreateIfStoryNull() { var userStories = new StoryService(_unitOfWorkMock.Object, _storyRepositoryMock.Object, _storfinderMock.Object, _userFinderMock.Object ); var result = await userStories.Create(null); Assert.IsTrue(result.Errors.First() == "Null Story"); }
public void GetStoriesByUserIDIfIdNull() { var userStories = new StoryService(_unitOfWorkMock.Object, _storyRepositoryMock.Object, _storfinderMock.Object, _userFinderMock.Object ); var result = userStories.GetStoriesByUserName(null); Assert.IsNull(result); }
public void GetStoriesOneIfIdNegative() { var userStories = new StoryService(_unitOfWorkMock.Object, _storyRepositoryMock.Object, _storfinderMock.Object, _userFinderMock.Object ); var result = userStories.GetStories(-2); Assert.IsTrue(result == null); }
public void TestFixtureSetUp() { this.storyService = new StoryService(Constants.ApiToken); }
public void TestFixtureSetUp() { storyService = new StoryService(AuthenticationService.Authenticate(Constants.Username, Constants.Password)); }