Source

stacky / trunk / source / Tests / Stacky.UnitTests / DateTests.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Stacky.UnitTests
{
    [TestClass]
    public class DateTests
    {
        [TestMethod]
        public void ImplicitUnixDateToLong()
        {
            DateTime date = DateTime.Now;
            UnixDateTime unixDate = new UnixDateTime(date);

            long actual = unixDate;
            long expected = UnixDateTime.UnixTimeFromDate(date);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ImplicitLongToUnixDate()
        {
            long date = UnixDateTime.UnixTimeFromDate(DateTime.Now);
            UnixDateTime unixDate = date;

            Assert.AreEqual(date, unixDate.UnixValue);
        }

        [TestMethod]
        public void ImplicitDateTimeToUnixDate()
        {
            DateTime date = DateTime.Now;
            UnixDateTime unixDate = date;

            Assert.AreEqual(date, unixDate.DateValue);
        }

        [TestMethod]
        public void ImplicitUnixDateToDateTime()
        {
            DateTime date = DateTime.Now;
            UnixDateTime unixDate = new UnixDateTime(date);

            DateTime actual = unixDate;
            Assert.AreEqual(date, actual);
        }

        [TestMethod]
        public void ToString_IsUnixDate()
        {
            long date = UnixDateTime.UnixTimeFromDate(DateTime.Now);
            UnixDateTime unixDate = new UnixDateTime(date);

            Assert.AreEqual(date.ToString(), unixDate.ToString());
        }

        [TestMethod]
        public void Uninitialized_DoesntThrowException()
        {
            UnixDateTime value = new UnixDateTime();
            string s = value.ToString();
            long unix = value;
            DateTime date = value;

            value = 1;
            value = DateTime.Now;
        }
    }
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.