2014-07-26 07:12:56 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
using RainmeterStudio.Storage;
|
|
|
|
|
using System.IO;
|
2014-08-12 13:33:13 +00:00
|
|
|
|
using RainmeterStudio.Core.Model;
|
2014-08-31 11:41:24 +00:00
|
|
|
|
using Version = RainmeterStudio.Core.Utils.Version;
|
2014-07-26 07:12:56 +00:00
|
|
|
|
|
|
|
|
|
namespace RainmeterStudio.Tests.Storage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Tests the ProjectStorage class
|
|
|
|
|
/// </summary>
|
|
|
|
|
[TestClass]
|
|
|
|
|
public class ProjectStorageTest
|
|
|
|
|
{
|
|
|
|
|
private ProjectStorage ProjectStorage = new ProjectStorage();
|
|
|
|
|
|
|
|
|
|
public TestContext TestContext { get; set; }
|
|
|
|
|
|
|
|
|
|
[TestInitialize]
|
|
|
|
|
public void Initialize()
|
|
|
|
|
{
|
|
|
|
|
Directory.SetCurrentDirectory(TestContext.DeploymentDirectory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void ProjectStorageSmokeTest()
|
|
|
|
|
{
|
|
|
|
|
string filename = TestContext.TestName + ".rsproj";
|
|
|
|
|
|
|
|
|
|
// Create project
|
|
|
|
|
Project project = CreateProject();
|
|
|
|
|
|
|
|
|
|
// Save and load
|
2014-08-31 11:41:24 +00:00
|
|
|
|
ProjectStorage.Save(project, filename);
|
2014-07-26 07:12:56 +00:00
|
|
|
|
Project res = ProjectStorage.Load(filename);
|
|
|
|
|
|
|
|
|
|
// Verify results
|
|
|
|
|
Assert.IsNotNull(res);
|
|
|
|
|
Assert.AreEqual(project.Author, res.Author);
|
|
|
|
|
Assert.AreEqual(project.AutoLoadFile, res.AutoLoadFile);
|
|
|
|
|
Assert.AreEqual(project.MinimumRainmeter, res.MinimumRainmeter);
|
|
|
|
|
Assert.AreEqual(project.MinimumWindows, res.MinimumWindows);
|
|
|
|
|
Assert.AreEqual(project.Name, res.Name);
|
|
|
|
|
Assert.AreEqual(project.Root, res.Root);
|
|
|
|
|
Assert.IsTrue(project.VariableFiles.SequenceEqual(res.VariableFiles));
|
|
|
|
|
Assert.AreEqual(project.Version, res.Version);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void ProjectStorageEmptyProjectSmokeTest()
|
|
|
|
|
{
|
|
|
|
|
string filename = TestContext.TestName + ".rsproj";
|
|
|
|
|
|
|
|
|
|
// Create a project
|
|
|
|
|
Project project = new Project();
|
|
|
|
|
|
|
|
|
|
// Save and load project
|
2014-08-31 11:41:24 +00:00
|
|
|
|
ProjectStorage.Save(project, filename);
|
2014-07-26 07:12:56 +00:00
|
|
|
|
Project res = ProjectStorage.Load(filename);
|
|
|
|
|
|
|
|
|
|
// Test results
|
|
|
|
|
Assert.IsNotNull(res);
|
|
|
|
|
Assert.AreEqual(project.Author, res.Author);
|
|
|
|
|
Assert.AreEqual(project.AutoLoadFile, res.AutoLoadFile);
|
|
|
|
|
Assert.AreEqual(project.MinimumRainmeter, res.MinimumRainmeter);
|
|
|
|
|
Assert.AreEqual(project.MinimumWindows, res.MinimumWindows);
|
|
|
|
|
Assert.AreEqual(project.Name, res.Name);
|
|
|
|
|
Assert.AreEqual(project.Root, res.Root);
|
|
|
|
|
Assert.IsTrue(project.VariableFiles.SequenceEqual(res.VariableFiles));
|
|
|
|
|
Assert.AreEqual(project.Version, res.Version);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Project CreateProject()
|
|
|
|
|
{
|
|
|
|
|
// Create some file references
|
2014-08-31 11:41:24 +00:00
|
|
|
|
Reference folder1 = new Reference("folder1", "folder1");
|
|
|
|
|
Reference folder2 = new Reference("folder2", "folder2");
|
|
|
|
|
Reference file1 = new Reference("file1.txt", "folder1/file1.txt");
|
|
|
|
|
Reference file2 = new Reference("file2.ini", "folder2/file2.ini");
|
|
|
|
|
Reference file3 = new Reference("file3.bmp", "file3.bmp");
|
2014-07-26 07:12:56 +00:00
|
|
|
|
|
|
|
|
|
// Create a project
|
|
|
|
|
Project project = new Project();
|
|
|
|
|
project.Author = "Tiberiu Chibici";
|
|
|
|
|
project.MinimumRainmeter = new Version("3.1");
|
|
|
|
|
project.MinimumWindows = new Version("5.1");
|
|
|
|
|
project.Name = "My project";
|
|
|
|
|
project.Version = new Version("1.0.1");
|
|
|
|
|
|
|
|
|
|
project.AutoLoadFile = file2;
|
|
|
|
|
project.VariableFiles.Add(file1);
|
|
|
|
|
|
|
|
|
|
// Set project references
|
|
|
|
|
project.Root.Add(folder1);
|
|
|
|
|
project.Root.Add(folder2);
|
2014-08-31 11:41:24 +00:00
|
|
|
|
folder1.Add(file1);
|
|
|
|
|
folder2.Add(file2);
|
2014-07-26 07:12:56 +00:00
|
|
|
|
project.Root.Add(file3);
|
|
|
|
|
|
|
|
|
|
return project;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|