2015-07-02 15:19:32 -04:00
|
|
|
|
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>
|
2015-07-04 11:47:28 -04:00
|
|
|
|
<LatestVersionMajorPart>1</LatestVersionMajorPart>
|
|
|
|
|
<LatestVersionMinorPart>3</LatestVersionMinorPart>
|
2015-07-02 15:19:32 -04:00
|
|
|
|
<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
|
|
|
|
|
{
|
2015-07-04 11:47:28 -04:00
|
|
|
|
LatestVersionMajorPart = 1,
|
|
|
|
|
LatestVersionMinorPart = 3,
|
2015-07-02 15:19:32 -04:00
|
|
|
|
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
|
2015-07-04 11:47:28 -04:00
|
|
|
|
Assert.AreEqual(expectedResult.LatestVersionMajorPart, result.LatestVersionMajorPart);
|
|
|
|
|
Assert.AreEqual(expectedResult.LatestVersionMinorPart, result.LatestVersionMinorPart);
|
2015-07-02 15:19:32 -04:00
|
|
|
|
Assert.AreEqual(expectedResult.DownloadUrl, result.DownloadUrl);
|
|
|
|
|
Assert.AreEqual(expectedResult.ReleaseDate, result.ReleaseDate);
|
|
|
|
|
Assert.AreEqual(expectedResult.ReleaseNotes, result.ReleaseNotes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|