public void Add_SavesToDatabase() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "AddQuest_ToDb") .Options; using (var context = new GameInfoContext(options)) { var questToAdd = new AddQuestInputModel() { Title = "QuestTitle", QuestText = "QuestText", CompletionCondition = "None" }; questToAdd.QuestGiver = null; var service = new QuestsService(context, null); service.Add(questToAdd); var expectedQuest = new Quest() { Title = questToAdd.Title, QuestText = questToAdd.QuestText, CompletionCondition = questToAdd.CompletionCondition }; Assert.NotEmpty(context.Quests); Assert.Equal(expectedQuest.Title, context.Quests.First().Title); Assert.Equal(expectedQuest.QuestText, context.Quests.First().QuestText); Assert.Equal(expectedQuest.CompletionCondition, context.Quests.First().CompletionCondition); } }
public void All_WithData_ReturnsSameData() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "Db_WithQuests") .Options; using (var context = new GameInfoContext(options)) { var service = new QuestsService(context, null); var quests = new List <Quest> { new Quest() { Title = "1", QuestText = "1", CompletionCondition = "1" }, new Quest() { Title = "2", QuestText = "2", CompletionCondition = "2" }, new Quest() { Title = "3", QuestText = "3", CompletionCondition = "3" } }; context.Quests.AddRange(quests); context.SaveChanges(); Assert.Equal(3, service.All().Count); } }
public QuestsViewModel() { var qs = new QuestsService(); Quests = qs.GetQuestBySubSubClass(QuestClass, SubQuestClass, SubSubQuestClass); Title = SubSubQuestClass; }
public SubQuestClassesViewModel() { var qs = new QuestsService(); SubQuestClasses = qs.GetSubQuestClassNames(QuestClass); Title = QuestClass; }
public void ByName_WithQuest_ReturnsQuest() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "DbFor_ByName_WithQuest") .Options; using (var context = new GameInfoContext(options)) { var service = new QuestsService(context, null); var questTitle = "QuestTitle"; var quest = new Quest() { Title = questTitle, QuestText = "TextForQuest", CompletionCondition = "None" }; context.Quests.Add(quest); context.SaveChanges(); var questFromDb = service.ByName(questTitle); Assert.Equal(quest.Title, questFromDb.Title); Assert.Equal(quest.QuestText, questFromDb.QuestText); Assert.Equal(quest.CompletionCondition, questFromDb.CompletionCondition); } }
private void SetQuests() { var qs = new QuestsService(); QuestTotal = qs.GetTotal(); QuestComplete = qs.GetNumberOfComplete(); }
private void CheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) { var qs = new QuestsService(); var questChecked = (CheckBox)sender; qs.UpdateQuestCheck(questChecked.IsChecked, Quest); }
public QuestsViewModel(string questClass) { QuestClass = questClass; var qs = new QuestsService(); Quests = qs.GetQuestByClass(QuestClass); Title = SubSubQuestClass; }
private void CheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) { var qs = new QuestsService(); var questChecked = (CheckBox)sender; Quest quest = questChecked.BindingContext as Quest; qs.UpdateQuestCheck(questChecked.IsChecked, quest); }
public SubSubQuestClassesViewModel(string questClass, string subQuestClass) { QuestClass = questClass; SubQuestClass = subQuestClass; var qs = new QuestsService(); SubSubQuestClasses = qs.GetSubSubQuestClassNames(QuestClass, SubQuestClass); Title = QuestClass; }
public QuestPage(Quest quest) { Quest = quest; InitializeComponent(); var qs = new QuestsService(); QuestLocation = qs.GetLocationByQuest(Quest); this.BindingContext = new QuestViewModel(Quest); }
public void All_WithNoData_ReturnsNoData() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "NoQuests_Db") .Options; using (var context = new GameInfoContext(options)) { var service = new QuestsService(context, null); Assert.Equal(0, service.All().Count); } }
public void ById_WithNoQuests_ReturnsNull() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "NoQuests_DbFor_ById") .Options; using (var context = new GameInfoContext(options)) { var service = new QuestsService(context, null); Assert.Null(service.ById(1)); } }
public void Delete_NoData_ReturnsNull() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "NoQuests_Db_ForDelete") .Options; using (var context = new GameInfoContext(options)) { var service = new QuestsService(context, null); Assert.False(service.Delete(2)); } }
public void OnMore(object sender, EventArgs e) { var item = (ListView)sender; var subQuestClass = item.SelectedItem.ToString(); var qs = new QuestsService(); if (qs.GetSubSubQuestClassNames(QuestClass, subQuestClass).Count > 1) { Navigation.PushAsync(new SubSubQuestClassesPage(QuestClass, subQuestClass)); } else { Navigation.PushAsync(new QuestsPage(QuestClass, subQuestClass)); } }
public QuestViewModel(Quest quest) { Quest = quest; Title = Quest.QuestName; var qs = new QuestsService(); if (Quest.Location != "") { QuestLocation = qs.GetLocationByQuest(Quest); if (QuestLocation == null) { return; } HasLocationLink = true; } }
public void Delete_WithData_DeletesQuest() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "Db_WithQuest_ForDelete") .Options; using (var context = new GameInfoContext(options)) { context.Quests.Add(new Quest() { Title = "ToDelete", QuestText = "None", CompletionCondition = "None" }); context.SaveChanges(); } using (var context = new GameInfoContext(options)) { var service = new QuestsService(context, null); var result = service.Delete(1); Assert.True(result); Assert.Equal(0, context.Quests.Count()); } }
public QuestClassesViewModel() { var qs = new QuestsService(); QuestClasses = qs.GetQuestClassNames(); }
public QuestsController(QuestsService service) { _service = service; }
public QuestsController(QuestsService qs) { _qs = qs; }
public KnightsController(KnightsService ks, QuestsService qs) { _ks = ks; _qs = qs; }