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; 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;