public void SolveTopic() { var topicRepository = Substitute.For<ITopicRepository>(); var postRepository = Substitute.For<IPostRepository>(); var membershipUserPointsService = Substitute.For<IMembershipUserPointsService>(); var settingsService = Substitute.For<ISettingsService>(); settingsService.GetSettings().Returns(new Settings { PointsAddedForSolution = 20 }); var topicService = new TopicService(membershipUserPointsService, settingsService, topicRepository, postRepository, _api, _topicNotificationService); var marker = new MembershipUser { UserName = "******", Id = Guid.NewGuid() }; var topic = new Topic { Name = "something", Tags = new List<TopicTag> { new TopicTag{Tag = "tagone"}, new TopicTag{Tag = "tagtwo"} }, User = marker }; var post = new Post() {PostContent = "Test content"}; var solutionWriter = new MembershipUser {UserName = "******"}; topicService.SolveTopic(topic, post, marker, solutionWriter); Assert.IsTrue(topic.Solved); }
public void Delete_Check_Tags_Are_Cleared() { var topicRepository = Substitute.For<ITopicRepository>(); var postRepository = Substitute.For<IPostRepository>(); var membershipUserPointsService = Substitute.For<IMembershipUserPointsService>(); var settingsService = Substitute.For<ISettingsService>(); var topicService = new TopicService(membershipUserPointsService, settingsService, topicRepository, postRepository, _api, _topicNotificationService); var topic = new Topic { Name = "something", Tags = new List<TopicTag> { new TopicTag{Tag = "tagone"}, new TopicTag{Tag = "tagtwo"} } }; topicService.Delete(topic); Assert.IsTrue(!topic.Tags.Any()); }
public void BeforeMarkedAsSolutionCancel() { var topicRepository = Substitute.For<ITopicRepository>(); var postRepository = Substitute.For<IPostRepository>(); var membershipUserPointsService = Substitute.For<IMembershipUserPointsService>(); var settingsService = Substitute.For<ISettingsService>(); var topicService = new TopicService(membershipUserPointsService, settingsService, topicRepository, postRepository, _api, _topicNotificationService); var marker = new MembershipUser { UserName = "******", Id = Guid.NewGuid() }; var topic = new Topic { Name = "something", Tags = new List<TopicTag> { new TopicTag{Tag = "tagone"}, new TopicTag{Tag = "tagtwo"} }, User = marker }; var post = new Post { PostContent = "Test content" }; var solutionWriter = new MembershipUser { UserName = "******" }; EventManager.Instance.BeforeMarkedAsSolution += eventsService_BeforeMarkedAsSolutionCancel; topicService.SolveTopic(topic, post, marker, solutionWriter); postRepository.DidNotReceive().Update(Arg.Is<Post>(x => x.PostContent == "Test content")); Assert.IsFalse(topic.Solved); EventManager.Instance.BeforeMarkedAsSolution -= eventsService_BeforeMarkedAsSolutionCancel; }