private AdventureService CreateAdventureService() { var userId = Guid.Parse(User.Identity.GetUserId()); var adventureService = new AdventureService(userId); return(adventureService); }
public IHttpActionResult Get() { AdventureService adventureService = CreateAdventureService(); var adventures = adventureService.GetAdventures(); return(Ok(adventures)); }
public IHttpActionResult Get(int id) { AdventureService adventureService = CreateAdventureService(); var adventure = adventureService.GetAdventureById(id); return(Ok(adventure)); }
public async Task GetQuestions_ShouldThrowException_WhenInvalidData(string json) { fileRepository.Setup(_ => _.IsFileExist(It.IsAny <string>())).Returns(true); fileRepository.Setup(_ => _.ReadFile(It.IsAny <string>())).Returns(json); var adventureService = new AdventureService(fileRepository.Object, logger.Object); await Assert.ThrowsAsync <InvalidDataException>(() => adventureService.GetQuestionsAsync("testName")); }
public async Task AdventuresAsync() { foreach (Adventure adventure in AdventureService.adventures.Values.ToList()) { Embed embed = AdventureService.GetAdventureEmbed(adventure); await ReplyAsync(null, embed : embed); } }
public async Task GetQuestions_ShouldReturnAllQuestion(string json, int count) { fileRepository.Setup(_ => _.IsFileExist(It.IsAny <string>())).Returns(true); fileRepository.Setup(_ => _.ReadFile(It.IsAny <string>())).Returns(json); var adventureService = new AdventureService(fileRepository.Object, logger.Object); var questions = await adventureService.GetQuestionsAsync("testName"); Assert.NotNull(questions); Assert.Equal(questions.Count(), count); }
public void Seed() { _adventures = new List <Adventure>(); _repo = new AdventureService(userId); Adventure seedAdventure = new Adventure(); { seedAdventure.AdventureId = 3004; seedAdventure.Title = "Beaches of Jamaica"; seedAdventure.Description = null; }; _adventures.Add(seedAdventure); }
public async Task StartAsync([Remainder] string adventurename) { if (!AdventureService.messageMarkers.ContainsKey(Context.Channel.Id)) { Dictionary <string, AdventureSegment> segments = AdventureService.adventures[adventurename].segments; string segIndex = "Start"; IUserMessage msg = await AdventureService.SendSegmentMessage(Context.Channel, adventurename, segIndex); messageMarker messageMarker = new messageMarker(msg.Id, adventurename, segIndex); AdventureService.messageMarkers.Add(msg.Channel.Id, messageMarker); } else { await ReplyAsync("Sorry but only one adventure is allowed in a channel at once"); } }
public async Task GetQuestions_ShouldThrowException_WhenInvalidPath() { fileRepository.Setup(_ => _.IsFileExist(It.IsAny <string>())).Returns(false); var adventureService = new AdventureService(fileRepository.Object, logger.Object); await Assert.ThrowsAsync <FileNotFoundException>(() => adventureService.GetQuestionsAsync("testName")); }