refactor(storage): rename TasMemory to TasStorage and update references
- Renamed TasMemory.cs file to TasStorage.cs - Updated project file reference from TasMemory to TasStorage - Removed unused test project files and configurations - Fixed solution file project name and GUID references - Cleaned up obsolete MSTest configuration files
This commit is contained in:
74
BallanceTasEditorTests/BallanceTasEditorTests.csproj
Normal file
74
BallanceTasEditorTests/BallanceTasEditorTests.csproj
Normal file
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{D2E825CE-691B-48D7-8D87-D2CED1B25FF9}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>BallanceTasEditorTests</RootNamespace>
|
||||
<AssemblyName>BallanceTasEditorTests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.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>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</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>
|
||||
</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="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utils\TasStorageTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BallanceTasEditor\BallanceTasEditor.csproj">
|
||||
<Project>{dd898514-03ed-4257-afd1-290eedf68113}</Project>
|
||||
<Name>BallanceTasEditor</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props'))" />
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets')" />
|
||||
</Project>
|
||||
20
BallanceTasEditorTests/Properties/AssemblyInfo.cs
Normal file
20
BallanceTasEditorTests/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("BallanceTasEditorTests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("BallanceTasEditorTests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2025")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
[assembly: Guid("d2e825ce-691b-48d7-8d87-d2ced1b25ff9")]
|
||||
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
164
BallanceTasEditorTests/Utils/TasStorageTests.cs
Normal file
164
BallanceTasEditorTests/Utils/TasStorageTests.cs
Normal file
@ -0,0 +1,164 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BallanceTasEditor.Utils;
|
||||
|
||||
namespace BallanceTasEditorTests.Utils {
|
||||
[TestClass]
|
||||
public class TasStorageTests {
|
||||
|
||||
private static readonly int[] PROBE = { 10, 20, 30, 40, 50 };
|
||||
|
||||
private static IEnumerable<object[]> TasStorageInstanceProvider {
|
||||
get {
|
||||
yield return new object[] { new ListTasStorage<int>() };
|
||||
yield return new object[] { new LegacyTasStorage<int>() };
|
||||
// TODO: Add GapBufferTasStorage once we finish it.
|
||||
//yield return new object[] { new GapBufferTasStorage<int>() };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Visit函数独立测试。
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[DynamicData(nameof(TasStorageInstanceProvider))]
|
||||
public void VisitTest(ITasStorage<int> storage) {
|
||||
// 空时访问
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => storage.Visit(-1));
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => storage.Visit(0));
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => storage.Visit(1));
|
||||
|
||||
// 设置数据
|
||||
storage.Insert(0, PROBE);
|
||||
// 访问数据
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => storage.Visit(-1));
|
||||
for (int i = 0; i < PROBE.Length; i++) {
|
||||
Assert.AreEqual(storage.Visit(i), PROBE[i]);
|
||||
}
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => storage.Visit(PROBE.Length));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Insert函数独立测试。
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[DynamicData(nameof(TasStorageInstanceProvider))]
|
||||
public void InsertTest(ITasStorage<int> storage) {
|
||||
// 需要在不同的存储器上,分别检测在空的时候插入,
|
||||
// 和在非空时的头,中,尾分别插入的结果。
|
||||
|
||||
// 先检测空插入
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => storage.Insert(-1, PROBE));
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => storage.Insert(1, PROBE));
|
||||
storage.Insert(0, PROBE);
|
||||
for (int i = 0; i < PROBE.Length; i++) {
|
||||
Assert.AreEqual(storage.Visit(i), PROBE[i]);
|
||||
}
|
||||
|
||||
// 再检测有数据的插入,分别在头尾和中间进行
|
||||
var indices = new int[] { 0, PROBE.Length / 2, PROBE.Length - 1, PROBE.Length };
|
||||
foreach (var index in indices) {
|
||||
// 清空,一次插入,然后二次插入
|
||||
storage.Clear();
|
||||
storage.Insert(0, PROBE);
|
||||
storage.Insert(index, PROBE);
|
||||
|
||||
// 用List做正确模拟
|
||||
var expected = new List<int>();
|
||||
expected.AddRange(PROBE);
|
||||
expected.InsertRange(index, PROBE);
|
||||
|
||||
// 检查结果
|
||||
Assert.AreEqual(storage.GetCount(), expected.Count);
|
||||
for (int i = 0; i < expected.Count; i++) {
|
||||
Assert.AreEqual(storage.Visit(i), expected[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove函数独立测试。
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[DynamicData(nameof(TasStorageInstanceProvider))]
|
||||
public void RemoveTest(ITasStorage<int> storage) {
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear函数独立测试。
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[DynamicData(nameof(TasStorageInstanceProvider))]
|
||||
public void ClearTest(ITasStorage<int> storage) {
|
||||
// 设置数据后清空
|
||||
storage.Insert(0, PROBE);
|
||||
storage.Clear();
|
||||
|
||||
// 检查是否为空
|
||||
Assert.IsTrue(storage.IsEmpty());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IsEmpty函数独立测试。
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[DynamicData(nameof(TasStorageInstanceProvider))]
|
||||
public void IsEmptyTest(ITasStorage<int> storage) {
|
||||
// 检查是否为空
|
||||
Assert.IsTrue(storage.IsEmpty());
|
||||
|
||||
// 插入数据后再检查
|
||||
storage.Insert(0, PROBE);
|
||||
Assert.IsFalse(storage.IsEmpty());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetCount函数独立测试。
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[DynamicData(nameof(TasStorageInstanceProvider))]
|
||||
public void GetCountTest(ITasStorage<int> storage) {
|
||||
// 检查长度为0
|
||||
Assert.AreEqual(storage.GetCount(), 0);
|
||||
|
||||
// 插入数据后再检查
|
||||
storage.Insert(0, PROBE);
|
||||
Assert.AreEqual(storage.GetCount(), PROBE.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 混合检查Visit,Clear,GetCount,IsEmpty。
|
||||
/// </summary>
|
||||
/// <param name="storage"></param>
|
||||
[TestMethod]
|
||||
[DynamicData(nameof(TasStorageInstanceProvider))]
|
||||
public void HybridTest(ITasStorage<int> storage) {
|
||||
// 检查空和大小
|
||||
Assert.IsTrue(storage.IsEmpty());
|
||||
Assert.AreEqual(storage.GetCount(), 0);
|
||||
|
||||
// 设置内容
|
||||
storage.Insert(0, PROBE);
|
||||
// 并再次检查大小
|
||||
Assert.IsFalse(storage.IsEmpty());
|
||||
Assert.AreEqual(storage.GetCount(), PROBE.Length);
|
||||
|
||||
// 访问数据
|
||||
var len = PROBE.Length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Assert.AreEqual(storage.Visit(i), PROBE[i]);
|
||||
}
|
||||
|
||||
// 清空数据
|
||||
storage.Clear();
|
||||
// 再次检查数据
|
||||
Assert.IsTrue(storage.IsEmpty());
|
||||
Assert.AreEqual(storage.GetCount(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
5
BallanceTasEditorTests/packages.config
Normal file
5
BallanceTasEditorTests/packages.config
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MSTest.TestAdapter" version="2.2.10" targetFramework="net48" />
|
||||
<package id="MSTest.TestFramework" version="2.2.10" targetFramework="net48" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user