﻿using System;
using DerConverter.Asn;
using DerConverter.Asn.KnownTypes;
using NUnit.Framework;

namespace DerConverter.Tests.Asn.KnownTypes
{
    [TestFixture]
    public class DerAsnUtcTimeTests : Base<DerAsnUtcTime, DateTimeOffset>
    {
        public DerAsnUtcTimeTests() : base(DerAsnIdentifiers.Primitive.UtcTime) { }

        [TestCase("6 May 2018 16:45:40 -07:30", 0x31, 0x38, 0x30, 0x35, 0x30, 0x36, 0x31, 0x36, 0x34, 0x35, 0x34, 0x30, 0x2D, 0x30, 0x37, 0x33, 0x30)]
        [TestCase("18 Oct 2017 08:12:00 +01:00", 0x31, 0x37, 0x31, 0x30, 0x31, 0x38, 0x30, 0x38, 0x31, 0x32, 0x2B, 0x30, 0x31, 0x30, 0x30)]
        [TestCase("9 Sep 2099 08:12:00Z", 0x39, 0x39, 0x30, 0x39, 0x30, 0x39, 0x30, 0x38, 0x31, 0x32, 0x5A)]
        public void DecodeConstructor_ShouldDecodeCorrectly(string expectedValue, params int[] rawData)
        {
            base.DecodeConstructor_ShouldDecodeCorrectly(DateTimeOffset.Parse(expectedValue), rawData);
        }

        [TestCase("6 May 2018 16:45:40 -07:30", 0x31, 0x38, 0x30, 0x35, 0x30, 0x36, 0x31, 0x36, 0x34, 0x35, 0x34, 0x30, 0x2D, 0x30, 0x37, 0x33, 0x30)]
        [TestCase("18 Oct 2017 08:12:00 +01:00", 0x31, 0x37, 0x31, 0x30, 0x31, 0x38, 0x30, 0x38, 0x31, 0x32, 0x2B, 0x30, 0x31, 0x30, 0x30)]
        [TestCase("9 Sep 2099 08:12:00Z", 0x39, 0x39, 0x30, 0x39, 0x30, 0x39, 0x30, 0x38, 0x31, 0x32, 0x5A)]
        public void Encode_ShouldEncodeCorrectly(string value, params int[] expectedRawData)
        {
            base.Encode_ShouldEncodeCorrectly(DateTimeOffset.Parse(value), expectedRawData);
        }
    }
}
