mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Work on project storage
This commit is contained in:
parent
3d0a028920
commit
0c57cabe56
190
.gitignore
vendored
190
.gitignore
vendored
@ -1,15 +1,187 @@
|
||||
/TestBench
|
||||
/ipch
|
||||
bin
|
||||
obj
|
||||
x32*
|
||||
x64*
|
||||
Certificate.bat
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
build/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# Roslyn cache directories
|
||||
*.ide/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
/[Tt]est[Bb]ench
|
||||
|
||||
#NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.docstates
|
||||
*.exe
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.suo
|
||||
*.txt
|
||||
*.user
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding addin-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# If using the old MSBuild-Integrated Package Restore, uncomment this:
|
||||
#!**/packages/repositories.config
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
node_modules/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
16
RainmeterEditor/Business/ProjectManager.cs
Normal file
16
RainmeterEditor/Business/ProjectManager.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using RainmeterEditor.Model;
|
||||
|
||||
namespace RainmeterEditor.Business
|
||||
{
|
||||
public class ProjectManager
|
||||
{
|
||||
public Project ActiveProject { get; protected set; }
|
||||
|
||||
public void Open() { }
|
||||
public void Close() { }
|
||||
}
|
||||
}
|
114
RainmeterEditor/Model/Project.cs
Normal file
114
RainmeterEditor/Model/Project.cs
Normal file
@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace RainmeterEditor.Model
|
||||
{
|
||||
public class Project
|
||||
{
|
||||
[XmlElement("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[XmlElement("author")]
|
||||
public string Author { get; set; }
|
||||
|
||||
[XmlIgnore]
|
||||
public Version Version { get; set; }
|
||||
|
||||
[XmlElement("version")]
|
||||
public string VersionString
|
||||
{
|
||||
get
|
||||
{
|
||||
return Version.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
Version = new Version(value);
|
||||
}
|
||||
}
|
||||
|
||||
[XmlElement("autoLoadFile")]
|
||||
public Reference AutoLoadFile { get; set; }
|
||||
|
||||
[XmlArray("variableFiles")]
|
||||
public List<Reference> VariableFiles { get; set; }
|
||||
|
||||
[XmlIgnore]
|
||||
public Version MinimumRainmeter { get; set; }
|
||||
|
||||
[XmlElement("minimumRainmeter")]
|
||||
public string MinimumRainmeterString
|
||||
{
|
||||
get
|
||||
{
|
||||
return MinimumRainmeter.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
MinimumRainmeter = new Version(value);
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public Version MinimumWindows { get; set; }
|
||||
|
||||
[XmlElement("minimumWindows")]
|
||||
public string MinimumWindowsString
|
||||
{
|
||||
get
|
||||
{
|
||||
return MinimumWindows.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
MinimumWindows = new Version(value);
|
||||
}
|
||||
}
|
||||
|
||||
[XmlElement("root")]
|
||||
public Tree<Reference> Root { get; set; }
|
||||
|
||||
public Project()
|
||||
{
|
||||
Root = new Tree<Reference>();
|
||||
VariableFiles = new List<Reference>();
|
||||
Version = new Version();
|
||||
MinimumRainmeter = new Version("3.1");
|
||||
MinimumWindows = new Version("5.1");
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
Project other = obj as Project;
|
||||
|
||||
if (other == null)
|
||||
return false;
|
||||
|
||||
bool res = String.Equals(Author, other.Author);
|
||||
res &= Reference.Equals(AutoLoadFile, other.AutoLoadFile);
|
||||
res &= Version.Equals(MinimumRainmeter, other.MinimumRainmeter);
|
||||
res &= Version.Equals(MinimumWindows, other.MinimumWindows);
|
||||
res &= String.Equals(Name, other.Name);
|
||||
res &= Tree<Reference>.Equals(Root, other.Root);
|
||||
res &= Version.Equals(Version, other.Version);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hash = (Author == null) ? 0 : Author.GetHashCode();
|
||||
hash = hash * 7 + ((AutoLoadFile == null) ? 0 : AutoLoadFile.GetHashCode());
|
||||
hash = hash * 7 + ((MinimumRainmeter == null) ? 0 : MinimumRainmeter.GetHashCode());
|
||||
hash = hash * 7 + ((MinimumWindows == null) ? 0 : MinimumWindows.GetHashCode());
|
||||
hash = hash * 7 + ((Name == null) ? 0 : Name.GetHashCode());
|
||||
hash = hash * 7 + ((Root == null) ? 0 : Root.GetHashCode());
|
||||
hash = hash * 7 + ((Version == null) ? 0 : Version.GetHashCode());
|
||||
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
50
RainmeterEditor/Model/Reference.cs
Normal file
50
RainmeterEditor/Model/Reference.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace RainmeterEditor.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference to a file or folder
|
||||
/// </summary>
|
||||
public class Reference
|
||||
{
|
||||
[XmlAttribute("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[XmlAttribute("path")]
|
||||
public string Path { get; set; }
|
||||
|
||||
public Reference()
|
||||
{
|
||||
}
|
||||
|
||||
public Reference(string name, string path = null)
|
||||
{
|
||||
Name = name;
|
||||
Path = path;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as Reference;
|
||||
|
||||
// Types are different, so not equal
|
||||
if (other == null)
|
||||
return false;
|
||||
|
||||
// Compare using string equals
|
||||
return String.Equals(Name, other.Name) && String.Equals(Path, other.Path);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hash = (Name == null) ? 0 : Name.GetHashCode();
|
||||
hash = hash * 7 + ((Path == null) ? 0 : Path.GetHashCode());
|
||||
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
153
RainmeterEditor/Model/Tree.cs
Normal file
153
RainmeterEditor/Model/Tree.cs
Normal file
@ -0,0 +1,153 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace RainmeterEditor.Model
|
||||
{
|
||||
public class Tree<T>
|
||||
{
|
||||
[XmlElement("data")]
|
||||
public T Data { get; set; }
|
||||
|
||||
[XmlArray("children"), XmlArrayItem("child")]
|
||||
public List<Tree<T>> Children { get; set; }
|
||||
|
||||
public Tree()
|
||||
{
|
||||
Children = new List<Tree<T>>();
|
||||
Data = default(T);
|
||||
}
|
||||
|
||||
public Tree(T data)
|
||||
{
|
||||
Children = new List<Tree<T>>();
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public int IndexOf(Tree<T> item)
|
||||
{
|
||||
return Children.IndexOf(item);
|
||||
}
|
||||
|
||||
public void Insert(int index, Tree<T> item)
|
||||
{
|
||||
Children.Insert(index, item);
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
Children.RemoveAt(index);
|
||||
}
|
||||
|
||||
public Tree<T> this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return Children[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
Children[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(Tree<T> item)
|
||||
{
|
||||
Children.Add(item);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
Children.Clear();
|
||||
}
|
||||
|
||||
public bool Contains(Tree<T> item)
|
||||
{
|
||||
return Children.Contains(item);
|
||||
}
|
||||
|
||||
public void CopyTo(Tree<T>[] array, int arrayIndex)
|
||||
{
|
||||
Children.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return Children.Count; }
|
||||
}
|
||||
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public bool Remove(Tree<T> item)
|
||||
{
|
||||
return Children.Remove(item);
|
||||
}
|
||||
|
||||
public IEnumerator<Tree<T>> GetEnumerator()
|
||||
{
|
||||
return Children.GetEnumerator();
|
||||
}
|
||||
|
||||
public int IndexOf(T item)
|
||||
{
|
||||
return Children.IndexOf(new Tree<T>(item));
|
||||
}
|
||||
|
||||
public void Insert(int index, T item)
|
||||
{
|
||||
Children.Insert(index, new Tree<T>(item));
|
||||
}
|
||||
|
||||
public void Add(T item)
|
||||
{
|
||||
Children.Add(new Tree<T>(item));
|
||||
}
|
||||
|
||||
public bool Contains(T item)
|
||||
{
|
||||
return Children.Contains(new Tree<T>(item));
|
||||
}
|
||||
|
||||
public void CopyTo(T[] array, int arrayIndex)
|
||||
{
|
||||
foreach (var node in Children)
|
||||
array[arrayIndex++] = node.Data;
|
||||
}
|
||||
|
||||
public bool Remove(T item)
|
||||
{
|
||||
return Children.Remove(new Tree<T>(item));
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
Tree<T> other = obj as Tree<T>;
|
||||
|
||||
// Types are different, so not equal
|
||||
if (other == null)
|
||||
return false;
|
||||
|
||||
// Compare data
|
||||
if (!object.Equals(Data, other.Data))
|
||||
return false;
|
||||
|
||||
// Compare children array
|
||||
return Children.SequenceEqual(other.Children);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hash = ((Data == null) ? 0 : Data.GetHashCode());
|
||||
|
||||
foreach (var c in Children)
|
||||
hash = hash * 7 + c.GetHashCode();
|
||||
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
@ -70,6 +70,7 @@
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Business\DocumentManager.cs" />
|
||||
<Compile Include="Business\ProjectManager.cs" />
|
||||
<Compile Include="Documents\Text\TextDocument.cs" />
|
||||
<Compile Include="Documents\Text\TextEditorControl.xaml.cs">
|
||||
<DependentUpon>TextEditorControl.xaml</DependentUpon>
|
||||
@ -88,8 +89,11 @@
|
||||
<Compile Include="Documents\Text\TextEditor.cs" />
|
||||
<Compile Include="Documents\Text\TextEditorFactory.cs" />
|
||||
<Compile Include="Interop\NativeLibrary.cs" />
|
||||
<Compile Include="Model\Project.cs" />
|
||||
<Compile Include="Model\Property.cs" />
|
||||
<Compile Include="Model\RainmeterConfig.cs" />
|
||||
<Compile Include="Model\Reference.cs" />
|
||||
<Compile Include="Model\Tree.cs" />
|
||||
<Compile Include="Rainmeter.cs" />
|
||||
<Compile Include="Resources\Strings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
@ -97,6 +101,7 @@
|
||||
<DependentUpon>Strings.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Model\IDocumentStorage.cs" />
|
||||
<Compile Include="Storage\ProjectStorage.cs" />
|
||||
<Compile Include="Storage\SkinDirectory.cs" />
|
||||
<Compile Include="UI\Command.cs" />
|
||||
<Compile Include="UI\Dialogs\CreateDocumentDialog.xaml.cs">
|
||||
|
40
RainmeterEditor/Storage/ProjectStorage.cs
Normal file
40
RainmeterEditor/Storage/ProjectStorage.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using RainmeterEditor.Model;
|
||||
|
||||
namespace RainmeterEditor.Storage
|
||||
{
|
||||
public class ProjectStorage
|
||||
{
|
||||
public Project Load(string path)
|
||||
{
|
||||
// Open file
|
||||
var file = File.OpenText(path);
|
||||
|
||||
// Deserialize file
|
||||
var serializer = new XmlSerializer(typeof(Project), new XmlRootAttribute("project"));
|
||||
Project project = serializer.Deserialize(file) as Project;
|
||||
|
||||
// Clean up
|
||||
file.Close();
|
||||
return project;
|
||||
}
|
||||
|
||||
public void Save(string path, Project project)
|
||||
{
|
||||
// Open file
|
||||
var file = File.OpenWrite(path);
|
||||
|
||||
// Deserialize file
|
||||
var serializer = new XmlSerializer(typeof(Project), new XmlRootAttribute("project"));
|
||||
serializer.Serialize(file, project);
|
||||
|
||||
// Clean up
|
||||
file.Close();
|
||||
}
|
||||
}
|
||||
}
|
36
RainmeterStudio.Tests/Properties/AssemblyInfo.cs
Normal file
36
RainmeterStudio.Tests/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("RainmeterStudio.Tests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("RainmeterStudio.Tests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("e4fee45f-07d7-4ce8-96f7-b8dc29e62150")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
96
RainmeterStudio.Tests/RainmeterStudio.Tests.csproj
Normal file
96
RainmeterStudio.Tests/RainmeterStudio.Tests.csproj
Normal file
@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{845F4BD4-6822-4D92-9DDB-15FD18A47E5A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>RainmeterStudio.Tests</RootNamespace>
|
||||
<AssemblyName>RainmeterStudio.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
||||
<IsCodedUITest>False</IsCodedUITest>
|
||||
<TestProjectType>UnitTest</TestProjectType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
</ItemGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
|
||||
</ItemGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
<ItemGroup>
|
||||
<Compile Include="Storage\ProjectStorageTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Service References\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\RainmeterEditor\RainmeterStudio.csproj">
|
||||
<Project>{438d0136-4a27-4e4d-a617-fface4554236}</Project>
|
||||
<Name>RainmeterStudio</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
110
RainmeterStudio.Tests/Storage/ProjectStorageTest.cs
Normal file
110
RainmeterStudio.Tests/Storage/ProjectStorageTest.cs
Normal file
@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using RainmeterEditor.Storage;
|
||||
using RainmeterEditor.Model;
|
||||
using System.IO;
|
||||
|
||||
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
|
||||
ProjectStorage.Save(filename, project);
|
||||
Project res = ProjectStorage.Load(filename);
|
||||
|
||||
// Verify results
|
||||
Assert.IsNotNull(res);
|
||||
Assert.AreEqual(project, res);
|
||||
Assert.AreEqual(project.GetHashCode(), res.GetHashCode());
|
||||
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
|
||||
ProjectStorage.Save(filename, project);
|
||||
Project res = ProjectStorage.Load(filename);
|
||||
|
||||
// Test results
|
||||
Assert.IsNotNull(res);
|
||||
Assert.AreEqual(project, res);
|
||||
Assert.AreEqual(project.GetHashCode(), res.GetHashCode());
|
||||
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
|
||||
Reference folder1 = new Reference("folder1");
|
||||
Reference folder2 = new Reference("folder2");
|
||||
Reference file1 = new Reference("file1.txt");
|
||||
Reference file2 = new Reference("file2.ini");
|
||||
Reference file3 = new Reference("file3.bmp");
|
||||
|
||||
// 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);
|
||||
project.Root[0].Add(file1);
|
||||
project.Root[1].Add(file2);
|
||||
project.Root.Add(file3);
|
||||
|
||||
return project;
|
||||
}
|
||||
}
|
||||
}
|
@ -74,6 +74,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginWindowMessage", "Plug
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RainmeterStudio", "RainmeterEditor\RainmeterStudio.csproj", "{438D0136-4A27-4E4D-A617-FFACE4554236}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RainmeterStudio.Tests", "RainmeterStudio.Tests\RainmeterStudio.Tests.csproj", "{845F4BD4-6822-4D92-9DDB-15FD18A47E5A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -514,6 +516,18 @@ Global
|
||||
{438D0136-4A27-4E4D-A617-FFACE4554236}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{438D0136-4A27-4E4D-A617-FFACE4554236}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{438D0136-4A27-4E4D-A617-FFACE4554236}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{845F4BD4-6822-4D92-9DDB-15FD18A47E5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{845F4BD4-6822-4D92-9DDB-15FD18A47E5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{845F4BD4-6822-4D92-9DDB-15FD18A47E5A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{845F4BD4-6822-4D92-9DDB-15FD18A47E5A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{845F4BD4-6822-4D92-9DDB-15FD18A47E5A}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||
{845F4BD4-6822-4D92-9DDB-15FD18A47E5A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{845F4BD4-6822-4D92-9DDB-15FD18A47E5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{845F4BD4-6822-4D92-9DDB-15FD18A47E5A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{845F4BD4-6822-4D92-9DDB-15FD18A47E5A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{845F4BD4-6822-4D92-9DDB-15FD18A47E5A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{845F4BD4-6822-4D92-9DDB-15FD18A47E5A}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{845F4BD4-6822-4D92-9DDB-15FD18A47E5A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
Loading…
Reference in New Issue
Block a user