bovender framework
C# framework that implements MVVM and more
ReleaseInfoTest.cs
1 /* ReleaseInfoTest.cs
2  * part of Bovender framework
3  *
4  * Copyright 2014-2018 Daniel Kraus
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 using System;
19 using System.Collections.Generic;
20 using System.Linq;
21 using System.Text;
22 using System.IO;
23 using NUnit.Framework;
24 using Bovender.Versioning;
25 
26 namespace Bovender.UnitTests.Versioning
27 {
28  [TestFixture]
30  {
31  [Test]
32  public void ParseReleaseInfo()
33  {
34  string version = "1.2.3";
35  string url = "http://example.com/$VERSION/release-$VERSION.exe";
36  string hash = "db9ff4b6213b52020e8b4b818f4705773d27717cad64d5587213b31597b7df89 Dummy SHA-256 hash";
37  string summary = "This\r\nis a multi-line\r\nrelease summary.";
38  string raw = version + "\r\n" + url + "\r\n" + hash + "\r\n" + summary + "\r\n";
40  Assert.AreEqual(raw, ri.RawReleaseInfo, "Raw release info");
41  Assert.AreEqual(version, ri.ReleaseVersion.ToString(), "ReleaseVersion");
42  Assert.AreEqual(String.Format("http://example.com/{0}/release-{0}.exe", version), ri.DownloadUri.ToString(),
43  "Version-substituted URL");
44  Assert.AreEqual(summary.Replace("\r\n", " "), ri.Summary, "Summary");
45  }
46 
47  [Test]
48  public void ParsePartialReleaseInfo()
49  {
50  string version = "1.2.3";
51  string url = "http://example.com/$VERSION/release-$VERSION.exe";
52  string raw = version + "\r\n" + url + "\r\n";
54  Assert.AreEqual(ReleaseInfoStatus.FailureToParse, ri.Status, "Status should indicate failure to parse");
55  Assert.AreEqual(raw, ri.RawReleaseInfo, "Raw release info");
56  Assert.AreEqual(null, ri.ReleaseVersion, "ReleaseVersion should be null");
57  }
58  }
59 }
override string ToString()
Returns the full version string.