Added auto updater
This commit is contained in:
@@ -48,8 +48,10 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Repositories\TestItemFilterScriptRepository.cs" />
|
||||
<Compile Include="Services\TestHTTPService.cs" />
|
||||
<Compile Include="Services\TestItemFilterPersistenceService.cs" />
|
||||
<Compile Include="Services\TestStaticDataService.cs" />
|
||||
<Compile Include="Services\TestUpdateService.cs" />
|
||||
<Compile Include="Translators\TestBlockGroupHierarchyBuilder.cs" />
|
||||
<Compile Include="Translators\TestItemFilterBlockTranslator.cs" />
|
||||
<Compile Include="Translators\TestItemFilterScriptTranslator.cs" />
|
||||
|
||||
23
Filtration.Tests/Services/TestHTTPService.cs
Normal file
23
Filtration.Tests/Services/TestHTTPService.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Filtration.Services;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Filtration.Tests.Services
|
||||
{
|
||||
[Ignore("Integration Test - Makes real HTTP call")]
|
||||
[TestFixture]
|
||||
public class TestHTTPService
|
||||
{
|
||||
[Test]
|
||||
public async void GetContent_FetchesDataFromUrl()
|
||||
{
|
||||
// Arrange
|
||||
var service = new HTTPService();
|
||||
|
||||
// Act
|
||||
var result = await service.GetContentAsync("http://ben-wallis.github.io/Filtration/filtration_version.xml");
|
||||
|
||||
// Assert
|
||||
Assert.IsNotNull(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
53
Filtration.Tests/Services/TestUpdateService.cs
Normal file
53
Filtration.Tests/Services/TestUpdateService.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Filtration.Models;
|
||||
using Filtration.Services;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Filtration.Tests.Services
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestUpdateService
|
||||
{
|
||||
[Test]
|
||||
public void DeserializeUpdateData_ReturnsCorrectData()
|
||||
{
|
||||
// Arrange
|
||||
var testInputData = @"<UpdateData>
|
||||
<CurrentVersion>0.2</CurrentVersion>
|
||||
<ReleaseDate>2015-07-01</ReleaseDate>
|
||||
<DownloadUrl>http://www.google.com</DownloadUrl>
|
||||
<ReleaseNotes>* Release notes line 1
|
||||
* Release notes line 2
|
||||
* More really great release notes!</ReleaseNotes>
|
||||
</UpdateData>";
|
||||
|
||||
var expectedResult = new UpdateData
|
||||
{
|
||||
CurrentVersion = 0.2m,
|
||||
DownloadUrl = "http://www.google.com",
|
||||
ReleaseDate = new DateTime(2015, 7, 1),
|
||||
ReleaseNotes = @"* Release notes line 1
|
||||
* Release notes line 2
|
||||
* More really great release notes!"
|
||||
};
|
||||
|
||||
var mockHTTPService = new Mock<IHTTPService>();
|
||||
var service = new UpdateCheckService(mockHTTPService.Object);
|
||||
|
||||
// Act
|
||||
var result = service.DeserializeUpdateData(testInputData);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(expectedResult.CurrentVersion, result.CurrentVersion);
|
||||
Assert.AreEqual(expectedResult.DownloadUrl, result.DownloadUrl);
|
||||
Assert.AreEqual(expectedResult.ReleaseDate, result.ReleaseDate);
|
||||
Assert.AreEqual(expectedResult.ReleaseNotes, result.ReleaseNotes);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user