func TestEqualIsTrue(t *testing.T) {
	isEqual := misc.NewDateTime(testTime).Equal(misc.NewDateTime(testTime))
	testUtil.Assert(t, isEqual, "expected values to be equal")
}
func TestBeforeThanIsTrue(t *testing.T) {
	newTime := testTime.Add(duration250ms)
	isBefore := misc.NewDateTime(testTime).Before(misc.NewDateTime(newTime))
	testUtil.Assert(t, isBefore, "expected value to be before")
}
func TestAfterThanIsTrue(t *testing.T) {
	timeAfterOriginal := testTime.Add(duration250ms)
	isAfter := misc.NewDateTime(timeAfterOriginal).After(misc.NewDateTime(testTime))
	testUtil.Assert(t, isAfter, "expected value to be after")
}
//    under the License.

package misc_test

import (
	"encoding/json"
	"testing"
	"time"

	"git.openstack.org/stackforge/golang-client.git/misc"
	"git.openstack.org/stackforge/golang-client.git/testUtil"
)

var milliSecondsTestValue = `{"created_at":"2015-01-26T22:47:27.851022"}`
var milliSecondsTestTime, _ = time.Parse(`"2006-01-02T15:04:05.999999"`, `"2015-01-26T22:47:27.851022"`)
var milliSecondsTimeTestValue = timeTest{CreatedAt: misc.NewDateTime(milliSecondsTestTime)}

var testValue = `{"created_at":"2014-09-29T14:44:31"}`
var testTime, _ = time.Parse(`"2006-01-02T15:04:05"`, `"2014-09-29T14:44:31"`)
var timeTestValue = timeTest{CreatedAt: misc.NewDateTime(testTime)}
var duration250ms, _ = time.ParseDuration("250ms")

func TestMarshalTimeTestMilliseconds(t *testing.T) {
	bytes, _ := json.Marshal(milliSecondsTimeTestValue)

	testUtil.Equals(t, milliSecondsTestValue, string(bytes))
}

func TestUnmarshalValidTimeTestMilliseconds(t *testing.T) {
	val := timeTest{}
	err := json.Unmarshal([]byte(milliSecondsTestValue), &val)