World Save Back and Restore Changes

1. added the SaveGames folder to the to the backup zip file.
2. now restores the SaveGames folder.
This commit is contained in:
Brett Hewitson 2022-05-02 11:32:06 +10:00
parent aa5c135be7
commit a5e749963a
19 changed files with 408 additions and 96 deletions

View file

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RootNamespace>ServerManager.Common.UnitTests</RootNamespace>
<AssemblyName>ServerManager.Common.UnitTests</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<None Remove="ServerManager.Common.UnitTests.csproj.vspscc" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ServerManager.Common\ServerManager.Common.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,50 @@
using System;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ServerManagerTool.Common.Utils;
namespace ServerManager.Common.Tests
{
[TestClass]
public class ZipUtilsUnitTest
{
[TestMethod]
public void ZipUtils_()
{
// Arrange
var zipFile = FetchZipFile();
var destinationPath = Path.Combine(@"D:\_smtest", Path.GetFileNameWithoutExtension(zipFile));
var destinationPath1 = Path.Combine(destinationPath, "SavedArks");
// Act
var count = ZipUtils.ExtractFiles(zipFile, destinationPath1, recurseFolders: false);
// Assert
Assert.AreEqual(3, count);
// Act
var exists = ZipUtils.DoesFolderExist(zipFile, "SaveGames");
// Assert
Assert.IsTrue(exists);
// Act
count = ZipUtils.ExtractFiles(zipFile, destinationPath, sourceFolder: "SaveGames", recurseFolders: true);
// Assert
Assert.AreEqual(6, count);
// Act
exists = ZipUtils.DoesFolderExist(zipFile, "AwesomeTeleporters");
// Assert
Assert.IsTrue(exists);
// Act
count = ZipUtils.ExtractFiles(zipFile, destinationPath, sourceFolder: "AwesomeTeleporters", recurseFolders: true);
// Assert
Assert.AreEqual(1, count);
}
private string FetchZipFile()
{
return @"D:\_smtest\new_theisland_20220501_221004.zip";
}
}
}