From 4a22c0a971f270a436ceb85745fddb11cedda07e Mon Sep 17 00:00:00 2001 From: Jake <49795711+Rarisma@users.noreply.github.com> Date: Sun, 14 Jan 2024 19:41:16 +0000 Subject: [PATCH 1/2] Finish work on remaining tests --- StoryCADTests/CharacterModelTests.cs | 14 +++++++------- StoryCADTests/ENVTests.cs | 6 +----- StoryCADTests/FileTests.cs | 15 +++++---------- StoryCADTests/IocLoaderTests.cs | 5 ----- StoryCADTests/StoryModelTests.cs | 9 +-------- 5 files changed, 14 insertions(+), 35 deletions(-) diff --git a/StoryCADTests/CharacterModelTests.cs b/StoryCADTests/CharacterModelTests.cs index b6b37360..4ff17b35 100644 --- a/StoryCADTests/CharacterModelTests.cs +++ b/StoryCADTests/CharacterModelTests.cs @@ -5,8 +5,7 @@ using System; namespace StoryCADTests; -/* - * TODO: Finish this test. + [TestClass] public class CharacterModelTests { @@ -17,14 +16,15 @@ public class CharacterModelTests [TestMethod] public void TestBlankTraits() { - throw new Exception("This is broken"); CharacterViewModel CharVM = Ioc.Default.GetRequiredService(); - Ioc.Default.GetService().StoryModel = new(); - var x = new CharacterModel(Ioc.Default.GetService().StoryModel); + Ioc.Default.GetService()!.StoryModel = new(); + var x = new CharacterModel(Ioc.Default.GetService()!.StoryModel); CharVM.Activate(x); CharVM.NewTrait = String.Empty; CharVM.AddTraitCommand.Execute(null); - + Assert.IsTrue(CharVM.CharacterTraits.Count == 0); + CharVM.NewTrait = " TEST "; + CharVM.AddTraitCommand.Execute(null); + Assert.IsTrue(CharVM.CharacterTraits.Count == 1); } } -*/ \ No newline at end of file diff --git a/StoryCADTests/ENVTests.cs b/StoryCADTests/ENVTests.cs index 89bfbd3d..1f801609 100644 --- a/StoryCADTests/ENVTests.cs +++ b/StoryCADTests/ENVTests.cs @@ -2,18 +2,14 @@ using dotenv.net.Utilities; using dotenv.net; using Microsoft.VisualStudio.TestTools.UnitTesting; -using Syncfusion.Licensing; using System.IO; -using Windows.ApplicationModel; -using CommunityToolkit.Mvvm.DependencyInjection; -using StoryCAD.Services.Backend; using StoryCAD.Services.Json; using System.Threading.Tasks; namespace StoryCADTests; /// -/// All the tests here require a .ENV File.If you are unaffilliated +/// All the tests here require a .ENV File.If you are unaffiliated /// with Storybuilder-org i.e you are a contributor. You will /// not have this file in your copy of StoryCAD and these tests /// as a result will always fail. diff --git a/StoryCADTests/FileTests.cs b/StoryCADTests/FileTests.cs index c199fd31..80da4ee7 100644 --- a/StoryCADTests/FileTests.cs +++ b/StoryCADTests/FileTests.cs @@ -1,13 +1,9 @@ using CommunityToolkit.Mvvm.DependencyInjection; -using Microsoft.UI.Xaml; using Microsoft.VisualStudio.TestTools.UnitTesting; -using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer; using StoryCAD.DAL; using StoryCAD.Models; using StoryCAD.ViewModels; using System; -using System.Collections.ObjectModel; -using System.Diagnostics; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -76,8 +72,6 @@ public void FileCreation() } - /* - * TODO: Finish this test. /// /// This tests a file load to ensure file creation works. /// @@ -85,8 +79,8 @@ public void FileCreation() public async Task FileLoad() { // Arrange - string filePath = @"C:\Users\RARI\Desktop\OpenTest.stbx"; // Ensure this file exists and is accessible - Assert.IsTrue(System.IO.File.Exists(filePath), "Test file does not exist."); + string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestInputs", "OpenTest.stbx"); // Ensure this file exists and is accessible + Assert.IsTrue(File.Exists(filePath), "Test file does not exist."); StorageFile file = await StorageFile.GetFileFromPathAsync(filePath); StoryReader _rdr = Ioc.Default.GetRequiredService(); @@ -95,7 +89,8 @@ public async Task FileLoad() StoryModel storyModel = await _rdr.ReadFile(file); // Assert - Assert.AreEqual(3, storyModel.StoryElements.Count, "Story elements count mismatch."); - }*/ + Assert.AreEqual(6, storyModel.StoryElements.Count, "Story elements count mismatch."); + Assert.AreEqual(5, storyModel.ExplorerView.Count, "Overview Children count mismatch"); + } } diff --git a/StoryCADTests/IocLoaderTests.cs b/StoryCADTests/IocLoaderTests.cs index 22bf7b08..6dde6c37 100644 --- a/StoryCADTests/IocLoaderTests.cs +++ b/StoryCADTests/IocLoaderTests.cs @@ -1,18 +1,13 @@ using CommunityToolkit.Mvvm.DependencyInjection; using dotenv.net; -using Microsoft.UI.Xaml; using Microsoft.VisualStudio.TestTools.UnitTesting; -using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer; using StoryCAD.Models; using StoryCAD.Services.Backend; using StoryCAD.Services.IoC; using StoryCAD.ViewModels; using StoryCAD.ViewModels.Tools; using System; -using System.Diagnostics; using System.IO; -using Windows.ApplicationModel; -using Microsoft.UI.Dispatching; namespace StoryCADTests { diff --git a/StoryCADTests/StoryModelTests.cs b/StoryCADTests/StoryModelTests.cs index 4d929f6c..39c73138 100644 --- a/StoryCADTests/StoryModelTests.cs +++ b/StoryCADTests/StoryModelTests.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.UI.Xaml.Controls; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer; +using Microsoft.VisualStudio.TestTools.UnitTesting; using StoryCAD.Models; namespace StoryCADTests; From 9deb22dadec1ff0683e578109776e941ff07b76e Mon Sep 17 00:00:00 2001 From: Jake <49795711+Rarisma@users.noreply.github.com> Date: Sun, 14 Jan 2024 20:42:51 +0000 Subject: [PATCH 2/2] Fix issue preventing Autobuilder from running test --- StoryCADLib/ViewModels/ShellViewModel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/StoryCADLib/ViewModels/ShellViewModel.cs b/StoryCADLib/ViewModels/ShellViewModel.cs index 3a9993e4..f232bd46 100644 --- a/StoryCADLib/ViewModels/ShellViewModel.cs +++ b/StoryCADLib/ViewModels/ShellViewModel.cs @@ -335,6 +335,7 @@ public static StoryModel GetModel() /// public static void ShowChange() { + if (Ioc.Default.GetRequiredService().StoryCADTestsMode) { return; } if (ShellInstance.StoryModel.Changed) { return; } ShellInstance.StoryModel.Changed = true; ShellInstance.ChangeStatusColor = Colors.Red;