提交 138ac02a 编写于 作者: N nulltoken

Renamed EpochHelper to Epoch.

上级 98157253
......@@ -4,13 +4,13 @@
namespace libgit2sharp.Tests
{
[TestFixture]
public class EpochHelperFixture
public class EpochFixture
{
[TestCase(0)]
[TestCase(17)]
public void ToDateDateTimeOffset_ShouldReturnAUtcBasedDateTimeOffset(Int32 secondsSinceEpoch)
{
DateTimeOffset when = EpochHelper.ToDateTimeOffset(secondsSinceEpoch);
DateTimeOffset when = Epoch.ToDateTimeOffset(secondsSinceEpoch);
Assert.AreEqual(TimeSpan.Zero, when.Offset);
Assert.AreEqual(DateTimeKind.Utc, when.UtcDateTime.Kind);
}
......@@ -20,7 +20,7 @@ public void ToDateDateTimeOffset_ShouldReturnAUtcBasedDateTimeOffset(Int32 secon
[TestCase(1288114383, "Tue, 26 Oct 2010 17:33:03 GMT")]
public void ToDateDateTimeOffset_ShouldCorrectlyConvert(Int32 secondsSinceEpoch, string expected)
{
DateTimeOffset when = EpochHelper.ToDateTimeOffset(secondsSinceEpoch);
DateTimeOffset when = Epoch.ToDateTimeOffset(secondsSinceEpoch);
var expectedDate = DateTimeOffset.Parse(expected);
Assert.AreEqual(expectedDate, when);
}
......
......@@ -155,7 +155,7 @@ private static void AssertTag0c37a53(string objectId, Tag tag)
Assert.AreEqual("v1.0", tag.Name);
Assert.AreEqual("schacon@gmail.com", tag.Tagger.Email);
Assert.AreEqual("test tag message\n", tag.Message);
Assert.AreEqual(EpochHelper.ToDateTimeOffset(1288114383), tag.Tagger.Time);
Assert.AreEqual(Epoch.ToDateTimeOffset(1288114383), tag.Tagger.Time);
Assert.AreEqual("5b5b025afb0b4c913b4c338a42934a3863bf3644", tag.Target.Id);
}
......
......@@ -43,7 +43,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="EpochHelperFixture.cs" />
<Compile Include="EpochFixture.cs" />
<Compile Include="ObjectIdFixture.cs" />
<Compile Include="RepositoryFixtures.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
......
......@@ -2,13 +2,13 @@
namespace libgit2sharp
{
public static class EpochHelper
public static class Epoch
{
public static readonly DateTimeOffset Epoch = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
private static readonly DateTimeOffset EpochDateTimeOffset = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
public static DateTimeOffset ToDateTimeOffset(Int32 secondsSinceEpoch)
{
return Epoch.AddSeconds(secondsSinceEpoch);
return EpochDateTimeOffset.AddSeconds(secondsSinceEpoch);
}
}
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ internal Commit Build()
var gitTree = (git_tree)Marshal.PtrToStructure(tree, typeof(git_tree));
Tree commitTree = gitTree.Build();
return new Commit(ObjectId.ToString(commit.id.id), commitAuthor, commitCommitter, EpochHelper.ToDateTimeOffset((int)time), message, message_short, commitTree);
return new Commit(ObjectId.ToString(commit.id.id), commitAuthor, commitCommitter, Epoch.ToDateTimeOffset((int)time), message, message_short, commitTree);
}
}
}
......@@ -16,7 +16,7 @@ internal struct git_person
internal Person Build()
{
return new Person(name, email, EpochHelper.ToDateTimeOffset((int)time));
return new Person(name, email, Epoch.ToDateTimeOffset((int)time));
}
}
}
\ No newline at end of file
......@@ -42,7 +42,7 @@
<ItemGroup>
<Compile Include="Blob.cs" />
<Compile Include="Commit.cs" />
<Compile Include="EpochHelper.cs" />
<Compile Include="Epoch.cs" />
<Compile Include="IObjectHeaderReader.cs" />
<Compile Include="IResolver.cs" />
<Compile Include="ObjectId.cs" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册