Skip to content

Commit

Permalink
Merge pull request #695 from storybuilder-org/EnableRemainingTests
Browse files Browse the repository at this point in the history
  • Loading branch information
terrycox authored Jan 14, 2024
2 parents e507f9e + 9deb22d commit cefca28
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 35 deletions.
1 change: 1 addition & 0 deletions StoryCADLib/ViewModels/ShellViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ public static StoryModel GetModel()
/// </summary>
public static void ShowChange()
{
if (Ioc.Default.GetRequiredService<AppState>().StoryCADTestsMode) { return; }
if (ShellInstance.StoryModel.Changed) { return; }
ShellInstance.StoryModel.Changed = true;
ShellInstance.ChangeStatusColor = Colors.Red;
Expand Down
14 changes: 7 additions & 7 deletions StoryCADTests/CharacterModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
using System;

namespace StoryCADTests;
/*
* TODO: Finish this test.

[TestClass]
public class CharacterModelTests
{
Expand All @@ -17,14 +16,15 @@ public class CharacterModelTests
[TestMethod]
public void TestBlankTraits()
{
throw new Exception("This is broken");
CharacterViewModel CharVM = Ioc.Default.GetRequiredService<CharacterViewModel>();
Ioc.Default.GetService<ShellViewModel>().StoryModel = new();
var x = new CharacterModel(Ioc.Default.GetService<ShellViewModel>().StoryModel);
Ioc.Default.GetService<ShellViewModel>()!.StoryModel = new();
var x = new CharacterModel(Ioc.Default.GetService<ShellViewModel>()!.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);
}
}
*/
6 changes: 1 addition & 5 deletions StoryCADTests/ENVTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
/// 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.
Expand Down
15 changes: 5 additions & 10 deletions StoryCADTests/FileTests.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -76,17 +72,15 @@ public void FileCreation()
}


/*
* TODO: Finish this test.
/// <summary>
/// This tests a file load to ensure file creation works.
/// </summary>
[TestMethod]
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<StoryReader>();
Expand All @@ -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");
}

}
5 changes: 0 additions & 5 deletions StoryCADTests/IocLoaderTests.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
9 changes: 1 addition & 8 deletions StoryCADTests/StoryModelTests.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit cefca28

Please sign in to comment.